Skip to content

Commit

Permalink
Better added/removed song detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Brainicism committed Oct 1, 2024
1 parent ddc0edc commit a345231
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/seed/seed_db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,19 @@ async function reloadAutocompleteData(): Promise<void> {

logger.info("Calculating songs both added and removed");
const songsAddedLinks = songsAdded.map((x) => x.link);
const songNameHash = function (a: AvailableSongDeltaData): string {
return `${a.song_name_en}|${a.artist_name_en}`.toLowerCase();
};

const songAddedNameHashes = songsAdded.map((x) => songNameHash(x));

const addedAndRemovedLinks = new Set(
songsRemoved
.filter((removed) => songsAddedLinks.includes(removed.link))
.filter(
(removed) =>
songsAddedLinks.includes(removed.link) ||
songAddedNameHashes.includes(songNameHash(removed)),
)
.map((x) => x.link),
);

Expand Down

0 comments on commit a345231

Please sign in to comment.