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

FW-4520 Use Stats API #201

Merged
merged 7 commits into from
Nov 22, 2023
Merged

FW-4520 Use Stats API #201

merged 7 commits into from
Nov 22, 2023

Conversation

bronson-c
Copy link
Collaborator

@bronson-c bronson-c commented Nov 21, 2023

Description of Changes

This PR re-enables the stats widget and connect it to the new stats API in the Django BE.

Checklist

  • README / documentation has been updated if needed
  • PR title / commit messages contain Jira ticket number if applicable
  • Tests have been updated / created if applicable

Reviewers Should Do The Following:

  • Review the changes here
  • Pull the branch and test locally

Additional Notes

N/A

import api from 'services/api'
import { useParams } from 'react-router-dom'

export function useStats() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The logic for how the stats widget displays the data from the stats API has been moved here rather than WidgetStatsData.js

const weekTotal = getPeriodTotal('last7Days')
const monthTotal = getPeriodTotal('lastMonth')

if (weekTotal > 4) {
Copy link
Collaborator Author

@bronson-c bronson-c Nov 21, 2023

Choose a reason for hiding this comment

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

The stats widget should work the same as when the data was being provided by Nuxeo, however I have been unable to trigger the widget into displaying "new this week", "new this month" and "on this site" are working correctly though. @gmcauliffe I am not sure if this is how the widget behaved before the endpoint change

Copy link
Contributor

Choose a reason for hiding this comment

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

The API returns "lastWeek" not "last7Days"... does this time period string need to match?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That was it! The display is now fixed, thank you!

@bronson-c bronson-c marked this pull request as ready for review November 21, 2023 19:35
Copy link
Contributor

@gmcauliffe gmcauliffe left a comment

Choose a reason for hiding this comment

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

LGTM! Just one small import change and you're good to merge :)

// FPCC
import { useSiteStore } from 'context/SiteContext'
import api from 'services/api'
import { useStats } from '../../common/dataHooks/useStats'
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid using relative imports. You can leverage our Webpack aliases here and change this to 'common/dataHooks/useStats'

Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@bronson-c bronson-c merged commit 3474607 into main Nov 22, 2023
4 checks passed
@bronson-c bronson-c deleted the FW-4520-use-stats-api branch November 22, 2023 19:03
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.

3 participants