Skip to content

Commit

Permalink
Merge pull request #98 from Ferlab-Ste-Justine/fix/clin-3620
Browse files Browse the repository at this point in the history
fix: CLIN-3620 update latest record if not touching flags
  • Loading branch information
meek0 authored Dec 4, 2024
2 parents a33e2eb + a888600 commit 25b4b48
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/db/dal/variant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ export const addNewEntry = async function (

const combinedProperties = { ...(variantFound?.properties || {}), ...properties };

return await VariantModel.create({
unique_id: uniqueId,
organization_id: organizationId,
author_id: authorId,
properties: combinedProperties,
timestamp: new Date(),
});
if (Object.keys(properties).indexOf('flags') > -1 && variantFound) {
return await variantFound.update({ properties: combinedProperties, timestamp: new Date(), });
} else {
return await VariantModel.create({
unique_id: uniqueId,
organization_id: organizationId,
author_id: authorId,
properties: combinedProperties,
timestamp: new Date(),
});
}
};

export const getEntriesByUniqueIdsAndOrganizations = async function (uniqueIds: string[], organizationIds: string[]) {
Expand Down

0 comments on commit 25b4b48

Please sign in to comment.