Commit 82e67fe
Update Admin > Statistics views data fetching and error handling (#9416)
I updated the Admin > Statistics views slightly:
- unified data fetching with `useQuery`
- unified error handling for fetching with a new hook
`useQueryWithErrorHandling`
- fixed several code smells:
##### `time_tracking_overview.tsx`:
- Bug: filteredTimeEntries?.length === null is always false (array
length is never null)
→ fixed to filteredTimeEntries.length === 0
- Typo: setEndeDate → setEndDate
- Race condition: both useFetch calls shared the same isFetching state —
one could clear
it while the other was still loading. Now each query has its own
isLoading/isFetching
flag, combined as const isFetching = isTeamsLoading || isEntriesFetching
##### `time_tracking_detail_view.tsx`:
- Missing key prop: project header <Row> in taskRows had no key → added
key={project}
- Missing key on fragments: the <> {row} <Divider/> </> wrapper in the
map had no key →
replaced with <Fragment key={index}>
- Destructured props at component signature instead of accessing via
props.x
##### `project_and_annotation_type_dropdown.tsx`:
- let allOptions = [...] → const allOptions (it's only mutated via
.push(), never
reassigned)
- useState(Array<string>) → useState<string[]>([]) (the former uses
Array as a lazy
initializer function — valid but highly unusual and non-obvious)
### URL of deployed dev instance (used for testing):
- https://___.webknossos.xyz
### Steps to test:
- abc
### Issues:
- fixes #
------
(Please delete unneeded items, merge only when none are left open)
- [ ] Added changelog entry (create a `$PR_NUMBER.md` file in
`unreleased_changes` or use `./tools/create-changelog-entry.py`)
- [ ] Added migration guide entry if applicable (edit the same file as
for the changelog)
- [ ] Updated [documentation](../blob/master/docs) if applicable
- [ ] Adapted [wk-libs python
client](https://github.com/scalableminds/webknossos-libs/tree/master/webknossos/webknossos/client)
if relevant API parts change
- [ ] Removed dev-only changes like prints and application.conf edits
- [ ] Considered [common edge
cases](../blob/master/.github/common_edge_cases.md)
- [ ] Needs datastore update after deployment
---------
Co-authored-by: Philipp Otto <philippotto@users.noreply.github.com>1 parent 6a7f8f1 commit 82e67fe
File tree
6 files changed
+295
-297
lines changed- frontend/javascripts
- admin/statistic
- libs
6 files changed
+295
-297
lines changedLines changed: 9 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
| 19 | + | |
21 | 20 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
37 | 26 | | |
38 | 27 | | |
39 | 28 | | |
| |||
47 | 36 | | |
48 | 37 | | |
49 | 38 | | |
50 | | - | |
| 39 | + | |
51 | 40 | | |
52 | 41 | | |
53 | 42 | | |
| |||
Lines changed: 12 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
58 | | - | |
| 57 | + | |
59 | 58 | | |
60 | 59 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
69 | 66 | | |
70 | 67 | | |
71 | 68 | | |
| |||
84 | 81 | | |
85 | 82 | | |
86 | 83 | | |
87 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
0 commit comments