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

Add election name to IEC contribution list #466

Merged
merged 3 commits into from
Dec 14, 2023
Merged

Conversation

mikeubell
Copy link
Contributor

This work resolves #435
Since Independent committees can raise money in one election and spend it in another, we are leaving all contributions to a committee in the list but sorting it so that the most recent election's contributions appear first. This is true even when sorting is specified on a different columng

Previews

Screen Shot 2023-12-01 at 2 54 11 PM

Screen Shot 2023-12-01 at 2 54 26 PM

@mikeubell mikeubell requested a review from ckingbailey December 1, 2023 23:33
Copy link
Contributor

@ckingbailey ckingbailey left a comment

Choose a reason for hiding this comment

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

Mostly seems fine. I think the election.name comparison bit is not working like you intended it to. Other than that, one or two code style comments, and a (maybe) warning about allowing JS to (maybe) handle strings as numbers. I had forgotten just how loosey-goosey JS is. I kind of hate it and I love it in equal measure.

src/components/contributions-table.jsx Outdated Show resolved Hide resolved
src/components/contributions-table.jsx Show resolved Hide resolved
const election1 = parseElectionName(x);
const election2 = parseElectionName(y);

if (election1.name > election2.name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused how this is working. It looks to me like parseElectionName returns an object with a property ename, rather than name. Is it possible these cases are never hit because it's always comparing undefined to undefined?
What's the desired behavior here, that elections would sort alphabetically by locale?

return -1;
}

if (election1.year > election2.year) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is comparing strings. Not sure if there's any "gotchas" with > & < comparing strings in JS. Could be fine, I don't know. Just wanted to point it out in case you'd be concerned.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually it occurs to me that we do not need to (or maybe should not) sort on name. The names will be all the same. I don't think that a IEC will report collections in two different jurisdictions, but if they did then we would want the order to be on the date, regardless of the jurisdiction.

src/components/contributions-table.jsx Show resolved Hide resolved
Copy link
Contributor

@ckingbailey ckingbailey left a comment

Choose a reason for hiding this comment

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

One thing I forgot to mention in earlier review: I am running into this error with Node 18. SO answers suggests downgrading to Node 16.13.1 (which I did not try) or passing the option --openssl-legacy-provider in NODE_OPTIONS env var, which did work for me. We should either downgrade or set that env var on the npm command that runs Webpack, if possible.

@mikeubell
Copy link
Contributor Author

@ckingbailey I believe I have addressed all you concerns.

@ckingbailey
Copy link
Contributor

@mikeubell what do you want to do about the Node 18 issue?

@mikeubell
Copy link
Contributor Author

mikeubell commented Dec 13, 2023

I don’t feel qualified to know what the right call is. I see that this commit makes that change. I think its best to to stay as current as possible with the tools as it becomes harder to keep things running as they get older. I guess passing the flag would be the thing to do.

@mikeubell mikeubell merged commit 58cfc5f into master Dec 14, 2023
1 check passed
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.

Handle contributions for committees that span elections
2 participants