Skip to content

Commit

Permalink
added more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
andieswift committed Jan 23, 2025
1 parent bf2e0ec commit 0a1c885
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions lib/lambda/adminActions/submitNOSO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,45 @@ import { ItemResult } from "shared-types/opensearch/main";
import { submitNOSOAdminSchema } from "./adminSchemas";

export const copyAttachments = async (data: any) => {
console.log("ANDIE******:", data, data.copyAttachmentsFromId);
console.log("ANDIE******:", data);

const currentPackage = await getPackage(data._id);
const currentPackageChangelog = await getPackageChangelog(data._id);
// check for id
if (!data.id) {
console.log("Error with data.id");
return data;
}

const currentPackage = await getPackage(data.id);
const currentPackageChangelog = await getPackageChangelog(data.id);

console.log("current Package", currentPackage);
console.log("current package changelog", currentPackageChangelog);

console.log("andie", currentPackage);
if (!currentPackage || currentPackage.found == false) {
console.error(`Current package id: ${currentPackage} not found`);
return data;
}

if (!currentPackageChangelog) {
console.error(`Current package change log id: ${currentPackage} not found`);
return data;
}

//@ts-ignore
const copyAttachmentsFromId = currentPackage?._source.copyAttachmentsFromId;
console.log(`atempting to copy attachments from ${copyAttachmentsFromId}...`);

if (!copyAttachmentsFromId) {
console.log("Copy Attachment Id not found.");
return data;
}
// get the attachementPackage
const attachPackage = await getPackage(copyAttachmentsFromId);
const attachPackageChangelog = await getPackageChangelog(copyAttachmentsFromId);

console.log("Attach Package", attachPackage);
console.log("Attach package changelog", attachPackageChangelog);

if (!attachPackage || attachPackage.found == false) {
console.error(`Copy Attachment Package of id: ${copyAttachmentsFromId} not found`);
return data;
Expand All @@ -39,7 +59,7 @@ export const copyAttachments = async (data: any) => {
return data;
}

if (attachPackage) {
if (attachPackage && attachPackage) {
// const attachments = structuredClone(attachPackage._source.changelog);
console.log("ANDIEEEEEEE ***********");
console.log("attachment package: ", attachPackage);
Expand All @@ -61,6 +81,9 @@ export const copyAttachments = async (data: any) => {

return currentPackageChangelog.hits.hits[length];
}

console.log("did not copy over attachements");
return data;
};

const sendSubmitMessage = async ({
Expand Down

0 comments on commit 0a1c885

Please sign in to comment.