-
Notifications
You must be signed in to change notification settings - Fork 15
Add live data to project summary #1296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
d18aea8
feat: setup endpoint for top identifiers
annavik 4ba75dd
feat: add overview section to project summary with top identifiers
annavik 8dbf006
feat: add top taxa to overview section
annavik f450128
feat: add latest occurrences to overview section
annavik b9a2c3e
feat: handle loading, error and empty states
annavik f42c462
layout: adjust layout for small screens
annavik f39ea6c
fix: replace hard coded strings
annavik fe1862e
feat: add links to occurrences and taxa
annavik 2a3a997
Merge branch 'main' into feat/project-overview
annavik 0f9f1c0
fix: cleanup
annavik 8494ad3
fix(project-overview): address PR review feedback
mihow 7758499
fix(api): gate top-identifiers endpoint on project visibility
mihow b671d69
fix(api): count distinct occurrences in top-identifiers leaderboard
mihow 253d5dc
refactor(summary): extract SummaryColumn to dedupe overview columns
mihow 86d2f90
docs: plan for /occurrences/stats/ endpoint convention + top-identifi…
mihow 5d20619
docs: lock decisions on /occurrences/stats/ pattern after 2nd review
mihow ba00cdd
docs: snapshot Anna's PR #1296 body before adding Claude commits
mihow c83ebae
refactor(stats): extract top_identifiers query into models_future
mihow a50abd3
feat(stats): add /occurrences/stats/top-identifiers/ endpoint
mihow 1a176c3
refactor(stats): flip FE to /occurrences/stats/, delete legacy backend
mihow de2ddc5
docs(api): convention reference for /<entity>/stats/<kind>/ endpoints
mihow d649c1f
Merge remote-tracking branch 'origin/main' into worktree-project-over…
mihow e4a0d29
docs(api): expand future-stats examples (deployments, agreement, spec…
mihow 4c9acd5
refactor(stats): use paginator + add scalar-shape placeholder
mihow fbf4382
refactor(stats): simplify to scalar shape, defer paginator pattern
mihow 7209708
chore(api_router): collapse stats-route ordering comment to one line
mihow 1da2943
chore(docs): archive PR #1296 stats migration plan [no ci]
mihow db0157a
ci: trigger checks on current head
mihow 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
Some comments aren't visible on the classic Files Changed page.
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
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
29 changes: 29 additions & 0 deletions
29
ui/src/data-services/hooks/identifications/useTopIdentifiers.ts
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,29 @@ | ||
| import { API_ROUTES, API_URL } from 'data-services/constants' | ||
| import { useAuthorizedQuery } from '../auth/useAuthorizedQuery' | ||
|
|
||
| interface Response { | ||
| project_id?: number | ||
| top_identifiers: { | ||
| id: number | ||
| name?: string | ||
| email: string | ||
| image?: string | ||
| identification_count: number | ||
| }[] | ||
| } | ||
|
|
||
| export const useTopIdentifiers = (projectId?: string) => { | ||
| const url = `${API_URL}/${API_ROUTES.USERS}/${API_ROUTES.IDENTIFICATIONS}/top/` | ||
|
|
||
| const { data, isLoading, isFetching, error } = useAuthorizedQuery<Response>({ | ||
| queryKey: [API_ROUTES.IDENTIFICATIONS, 'top', projectId], | ||
| url: projectId ? `${url}?project_id=${projectId}` : url, | ||
| }) | ||
|
|
||
| return { | ||
| data, | ||
| isLoading, | ||
| isFetching, | ||
| error, | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
ui/src/data-services/hooks/occurrences/useLatestOccurrences.ts
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,11 @@ | ||
| import { useOccurrences } from './useOccurrences' | ||
|
|
||
| export const useLatestOccurrences = (projectId: string) => { | ||
| const result = useOccurrences({ | ||
| pagination: { page: 0, perPage: 5 }, | ||
| projectId, | ||
| sort: { field: 'first_appearance_timestamp', order: 'desc' }, | ||
| }) | ||
|
|
||
| return result | ||
| } |
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,11 @@ | ||
| import { useSpecies } from './useSpecies' | ||
|
|
||
| export const useTopSpecies = (projectId: string) => { | ||
| const result = useSpecies({ | ||
| pagination: { page: 0, perPage: 5 }, | ||
| projectId, | ||
| sort: { field: 'occurrences_count', order: 'desc' }, | ||
| }) | ||
|
|
||
| return result | ||
| } |
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,46 @@ | ||
| import { ImageIcon, UserIcon } from 'lucide-react' | ||
|
|
||
| export const ListItem = ({ | ||
| count, | ||
| item, | ||
| }: { | ||
| count?: number | string | ||
| item: { | ||
| image: { src?: string; variant?: 'default' | 'user' } | ||
| text: string | ||
| title?: string | ||
| } | ||
| }) => ( | ||
| <div className="flex items-center gap-4 p-2 pr-4"> | ||
| {item.image.variant === 'user' ? ( | ||
| <UserImage image={item.image.src} /> | ||
| ) : ( | ||
| <Image image={item.image.src} /> | ||
| )} | ||
| <div className="flex flex-col overflow-hidden"> | ||
| <div className="flex items-center gap-4"> | ||
| {item.title ? ( | ||
| <span className="truncate font-medium">{item.title}</span> | ||
| ) : null} | ||
| </div> | ||
| <span className="truncate">{item.text}</span> | ||
| </div> | ||
| {count !== undefined ? ( | ||
| <span className="body-small grow text-right"> | ||
| {count.toLocaleString()} | ||
| </span> | ||
| ) : null} | ||
| </div> | ||
| ) | ||
|
|
||
| const Image = ({ image }: { image?: string }) => ( | ||
| <div className="shrink-0 flex items-center justify-center w-12 h-12 border border-border rounded-md text-muted-foreground overflow-hidden"> | ||
| {image ? <img alt="" src={image} /> : <ImageIcon className="w-4 h-4" />} | ||
| </div> | ||
| ) | ||
|
|
||
| const UserImage = ({ image }: { image?: string }) => ( | ||
| <div className="shrink-0 flex items-center justify-center w-12 h-12 border border-border rounded-full text-muted-foreground overflow-hidden"> | ||
| {image ? <img alt="" src={image} /> : <UserIcon className="w-4 h-4" />} | ||
| </div> | ||
| ) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
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.