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

Implement contribution graph #2615

Merged
merged 14 commits into from
Aug 29, 2022
Merged

Conversation

mathjazz
Copy link
Collaborator

@mathjazz mathjazz commented Aug 26, 2022

This patch partially fixes #2487. It implements the contribution graph, with the ability to display different contribution types (translations, reviews, both, peer reviews, etc.),

I still need to add a unit test for the utils function and optimize the request to render all contributions.

The missing piece is the timeline that renders under the graph on page load and updates after selecting a day on the graph.

Fix tooltip plurals
Modernize date display
Replace formatString with Template literals
Simplify input data conversion into an object
Various simplifications of the contributor graph lib
More simplification
Simplify date handling
Less configuration
Remove header
Move chart code to profile.js
No need for data reformatting
Remove underscores
@mathjazz
Copy link
Collaborator Author

@mathjazz mathjazz requested a review from eemeli August 26, 2022 13:48
<div class="menu" style="display: none;">
<ul>
<li class="clearfix">
<span data-type="user_translations" title="Translations submitted by the user">User translations</span>
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are not the categories in the specs? I believe those are clearer.

Copy link
Collaborator Author

@mathjazz mathjazz Aug 26, 2022

Choose a reason for hiding this comment

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

I changed them, because the ones in the spec weren't clear to me. :-)

E.g. We don't use the term "Submissions", "performed" and "received" sound unusual when used together with Review and "Submissions and reviews" isn't clear about excluding reviews of user's translations.

I tried to make thing clearer in the tooltip, but I understand that's not very visible. Maybe we should show the tooltip text underneath the chart for the selected option?

Copy link
Collaborator

Choose a reason for hiding this comment

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

  • The concept of "peer" doesn't exist anywhere. Funny enough, it's almost never a peer who reviews your work.
  • "User review" doesn't say much: are those done by the user, or received by the user.

Submissions was used to make it clear that's something entered by the user, and translation can't be used.

Since this went through review internally and externally, I'd stick to the specs. If those turn out to be unclear in everyday use, changing them should be very quick.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since this went through review internally and externally, I'd stick to the specs. If those turn out to be unclear in everyday use, changing them should be very quick.

Fair point. Updated the wording.

pontoon/contributors/static/js/profile.js Outdated Show resolved Hide resolved
Copy link
Member

@eemeli eemeli left a comment

Choose a reason for hiding this comment

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

A few small-ish changes. If using Fluent for our own localisation would be too hard, then we ought to fix that separately.

Comment on lines 147 to 151
const graph = $('#contribution-graph');
const contributions = graph.data('contributions');

// Set start date to 365 days before now
var startDate = new Date();
Copy link
Member

Choose a reason for hiding this comment

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

Mixing const and var like this is weird. Just make them all const and let, as appropriate.

pontoon/contributors/static/js/profile.js Outdated Show resolved Hide resolved
gx = week * step;
}

startDate.setUTCDate(startDate.getUTCDate() + 1);
Copy link
Member

Choose a reason for hiding this comment

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

This should not be called startDate if/as it's being used as an iterator.

pontoon/contributors/static/js/profile.js Outdated Show resolved Hide resolved
Comment on lines 250 to 253
var count = $(e.target).attr('data-count');
var date = shortDateFormat.format($(e.target).attr('data-date'));
var action = count == 1 ? 'contribution' : 'contributions';
var text = `${count} ${action} on ${date}`;
Copy link
Member

Choose a reason for hiding this comment

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

Alas, if only we had a localization system that could handle this sort of stuff. 😇

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

:-)

We don't use it outside the translate app, yet.

total = sum(contributions.values())

return {
"contributions": json.dumps(contributions),
Copy link
Member

Choose a reason for hiding this comment

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

Why does this need to get double-encoded like this? If there is a need for this, some code comment here explaining the situation would be a really good idea.

mathjazz and others added 7 commits August 26, 2022 20:25
Co-authored-by: Eemeli Aro <eemeli@gmail.com>
Co-authored-by: Eemeli Aro <eemeli@gmail.com>
- startDate -> currentDate
- usingMonth -> currentMonth
- monthInDay -> monthOfTheDay
@mathjazz mathjazz requested a review from eemeli August 27, 2022 06:23
Copy link
Collaborator

@flodolo flodolo left a comment

Choose a reason for hiding this comment

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

I'm not convinced of using uppercase in the dropdown above the graph, but the rest looks good to me.

Copy link
Member

@eemeli eemeli left a comment

Choose a reason for hiding this comment

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

I've added a commit with a proposed change that would allow contributor data to not get double-encoded when passed through the GET /update-contribution-graph REST endpoint.

@mathjazz I hope that's ok with you? This seemed like the easiest way for me to explain what I think should be done here.

@mathjazz
Copy link
Collaborator Author

I've added a commit with a proposed change that would allow contributor data to not get double-encoded when passed through the GET /update-contribution-graph REST endpoint.

@mathjazz I hope that's ok with you? This seemed like the easiest way for me to explain what I think should be done here.

Ohhhh, now I see what you meant with double-encoding. Thanks for the fix!

I'm refactoring the outputs of the utils functions in the 2nd half of #2487, but I'll take that commit and update there.

@mathjazz
Copy link
Collaborator Author

mathjazz commented Aug 29, 2022

I'm not convinced of using uppercase in the dropdown above the graph, but the rest looks good to me.

That's consistent with the rest of the app. There are a few other things to improve in Pontoon dropdowns (e.g. some lack and arrow and hence don't look like dropdowns, some don't work well with long texts, etc.), so let's address this afterwards.

@mathjazz mathjazz merged commit 69e7b06 into mozilla:master Aug 29, 2022
@mathjazz mathjazz deleted the 2487-contributor-graph branch August 29, 2022 19:42
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.

Implement contribution graph
3 participants