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

Create JSON files instead of CSV from Collectors #63

Merged
merged 14 commits into from
Nov 7, 2023
Merged

Conversation

ipc103
Copy link
Collaborator

@ipc103 ipc103 commented Nov 2, 2023

@ajhenry and I have been working on adding the data generated by the backed into the frontend application. To better integrate with the proposed frontend, this PR overhauls the Fetcher interface. Instead of having each Fetcher return a CSV string, we instead have the fetchers return structs or maps that hold data from their particular endpoint. The Collector then takes that data and generates a JSON file which can be consumed by the frontend application.

This also updates the next.js build action so that we generate the JSON files as part of the build step. Each time we re-deploy the app, we'll want the ability to re-populate the dataset.

There may be a world where we want to make the data-fetching optional (so that, for example, we could still deploy UI updates if the GitHub API was down), but we didn't worry too much about that for now.

Would love a thorough review on this since it's a relatively big change - definitely open to other suggestions or feedback.

ajhenry and others added 6 commits October 31, 2023 13:18
Instead of having each fetcher return a CSV string, this update allows
each fetcher to create it's own data files directly. This should make
things more open for extension in the future, because a fetcher doesn't
need to be tied to a specific return value. Instead, it can format files
directly however it likes (or append to multiple files if needed).

Co-authored-by: Andrew Henry <[email protected]>
When we build the next site, we can automatically include the static data
so that we don't need to check the data into the source code. This
updates the workflow to build the JSON file before the rest of the site
so it's included in the frontend build.

Co-authored-by: Andrew Henry <[email protected]>
Because the build step now includes the data files, we don't need a
separate action to do those. We can instead remove this and depend on
the nextjs workflow to automatically load the data it needs.

If we need CSV functionality, we can either 1) write an action/workflow
to download a CSV for you or 2) add a CSV download button to the UI.

Co-authored-by: Andrew Henry <[email protected]>
Allows us to set the organization name for fetching data via an environemnt
variable. Left a fallback in place so that this can be optional for now
during development.

Also removed the csv/json flag as we ended up not using that pattern.
@ipc103
Copy link
Collaborator Author

ipc103 commented Nov 2, 2023

Just tested this again after updating form main and got an error: Error: You do not have permission to view repository collaborators I think it has something to do with my PAT, but I'm going to convert this to draft while I investigate.

@ipc103 ipc103 marked this pull request as draft November 2, 2023 00:59
@ipc103 ipc103 marked this pull request as ready for review November 2, 2023 14:05
@ipc103
Copy link
Collaborator Author

ipc103 commented Nov 2, 2023

The issue I had was just with my PAT - this is ready for review!

Copy link
Contributor

@dmgardiner25 dmgardiner25 left a comment

Choose a reason for hiding this comment

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

Seems to be working well, just have a few comments

README.md Outdated Show resolved Hide resolved
who-metrics-ui/src/data/data.json Outdated Show resolved Hide resolved
@@ -2,10 +2,13 @@
const nextConfig = {
reactStrictMode: true,
productionBrowserSourceMaps: true,
basePath: '/sbv-world-health-org-metrics',
basePath:
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding this! Drove me crazy trying to figure out why I couldn't get the pages to load my first time spinning up the front end

backend/cmd/main.go Outdated Show resolved Hide resolved
ipc103 and others added 4 commits November 2, 2023 17:45
- Remove formatCSV functions, which are now unused
- Rename on instnace of `buildJSON` to `buildResult` for consistency

Co-authored-by: David Gardiner <[email protected]>
#66

contains the relevant information for adding this feature.
@ipc103 ipc103 requested a review from dmgardiner25 November 2, 2023 19:14
Copy link
Contributor

@dmgardiner25 dmgardiner25 left a comment

Choose a reason for hiding this comment

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

Thanks for making the updates!

@ipc103
Copy link
Collaborator Author

ipc103 commented Nov 7, 2023

Confirmed that the build was successful once updating the environment variables: https://github.com/sbv-world-health-org-metrics/sbv-world-health-org-metrics/actions/runs/6787581045 (the deploy failed because of a failed protection rule - interestingly the rule looks like deployments from any branch should be allowed 🤷).

I'm going to go ahead and merge and see if the deploy succeeds afterwards.

@ipc103 ipc103 merged commit 12d2ee8 into main Nov 7, 2023
5 of 7 checks passed
@ipc103 ipc103 deleted the ajhenry/overhaul branch November 7, 2023 16:47
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