Skip to content

Commit

Permalink
Syntax updates after review
Browse files Browse the repository at this point in the history
  • Loading branch information
TimCsaky committed Nov 3, 2023
1 parent a6f44cf commit b4a60e8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions app/src/components/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,7 @@ const utils = {
* @returns array of unique objects based on value of a given property
*/
getUniqueObjects(array, key) {
return [...new Map(array.map(item =>
[item[key], item])).values()];
return [...new Map(array.map(item => [item[key], item])).values()];
},

/**
Expand Down
8 changes: 3 additions & 5 deletions app/src/services/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ const service = {

// get COMS versions that are not in S3 (matching on s3VersionId) OR not
// in list of unique COMS versions (matching on id)
const cVsToDelete = comsVersions.filter(function(cv) {
const cVsToDelete = comsVersions.filter(cv => {
const notInS3 = !s3Versions.some(s3v => (s3v.VersionId === String(cv.s3VersionId)));
const isDuplicate = !uniqueCVIds.includes(cv.id);
return notInS3 || isDuplicate;
});

if(cVsToDelete?.length > 0){
if(cVsToDelete.length){
await Version.query(trx)
.delete()
.where('objectId', comsObject.id)
Expand Down Expand Up @@ -380,9 +380,7 @@ const service = {
// Associate new S3 Tags
const newTags = [];
for (const s3Tag of s3Tags) {
if (!comsTags.some(comsT => {
return (comsT.key === s3Tag.key && comsT.value === s3Tag.value);
})) {
if (!comsTags.some(comsT => comsT.key === s3Tag.key && comsT.value === s3Tag.value)) {
newTags.push(s3Tag);
} else {
response.push(s3Tag);
Expand Down
4 changes: 1 addition & 3 deletions app/src/services/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ const service = {
/**
* @function delete
* Delete a version record of an object
* Note: For consistency, it is recommended to sync isLatest with S3 by calling
* `service.updateIsLatest()` after invoking this function
* @param {string} objId The object uuid
* @param {string} s3VersionId The version ID or null if deleting an object
* @param {string} [userId=undefined] An optional uuid of a user
Expand Down Expand Up @@ -284,7 +282,7 @@ const service = {
* Determines latest by checking S3 and ensures only one version has isLatest: true
* @param {string} objectId COMS object uuid
* @param {object} [etrx=undefined] An optional Objection Transaction object
* @returns {object} Version model of provided version in db
* @returns {object} Version model of latest version
*/
updateIsLatest: async (objectId, etrx = undefined) => {
// TODO: consider having accepting a `userId` argument for version.updatedBy when a version becomes 'latest'
Expand Down

0 comments on commit b4a60e8

Please sign in to comment.