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

Restore Auto project counter #26807

Conversation

dmcavoy
Copy link
Contributor

@dmcavoy dmcavoy commented Jan 30, 2019

Restores #26702 by reverting #26795 with updates to fetch metrics function

Updated these 4 places (see below) on the website to have the project count get automatically updated.
We check on Sunday to see if the project count is a million higher than the current count and update the number used for display if it is.

These are both on the homepage:
unnamed-1
unnamed

This is on the projects page - both the index page and the public page.
unnamed-2

@dmcavoy dmcavoy changed the title Revert "Revert "Revert "Revert "Auto project counter"""" Restore Auto project counter Jan 30, 2019
Properties.set :metrics, {
created_at: time,
created_on: time.to_date,
petition_signatures: petition_signatures,
lines_of_code: lines_of_code,
project_count: Properties.get(:metrics)['project_count'],
Copy link
Member

Choose a reason for hiding this comment

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

Just a comment for future readers that this will lead to project_count being set to nil when it was previously not recorded at all. We have seen this in our test environments, for example, which has led to the delete_if added at https://github.com/code-dot-org/code-dot-org/pull/26807/files#diff-cfda98acedc510b51ec32e23bfad5d69R65

# When getting metrics: If metrics were to be nil we use the empty hash as delete_if
# does not work on nil. Delete_if deals with any specific values that come back nil and removes them so
# the merge will use the default values instead of a nil value. All of this makes sure each value in the hash
# is not zero or nil.
Copy link
Member

@breville breville Jan 30, 2019

Choose a reason for hiding this comment

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

I would shorten the new comment to something like:

Note that project_count might be nil due to analyze_hoc_activity, and so we delete nil values prior to the merge, so that the merge doesn't overwrite our human-readable defaults with nil.

I'd also add a comment to analyze_hoc_activity with something like:

Note that project_count will be set to nil if it doesn't already exist.  See the comment in fetch_metrics in lib/cdo/properties.rb where we handle this case when generating fallback human-readable default values.

@dmcavoy dmcavoy merged commit 5e6ac9f into staging Jan 31, 2019
@dmcavoy dmcavoy deleted the revert-26795-revert-26769-revert-26764-revert-26702-auto-project-counter branch January 31, 2019 22:46
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.

None yet

3 participants