-
Notifications
You must be signed in to change notification settings - Fork 0
119 improve exploreplants based on feedback #120
Merged
+1,380
−562
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
aecc4e7
add number of results shown after a search in ExplorePlants
helenul 94f9767
add reusable Pagination component with numbered pages
helenul 487fdb5
make the ✿ button on Explore Plants a toggle
helenul 04b7dde
combine Explore Plants filters into a reusable FilterSelect component
helenul 7baba10
remove the cache warning when a match is removed
helenul 78a4795
add index for sorting plants by name
helenul ba53bf0
document Explore Plants changes and add results count tests
helenul a4cb5fb
run lint and prettier
helenul d902af7
move the sort menu into a reusable SortMenu component, add tests and …
helenul 65e0bf7
move the URL state from ExplorePlants into a useExploreParams hook, a…
helenul bae5638
rewrite AI usage example as refactoring after peer review
helenul 1611acf
move fonts into CSS variables
helenul 6d937b0
run prettier and remove a comment
helenul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import type { Db } from "mongodb"; | ||
|
|
||
| // The indexes the app needs. createIndex does nothing if the index already | ||
| // exists, so this is safe to run every time the server starts. | ||
| export async function ensureIndexes(database: Db) { | ||
| // Sorting by name (A–Z, the default, and Z–A) reads the plants in order from | ||
| // this index instead of sorting the whole collection in memory. _id is part | ||
| // of the sort as a tie-breaker, so it is part of the index too. | ||
| await database.collection("plants").createIndex({ commonName: 1, _id: 1 }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { MongoClient } from "mongodb"; | ||
| import { afterAll, expect, inject, it } from "vitest"; | ||
| import { ensureIndexes } from "../src/indexes.js"; | ||
|
|
||
| // Uses the in-memory MongoDB from globalSetup.ts, with its own database for this file | ||
| const client = await MongoClient.connect(inject("mongoUri")); | ||
| const db = client.db("indexes-test"); | ||
|
|
||
| afterAll(async () => { | ||
| await client.close(); | ||
| }); | ||
|
|
||
| it("creates the index for sorting by name, and can run again on the next start", async () => { | ||
| await ensureIndexes(db); | ||
| // The server runs this on every start, so running it twice must not fail | ||
| await ensureIndexes(db); | ||
|
|
||
| const indexes = await db.collection("plants").indexes(); | ||
| expect(indexes.map((index) => index.key)).toContainEqual({ | ||
| commonName: 1, | ||
| _id: 1, | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "extends": "../tsconfig.json", | ||
| "compilerOptions": { | ||
| "rootDir": "..", | ||
| "noEmit": true | ||
| }, | ||
| "include": ["../src", "."] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.