Skip to content

Commit b56de95

Browse files
committed
Fixed minor issues with duplicate record processing
* Now treating “artist” as a required field for record ingestion. * Only ingest rating if provided _and_ greater than 0 (Discog’s lowest user-adjustable value is 1). * Fixing bug with record updating where the wrong record was notified to the frontend.
1 parent 94b3bed commit b56de95

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

backend/records/Fetcher.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,11 @@ export default class Fetcher {
370370
recordBuilder.setYearOfPressing(discogsRecord.basic_information.year);
371371
recordBuilder.setDiscogsAddedOn(discogsRecord.date_added);
372372
recordBuilder.setArtist(discogsRecord.basic_information.artists[0].name);
373+
// Don't process any record returned by Discogs without an Artist
374+
if (!("name" in discogsRecord.basic_information.artists[0])) {
375+
log.debug("Record found missing artist, skipping title=" + record.title);
376+
return;
377+
}
373378

374379
// There is not an associated folder if getting wishlist items
375380
if ("folder_id" in discogsRecord) {
@@ -380,8 +385,8 @@ export default class Fetcher {
380385
} else if ("thumb" in discogsRecord.basic_information) {
381386
recordBuilder.setDiscogsAlbumArtUrl(discogsRecord.basic_information.thumb);
382387
}
383-
// If there's no rating, the rating field isn't returned
384-
if ("rating" in discogsRecord) {
388+
// If there's no rating, the rating field is returned as "0"
389+
if ("rating" in discogsRecord && discogsRecord.rating != 0) {
385390
recordBuilder.setRating(discogsRecord.rating);
386391
}
387392

@@ -413,9 +418,9 @@ export default class Fetcher {
413418
// Notify the backend server of the update
414419
if (this.backendSocket) {
415420
if (record.inWishlist) {
416-
this.backendSocket.emit(socketCodes.UPDATED_RECORD_IN_WISHLIST, record);
421+
this.backendSocket.emit(socketCodes.UPDATED_RECORD_IN_WISHLIST, updatedRecord);
417422
} else {
418-
this.backendSocket.emit(socketCodes.UPDATED_RECORD_IN_COLLECTION, record);
423+
this.backendSocket.emit(socketCodes.UPDATED_RECORD_IN_COLLECTION, updatedRecord);
419424
}
420425
}
421426
} else {

0 commit comments

Comments
 (0)