Skip to content

Commit

Permalink
removed undefined tieBreakScore from tagger
Browse files Browse the repository at this point in the history
  • Loading branch information
awest25 committed Jun 6, 2024
1 parent 83f99b6 commit 515da3c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/(interactive)/tag-match/[slug]/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export default function TagMatch() {
: combinedRows;

// Filter out duplicates based on pointStartTime, keeping the last occurrence
const uniqueRows = combinedRows.reduceRight((acc, row) => {
let uniqueRows = combinedRows.reduceRight((acc, row) => {
acc.pointStartTimes.add(row.pointStartTime);
if (acc.pointStartTimes.has(row.pointStartTime) && !acc.added.has(row.pointStartTime)) {
acc.rows.unshift(row); // Add the row to the beginning to maintain order
Expand All @@ -282,6 +282,16 @@ export default function TagMatch() {
return acc;
}, { rows: [], pointStartTimes: new Set(), added: new Set() }).rows;

// If any rows have a value of undefined, set it to an empty string
// This is a requirement for Firestore
uniqueRows.forEach(row => {
for (const key in row) {
if (row[key] === undefined) {
row[key] = '';
}
}
});

// Update the document in Firestore with the unique rows
await updateMatchDocument(matchId, {
points: uniqueRows
Expand Down

0 comments on commit 515da3c

Please sign in to comment.