-
Notifications
You must be signed in to change notification settings - Fork 479
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
Restore Auto project counter #26807
Conversation
…ty hash then use delete if
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'], |
There was a problem hiding this comment.
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
lib/cdo/properties.rb
Outdated
# 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. |
There was a problem hiding this comment.
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.
…vert-26702-auto-project-counter
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:
This is on the projects page - both the index page and the public page.