Skip to content

Commit

Permalink
fix: rating filter doesn't work
Browse files Browse the repository at this point in the history
add rating conversion

fixes #48
  • Loading branch information
shayded-exe committed Jun 19, 2021
1 parent 98c4e3b commit 9f17889
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/app/engine/1.6/engine-db-1_6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,19 @@ export class EngineDB_1_6 extends EngineDB {
textMetaMap[track.id] ?? [],
(result, meta) => {
const key = schema.MetaDataType[meta.type];
result[key] = meta.text;
if (key) {
result[key] = meta.text;
}
},
{} as any,
),
...transform(
intMetaMap[track.id] ?? [],
(result, meta) => {
const key = schema.MetaDataIntegerType[meta.type];
result[key] = meta.value;
if (key) {
result[key] = meta.value;
}
},
{} as any,
),
Expand Down
1 change: 1 addition & 0 deletions src/app/engine/1.6/schema-1_6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export enum MetaDataIntegerType {
dateAdded = 2,
dateCreated = 3,
key = 4,
rating = 5,
}

export interface MetaDataInteger {
Expand Down
29 changes: 28 additions & 1 deletion src/app/views/smart-command.vue
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,33 @@ function getTrackValue(
}
}
return track[getTrackField()];
function convertRating(rating: number): number {
if (rating <= 0) {
return 0;
} else if (rating <= 20) {
return 1;
} else if (rating <= 40) {
return 2;
} else if (rating <= 60) {
return 3;
} else if (rating <= 80) {
return 4;
} else {
return 5;
}
}
const value = track[getTrackField()];
if (value == null) {
return value;
}
switch (field) {
case def.NumericFilterField.Rating:
return convertRating(value as number);
default:
return value;
}
}
</script>

0 comments on commit 9f17889

Please sign in to comment.