Skip to content

Commit

Permalink
Fill durations for all records (#926)
Browse files Browse the repository at this point in the history
Because old FC records got no duration because FC Date was not bumped.
  • Loading branch information
anantakrishna committed May 9, 2024
1 parent 62b06c9 commit aab8f93
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions functions/src/FidelityCheck/FC.functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,22 @@ export const importRecords = functions
generation: file.metadata.generation,
};

const duration = metadataCacheSnapshot
.child(getFileDurationPath(file))
.val() as number;

if (!duration) return 'Duration is not available';

if (
existingRecord &&
existingRecord.file &&
existingRecord.fidelityCheck &&
fidelityCheck.timestamp <= existingRecord.fidelityCheck.timestamp
) {
// Saving durations for old records
if (!existingRecord.duration)
await recordSnapshot.ref.update({ duration });

// Comparing file info if the FC Date was not bumped
if (getDiff(existingRecord.file, fileReference).length)
// It is unlikely we get here due to the dates comparison earlier. But as a safety net we keep this check.
Expand All @@ -199,9 +209,7 @@ export const importRecords = functions
await recordSnapshot.ref.update({
file: fileReference,
fidelityCheck,
duration: metadataCacheSnapshot
.child(getFileDurationPath(file))
.val() as number,
duration,
});

/**
Expand Down

0 comments on commit aab8f93

Please sign in to comment.