Skip to content

Commit

Permalink
filter and sort fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cdleveille committed Oct 30, 2024
1 parent f462270 commit d901004
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions src/helpers/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ export const filterDiscsByQuery = (discs: TDisc[], query: TDiscQuery) => {
return discs.filter(disc => {
return (
(!id || disc.id === id) &&
(!name ||
(disc.name_slug.includes(name) &&
(!brand || disc.brand_slug.includes(brand)) &&
(!category || disc.category_slug.includes(category)) &&
(!stability || disc.stability_slug === stability.toLowerCase()) &&
(!speed || disc.speed === speed) &&
(!glide || disc.glide === glide) &&
(!turn || disc.turn === turn) &&
(!fade || disc.fade === fade)))
(!name || disc.name_slug.includes(name)) &&
(!brand || disc.brand_slug.includes(brand)) &&
(!category || disc.category_slug.includes(category)) &&
(!stability || disc.stability_slug === stability.toLowerCase()) &&
(!speed || disc.speed === speed) &&
(!glide || disc.glide === glide) &&
(!turn || disc.turn === turn) &&
(!fade || disc.fade === fade)
);
});
};
2 changes: 1 addition & 1 deletion src/models/disc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const getDiscsFromFile = async () => {
};

const writeDiscsToFile = async () => {
const discs = await DiscModel.find({}, projection);
const discs = await DiscModel.find({}, projection).sort({ name: 1 });
await Bun.write(DISCS_FILENAME, JSON.stringify(discs));
return discs;
};
Expand Down

0 comments on commit d901004

Please sign in to comment.