Skip to content
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

Dashboard stats via RTK Query. (PP-1418) #122

Merged
merged 5 commits into from
Jul 30, 2024
Merged

Conversation

tdilauro
Copy link
Contributor

@tdilauro tdilauro commented Jul 28, 2024

Description

  • Move fetch handling for dashboard statistics out of Redux actions/reducers and into RTK Query, using hooks and caching.
  • Move some tests over to jest.

Motivation and Context

  • Move to modern Redux approach.
  • Reduce server load with caching.

[Jira PP-1418]

How Has This Been Tested?

Checklist:

  • N/A - I have updated the documentation accordingly.
  • All new and existing tests passed.

@tdilauro tdilauro requested a review from ray-lee July 28, 2024 13:03
Copy link
Contributor

@ray-lee ray-lee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. It's great how much code you were able to remove. Just one (non-blocking) question.

* Otherwise, statistics for all authorized libraries will be displayed.
* @param {StatsProps} props
* @param {string} props.library - key (short name) of a library.
* */
export const Stats = (props: StatsProps) => {
const { library: targetLibraryKey } = props;
const { data: statisticsData, fetchError, isLoaded } = useStatistics();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, isLoaded was a misleading name. Glad that's fixed.

src/hooks.ts Outdated
import { AppDispatch, RootState } from "./store";

export const useAppDispatch = () => useDispatch<AppDispatch>();
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these get used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I accidentally included an untracked file.

@tdilauro tdilauro merged commit 25378bb into main Jul 30, 2024
1 check passed
@tdilauro tdilauro deleted the chore/stats-in-rtkquery branch July 30, 2024 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants