Skip to content

Chart: repository history #27

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

Merged
merged 6 commits into from
Oct 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/_data/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
url: "/pr-usage"
- title: "Total"
url: "/pr-total"
- title: "Repositories"
url: "/repositories-total"
- title: "Housekeeping"
url: "/housekeeping-git-traffic"
subnavigation:
Expand Down
86 changes: 86 additions & 0 deletions docs/demo-data/repository-history.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
date total in organizations in user spaces
2017-08-01 7480 2991 4489
2017-08-02 7743 3038 4705
2017-08-03 7434 3065 4369
2017-08-04 7693 3080 4613
2017-08-05 7530 3092 4438
2017-08-06 7758 3170 4588
2017-08-07 8077 3245 4832
2017-08-08 8005 3217 4788
2017-08-09 7968 3217 4751
2017-08-10 8059 3294 4765
2017-08-11 8300 3332 4968
2017-08-12 8441 3429 5012
2017-08-13 8491 3339 5152
2017-08-14 8694 3331 5363
2017-08-15 8386 3447 4939
2017-08-16 9007 3539 5468
2017-08-17 8609 3558 5051
2017-08-18 9150 3610 5540
2017-08-19 8931 3550 5381
2017-08-20 9163 3533 5630
2017-08-21 8869 3581 5288
2017-08-22 9028 3634 5394
2017-08-23 9470 3828 5642
2017-08-24 9537 3693 5844
2017-08-25 9574 3765 5809
2017-08-26 9608 3811 5797
2017-08-27 9783 3868 5915
2017-08-28 9677 3953 5724
2017-08-29 9946 4056 5890
2017-08-30 9993 3945 6048
2017-08-31 10349 4108 6241
2017-09-01 10175 4082 6093
2017-09-02 10488 4172 6316
2017-09-03 10386 4222 6164
2017-09-04 10703 4298 6405
2017-09-05 10718 4279 6439
2017-09-06 10561 4237 6324
2017-09-07 10876 4423 6453
2017-09-08 10719 4309 6410
2017-09-09 10946 4469 6477
2017-09-10 11044 4464 6580
2017-09-11 11105 4515 6590
2017-09-12 11586 4597 6989
2017-09-13 11612 4618 6994
2017-09-14 11533 4619 6914
2017-09-15 11707 4617 7090
2017-09-16 11619 4735 6884
2017-09-17 12092 4787 7305
2017-09-18 12000 4854 7146
2017-09-19 12132 4856 7276
2017-09-20 12173 4897 7276
2017-09-21 12298 5049 7249
2017-09-22 12756 5022 7734
2017-09-23 12566 5107 7459
2017-09-24 12504 5050 7454
2017-09-25 12900 5190 7710
2017-09-26 13123 5313 7810
2017-09-27 13078 5307 7771
2017-09-28 13439 5316 8123
2017-09-29 13414 5434 7980
2017-09-30 13688 5453 8235
2017-10-01 13745 5435 8310
2017-10-02 13879 5522 8357
2017-10-03 13909 5668 8241
2017-10-04 13948 5593 8355
2017-10-05 14418 5703 8715
2017-10-06 14590 5760 8830
2017-10-07 14754 5851 8903
2017-10-08 14846 5848 8998
2017-10-09 14704 5980 8724
2017-10-10 15171 6100 9071
2017-10-11 15062 6104 8958
2017-10-12 15339 6228 9111
2017-10-13 15499 6199 9300
2017-10-14 15880 6288 9592
2017-10-15 15800 6333 9467
2017-10-16 15844 6298 9546
2017-10-17 16086 6537 9549
2017-10-18 16336 6526 9810
2017-10-19 16506 6639 9867
2017-10-20 16634 6667 9967
2017-10-21 16955 6710 10245
2017-10-22 16985 6848 10137
2017-10-23 16981 6785 10196
2017-10-24 17216 6920 10296
26 changes: 26 additions & 0 deletions docs/repositories-total.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
layout: default
title: Repositories
permalink: /repositories-total
---

<h3>Repositories (Total)</h3>

<div class="row">
<div class="col-main">
<div class="chart-container">
<canvas
class="chart"
data-url="{{ site.dataURL }}/repository-history.tsv"
data-type="history"'
></canvas>
</div>
</div>
<div class="col-aside">
<div class="info-box">
<p>
The number of repositories in total, in organizations, and in user accounts.
</p>
</div>
</div>
</div>
48 changes: 48 additions & 0 deletions updater/reports/ReportRepositoryHistory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from .ReportDaily import *

# Lists the total number of repositories
class ReportRepositoryHistory(ReportDaily):
Copy link
Collaborator

@larsxschneider larsxschneider Oct 29, 2017

Choose a reason for hiding this comment

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

minor nit: I would prefer to use "Repo" in the code instead of "Repository" to improve code readability 😄
Otherwise all variable names and filenames will become really long for no good reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I get your point. Personally, I don’t like using abbreviations at all, as I have encountered so many cases where abbreviations introduced unnecessary ambiguities.

For instance, I had to work on a piece of code that had classes suffixed Impl, which—surprise—didn’t stand for ”implementation” but “implication,” causing a major misunderstanding of the code.

Well, while ”repo” might not be misunderstood as something else, I made a practice of not abbreviating anything for no good reason. “PR” is an example that my intuition tells me could be misunderstood, as I’d immediately interpret it as “public relations” before thinking about “pull requests.”

However, it might be more important not to discuss this for too long (as I did with this comment, shame on me) but to keep things consistent within the code base (which isn’t the case right now). So maybe, we should clean up all the files at some point after making a uniform decision on how to name things (for instance, according to GitHub’s MySQL schemes or the GitHub API).

Copy link
Collaborator

Choose a reason for hiding this comment

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

In general I concur (I love this post). However, Org, Repo, and PR in the context of GitHub are pretty clear from my point of view.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the record: @larsxschneider and I agreed to consistently name entities as done be the GitHub API in the future 😃.

There, pull requests are abbreviated pulls, repositories are repos, and organizations are orgs, for instance.

We’ll try to make this consistent soon!

def name(self):
return "repository-history"

def updateDailyData(self):
newHeader, newData = self.parseData(
self.executeQuery(self.query())
)
self.header = newHeader if newHeader else self.header
self.data.extend(newData)
self.truncateData(self.timeRangeTotal())
self.sortDataByDate()

# Collects the number of active repositories for a user type (user/organization) given a time range
def subquery(self, userType):
query = '''
SELECT
COUNT(*) AS count
FROM
repositories
JOIN users ON repositories.owner_id = users.id
WHERE
TRUE ''' + self.andExcludedEntities("users", "repositories")

if userType != None:
query += ''' AND
users.type = "''' + userType + '''"'''

return query

# Collects the number of repositories in total, in organizations, and in user accounts
def query(self):
query = '''
SELECT
"''' + str(self.yesterday()) + '''" AS date,
total.count AS total,
organizationSpace.count AS "in organizations",
userSpace.count AS "in user accounts"
FROM
(''' + self.subquery(None) + ''') AS total,
(''' + self.subquery("Organization") + ''') AS organizationSpace,
(''' + self.subquery("User") + ''') AS userSpace
'''

return query
2 changes: 2 additions & 0 deletions updater/update-stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from reports.ReportPRByRepo import *
from reports.ReportPRHistory import *
from reports.ReportPRUsage import *
from reports.ReportRepositoryHistory import *
from reports.ReportTokenlessAuth import *
from reports.ReportUsers import *

Expand Down Expand Up @@ -78,6 +79,7 @@ def main():
ReportPRByRepo(configuration, dataDirectory, metaStats).update()
ReportPRHistory(configuration, dataDirectory, metaStats).update()
ReportPRUsage(configuration, dataDirectory, metaStats).update()
ReportRepositoryHistory(configuration, dataDirectory, metaStats).update()
ReportTokenlessAuth(configuration, dataDirectory, metaStats).update()
ReportUsers(configuration, dataDirectory, metaStats).update()

Expand Down