-
Notifications
You must be signed in to change notification settings - Fork 47
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 repo usage report #112
Conversation
docs/repos-activity.html
Outdated
</div> | ||
<div class="info-box"> | ||
<p> | ||
Repositories are counted as <em>active</em> if they received at |
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.
Can you put this on one line?
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 like this report, that’s an interesting metric. Some minor remarks below 😄.
subnavigation: | ||
- title: "Feature Usage" |
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.
Good title for reports of this kind (no irony intended)!
updater/reports/ReportRepoUsage.py
Outdated
query = ''' | ||
SELECT | ||
"''' + str(oneDayAgo) + '''" AS date, | ||
ROUND(100*COUNT(DISTINCT(protect.repository_id))/COUNT(DISTINCT(active.repository_id))) |
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.
Can you put spaces around the arithmetic operators for consistency?
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.
Also, isn’t a float conversion desirable here to avoid an integer division?
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.
For the record, MySQL seems to perform a float division with /
in all cases, while integer divisions require the DIV
keyword. That’s strange, because other SQL implementations handle this differently as it seems …
updater/reports/ReportRepoUsage.py
Outdated
"''' + str(oneDayAgo) + '''" AS date, | ||
ROUND(100*COUNT(DISTINCT(protect.repository_id))/COUNT(DISTINCT(active.repository_id))) | ||
AS "protected branches [%]", | ||
ROUND(100*COUNT(DISTINCT(topics.repository_id))/COUNT(DISTINCT(active.repository_id))) |
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.
See above ☝️.
updater/reports/ReportRepoUsage.py
Outdated
( | ||
SELECT | ||
repositories.id AS repository_id, | ||
ref |
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.
Could you write repositories.ref
(if that’s the right one)? I had trouble seeing where ref
comes from.
f7ba847
to
53fb84e
Compare
updater/reports/ReportRepoUsage.py
Outdated
LEFT JOIN ( | ||
SELECT repository_id, name | ||
FROM protected_branches | ||
) AS protect ON active.repository_id = protect.repository_id AND active.ref = "refs/heads/" + protect.name |
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’d abbreviate “protected Branches” as protected
instead of protect
, but that’s not really an issue.
53fb84e
to
4c188c5
Compare
Align query for active repos and add a comment to keep them aligned. In the future we might want to refactor the "active repo" code into a reusable function. Although the updated query excludes entities, I don't expect the data to change in any significant way as there is usually no activity on the excluded entities anyways.
Calculate percentage of active repositories over the last four weeks in organizations that have received pushes to at least one protected branch and that have at least one topic assigned to them.
4c188c5
to
710bc7f
Compare
Calculate percentage of active repositories over the last four weeks
in organizations that have received pushes to at least one protected
branch and that have at least one topic assigned to them.
This way we can track if people use protected branches and topics!
Please review by commit. 1-3 are preparation, 4 is the beef 😄