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

Client report graphs #18

Merged
merged 8 commits into from
Oct 21, 2024
Merged

Client report graphs #18

merged 8 commits into from
Oct 21, 2024

Conversation

thomassth
Copy link
Contributor

  • Fixed beeswarm graph
  • Added participants graph

@patcon
Copy link
Member

patcon commented Oct 20, 2024

Thanks @thomassth! Still reviewing, but first thought was that there's already some test data and helper functions in .storybook/utils.js that other stories are using. Could we stick with using those functions, and add more if any from your testData file are missing?

See: https://github.com/CivicTechTO/polis-storybook/blob/main/.storybook/utils.js
and

import { getMath, getComments } from '../../../.storybook/utils'
const mathResults = getMath()
const commentsData = getComments()
commentsData.sort((a,b) => a.tid - b.tid)

Also, I spawned #19, because added more data sources is a really nice idea, and lets us actually start using storybook to look at past snapshots of data using the visualizations hosted here (which is its own killer feature)

@patcon
Copy link
Member

patcon commented Oct 20, 2024

Maybe in scope of this PR, you could version control your new data files alongside the originals? (for now, if we could stick with the current sample data, as I'm pretty sure some stories would break if other data was swapped in, and generalizing them seems out-of-scope for this issue. But if you added the data to the repo, viewing it for now would be as simple as changing the conversation_id in the imports when working locally)

import participationData from './data/3ntrtcehas-participation-init.json'
import commentsData from './data/3ntrtcehas-comments.json'

So versioning in your data into these files:

.storybook/data/5esrbenwxs-participation-init.json
.storybook/data/5esrbenwxs-comments.json

(participation init endpoint is a composite of enough data to init the visualization on first load, and is at: https://pol.is/api/v3/participationInit?conversation_id=5esrbenwxs )

@patcon
Copy link
Member

patcon commented Oct 20, 2024

Lemme know what you think! Thanks again 🙌

@patcon
Copy link
Member

patcon commented Oct 20, 2024

And unless there's a reason to change the submodule, would love to keep it pointed to the "storybook-prep" branch, which is a bare minimal changeset from upstream, just to get storybook working

If we're diverging too much, then we'll just add a new submodule in codebases/civictechto and create alternative stories for our components that differ from upstream. Right now, the stories/compdem/* is for things building on their base codebase

@thomassth
Copy link
Contributor Author

I've looked through the storybook-prep branch, I believe many of the changes should be merged too! It's beneficial to keep the code style updated & prep for future, bigger package upgrades.

@thomassth
Copy link
Contributor Author

I have removed the excess test data for now; we can think about adding them in other commits.

@patcon
Copy link
Member

patcon commented Oct 21, 2024

Hm, I'm not getting it building properly in storybook on local -- same for CI:
https://civictechto.github.io/polis-storybook/PR-18/

Found the build error line (it doesn't fail out, and maybe that's something to improve in the build process):
https://github.com/CivicTechTO/polis-storybook/actions/runs/11433350904/job/31805190108?pr=18#step:3:1025

Did you have it working locally? Anything that maybe didn't get committed?

I'll update if I sort it out myself :) Thanks @thomassth 🙌 🙌

@patcon
Copy link
Member

patcon commented Oct 21, 2024

K, gonna merge in mainline, where I've added a fix for ensuring failures show in CI when they happen in the build :)
#22

@patcon
Copy link
Member

patcon commented Oct 21, 2024

K, failure confirmed, and now I think I've got a fix. Needed to add some more packages to the storybook environment, and make sure they get added as a d3 global

@patcon patcon marked this pull request as draft October 21, 2024 20:02
@patcon
Copy link
Member

patcon commented Oct 21, 2024

k yay!

ParticipantsGraph working now 🎉 https://civictechto.github.io/polis-storybook/PR-18/?path=/story/compdem-client-report-participantsgraph--default

Beeswarm still needs some work: We got beeswarm working too!
https://civictechto.github.io/polis-storybook/PR-18/?path=/story/compdem-client-report-beeswarm--default

Now that you've got us going in the right direction, I think I know the fixes for this :)

export const getComments = () => {
return commentsData
}

// Simulates response data from /api/v3/reports?report_id=r3bpnywujybyru4rkx92i
export const getReports = () => {
return reportsData
Copy link
Member

Choose a reason for hiding this comment

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

Aligned this with the response from actual API endpoint (an array)


const comments = getComments();

// Logic from client-report/src/components/app.js#L274-291
Copy link
Member

Choose a reason for hiding this comment

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

<3 THANK YOU SO MUCH. This was what I was missing 🙏 🙏 🙏 🙏

@patcon patcon marked this pull request as ready for review October 21, 2024 20:43
@thomassth
Copy link
Contributor Author

Ah that's why, I didn't know the storybook needed another round of imports

@patcon
Copy link
Member

patcon commented Oct 21, 2024

Hm, it's working locally, but I'm seeing errors in the deployed storybook -- trying to figure out what's up with that 🤔

Maybe related: storybookjs/storybook#21525

EDIT: Ok, feeling good that I've pushed the fix 🤞

@patcon
Copy link
Member

patcon commented Oct 21, 2024

Ok, they're both working in the deployed storybook. Merge away if it looks good to you!

Thanks for getting this in!

@thomassth thomassth merged commit 765c397 into main Oct 21, 2024
2 checks passed
@patcon patcon deleted the client-report-graphs branch October 22, 2024 11:51
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