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

Chart: repository activity #28

Merged
merged 6 commits into from
Nov 16, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
### Features

- new chart: total number of repositories
- new chart: repository activity
- descriptive texts next to the charts
- support for GitHub Enterprise 2.11

Expand Down
7 changes: 6 additions & 1 deletion docs/_data/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
- title: "Total"
url: "/pr-total"
- title: "Repositories"
url: "/repositories-total"
url: "/repos-activity"
subnavigation:
- title: "Activity"
url: "/repos-activity"
- title: "Total"
url: "/repos-total"
- title: "Housekeeping"
url: "/housekeeping-git-traffic"
subnavigation:
Expand Down
93 changes: 93 additions & 0 deletions docs/demo-data/repository-activity.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
date total (last four weeks) total (last week) total (last day) in organizations (last four weeks) in organizations (last week) in organizations (last day) in user accounts (last four weeks) in user accounts (last week) in user accounts (last day)
2017-08-01 2560 2040 1469 932 755 540 1628 1285 929
2017-08-02 2567 2045 1542 936 761 602 1631 1284 940
2017-08-03 2579 2048 1441 938 758 508 1641 1290 933
2017-08-04 2587 2057 1507 942 761 509 1645 1296 998
2017-08-05 2596 2068 513 944 771 187 1652 1297 326
2017-08-06 2607 2074 317 949 772 113 1658 1302 204
2017-08-07 2614 2082 1547 955 768 532 1659 1314 1015
2017-08-08 2623 2092 1556 951 778 515 1672 1314 1041
2017-08-09 2634 2104 1570 963 779 532 1671 1325 1038
2017-08-10 2641 2109 1542 964 780 585 1677 1329 957
2017-08-11 2655 2120 526 962 787 188 1693 1333 338
2017-08-12 2665 2117 323 971 784 114 1694 1333 209
2017-08-13 2683 2131 1635 978 790 579 1705 1341 1056
2017-08-14 2690 2143 1535 978 794 543 1712 1349 992
2017-08-15 2700 2150 1590 986 799 549 1714 1351 1041
2017-08-16 2705 2157 1596 985 803 578 1720 1354 1018
2017-08-17 2714 2168 558 985 803 191 1729 1365 367
2017-08-18 2728 2171 321 996 806 121 1732 1365 200
2017-08-19 2742 2178 1652 997 805 613 1745 1373 1039
2017-08-20 2751 2183 1599 1003 811 552 1748 1372 1047
2017-08-21 2764 2195 1656 1009 818 637 1755 1377 1019
2017-08-22 2769 2207 1588 1013 822 603 1756 1385 985
2017-08-23 2776 2211 533 1006 820 191 1770 1391 342
2017-08-24 2795 2213 336 1019 819 116 1776 1394 220
2017-08-25 2795 2228 1694 1016 826 595 1779 1402 1099
2017-08-26 2805 2242 1652 1019 831 619 1786 1411 1033
2017-08-27 2813 2256 1644 1021 838 609 1792 1418 1035
2017-08-28 2824 2253 1614 1026 838 595 1798 1415 1019
2017-08-29 2843 2270 597 1035 842 217 1808 1428 380
2017-08-30 2841 2273 323 1034 844 117 1807 1429 206
2017-08-31 2865 2272 1716 1044 842 615 1821 1430 1101
2017-09-01 2869 2286 1699 1048 846 597 1821 1440 1102
2017-09-02 2880 2300 1746 1051 855 632 1829 1445 1114
2017-09-03 2891 2308 1732 1049 857 624 1842 1451 1108
2017-09-04 2896 2313 614 1052 858 208 1844 1455 406
2017-09-05 2909 2321 363 1060 863 131 1849 1458 232
2017-09-06 2927 2333 1722 1068 865 633 1859 1468 1089
2017-09-07 2923 2336 1654 1062 867 603 1861 1469 1051
2017-09-08 2933 2345 1768 1066 869 666 1867 1476 1102
2017-09-09 2952 2343 1757 1073 868 665 1879 1475 1092
2017-09-10 2961 2362 588 1073 879 207 1888 1483 381
2017-09-11 2972 2369 361 1082 878 125 1890 1491 236
2017-09-12 2983 2372 1647 1085 877 599 1898 1495 1048
2017-09-13 2985 2381 1752 1084 885 634 1901 1496 1118
2017-09-14 3012 2390 1664 1098 883 592 1914 1507 1072
2017-09-15 3018 2401 1734 1098 893 641 1920 1508 1093
2017-09-16 3025 2413 623 1105 898 208 1920 1515 415
2017-09-17 3035 2420 343 1105 896 133 1930 1524 210
2017-09-18 3042 2428 1715 1109 901 598 1933 1527 1117
2017-09-19 3048 2433 1733 1112 898 606 1936 1535 1127
2017-09-20 3066 2441 1885 1116 903 680 1950 1538 1205
2017-09-21 3065 2443 1771 1116 905 685 1949 1538 1086
2017-09-22 3074 2457 648 1118 911 234 1956 1546 414
2017-09-23 3090 2466 362 1123 918 125 1967 1548 237
2017-09-24 3103 2474 1813 1129 919 671 1974 1555 1142
2017-09-25 3110 2487 1756 1133 922 623 1977 1565 1133
2017-09-26 3127 2493 1807 1138 925 628 1989 1568 1179
2017-09-27 3138 2496 1859 1143 924 683 1995 1572 1176
2017-09-28 3145 2508 646 1141 932 223 2004 1576 423
2017-09-29 3157 2516 376 1148 937 135 2009 1579 241
2017-09-30 3171 2529 1874 1157 939 640 2014 1590 1234
2017-10-01 3170 2533 1953 1154 940 683 2016 1593 1270
2017-10-02 3181 2544 1809 1158 946 656 2023 1598 1153
2017-10-03 3191 2548 1809 1159 949 649 2032 1599 1160
2017-10-04 3216 2556 616 1173 946 223 2043 1610 393
2017-10-05 3228 2573 365 1176 956 130 2052 1617 235
2017-10-06 3237 2591 1882 1177 962 711 2060 1629 1171
2017-10-07 3249 2603 1819 1183 967 661 2066 1636 1158
2017-10-08 3267 2612 1893 1186 967 737 2081 1645 1156
2017-10-09 3286 2625 2013 1200 974 738 2086 1651 1275
2017-10-10 3306 2624 671 1204 974 256 2102 1650 415
2017-10-11 3315 2645 368 1203 978 130 2112 1667 238
2017-10-12 3339 2653 1894 1217 982 659 2122 1671 1235
2017-10-13 3352 2664 1997 1218 986 727 2134 1678 1270
2017-10-14 3358 2683 2007 1222 997 721 2136 1686 1286
2017-10-15 3376 2686 1936 1233 993 676 2143 1693 1260
2017-10-16 3394 2706 696 1239 1004 246 2155 1702 450
2017-10-17 3408 2718 397 1237 1011 151 2171 1707 246
2017-10-18 3426 2720 2033 1246 1009 770 2180 1711 1263
2017-10-19 3434 2747 1992 1251 1021 691 2183 1726 1301
2017-10-20 3453 2750 1990 1253 1019 748 2200 1731 1242
2017-10-21 3479 2754 2082 1267 1020 744 2212 1734 1338
2017-10-22 3491 2777 697 1272 1030 270 2219 1747 427
2017-10-23 3491 2784 415 1269 1033 156 2222 1751 259
2017-10-24 3523 2799 1966 1284 1034 727 2239 1765 1239
2017-10-25 3532 2815 2041 1287 1040 743 2245 1775 1298
2017-10-26 3543 2821 2010 1290 1044 730 2253 1777 1280
2017-10-27 3567 2837 2016 1298 1056 707 2269 1781 1309
2017-10-28 3578 2845 745 1304 1057 261 2274 1788 484
2017-10-29 3592 2859 413 1304 1064 158 2288 1795 255
2017-10-30 3607 2876 2062 1311 1071 788 2296 1805 1274
2017-10-31 3626 2895 2121 1318 1074 771 2308 1821 1350
47 changes: 47 additions & 0 deletions docs/repos-activity.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
layout: default
title: Repository Activity
permalink: /repos-activity
---

<h3>Repositories (Active)</h3>

<div class="row">
<div class="col-main">
<div class="chart-container">
<canvas
class="chart"
data-url="{{ site.dataURL }}/repository-activity.tsv"
data-type="history"
data-config='{
"series": [
"in organizations (last four weeks)",
"in user accounts (last four weeks)",
"in organizations (last week)",
"in user accounts (last week)",
"in organizations (last day)",
"in user accounts (last day)"
],
"visibleSeries": [
"in organizations (last four weeks)",
"in user accounts (last four weeks)"
]
}'
></canvas>
</div>
</div>
<div class="col-aside">
<div class="info-box">
<p>
Shows how many repositories are active in organizations and user
accounts.
</p>
</div>
<div class="info-box">
<p>
Repositories are counted as <em>active</em> if they received at
least one push within the respective time period.
</p>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion docs/repositories-total.html → docs/repos-total.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
layout: default
title: Repositories
permalink: /repositories-total
permalink: /repos-total
---

<h3>Repositories (Total)</h3>
Expand Down
77 changes: 77 additions & 0 deletions updater/reports/ReportRepoActivity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
from .ReportDaily import *

# Lists the number of active repositories in total, in organizations, and in
# user accounts for the last day, week, and 4 weeks
class ReportRepoActivity(ReportDaily):
def name(self):
return "repository-activity"

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, timeRange):
query = '''
SELECT
COUNT(*) AS count
FROM
(
SELECT
repositories.id
FROM
repositories
JOIN users ON repositories.owner_id = users.id
JOIN pushes ON pushes.repository_id = repositories.id
WHERE
CAST(pushes.created_at AS DATE) BETWEEN "''' + str(timeRange[0]) + '''" AND "''' + str(timeRange[1]) + '''"'''

query += self.andExcludedEntities("users", "repositories")

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

query += '''
GROUP BY
repositories.id
) AS activeRepositories'''

return query

# Collects the number of repositories in total, in organizations, and in user accounts
def query(self):
oneDayAgo = self.yesterday()
oneWeekAgo = self.daysAgo(7)
fourWeeksAgo = self.daysAgo(28)

query = '''
SELECT
"''' + str(self.yesterday()) + '''" AS date,
totalLastFourWeeks.count AS "total (last four weeks)",
totalLastWeek.count AS "total (last week)",
totalLastDay.count AS "total (last day)",
organizationSpaceLastFourWeeks.count AS "in organizations (last four weeks)",
organizationSpaceLastWeek.count AS "in organizations (last week)",
organizationSpaceLastDay.count AS "in organizations (last day)",
userSpaceLastFourWeeks.count AS "in user accounts (last four weeks)",
userSpaceLastWeek.count AS "in user accounts (last week)",
userSpaceLastDay.count AS "in user accounts (last day)"
FROM
(''' + self.subquery(None, [fourWeeksAgo, oneDayAgo]) + ''') AS totalLastFourWeeks,
(''' + self.subquery(None, [oneWeekAgo, oneDayAgo]) + ''') AS totalLastWeek,
(''' + self.subquery(None, [oneDayAgo, oneDayAgo]) + ''') AS totalLastDay,
(''' + self.subquery("Organization", [fourWeeksAgo, oneDayAgo]) + ''') AS organizationSpaceLastFourWeeks,
(''' + self.subquery("Organization", [oneWeekAgo, oneDayAgo]) + ''') AS organizationSpaceLastWeek,
(''' + self.subquery("Organization", [oneDayAgo, oneDayAgo]) + ''') AS organizationSpaceLastDay,
(''' + self.subquery("User", [fourWeeksAgo, oneDayAgo]) + ''') AS userSpaceLastFourWeeks,
(''' + self.subquery("User", [oneWeekAgo, oneDayAgo]) + ''') AS userSpaceLastWeek,
(''' + self.subquery("User", [oneDayAgo, oneDayAgo]) + ''') AS userSpaceLastDay
'''

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.ReportRepoActivity import *
from reports.ReportRepositoryHistory import *
from reports.ReportTokenlessAuth import *
from reports.ReportUsers import *
Expand Down Expand Up @@ -79,6 +80,7 @@ def main():
ReportPRByRepo(configuration, dataDirectory, metaStats).update()
ReportPRHistory(configuration, dataDirectory, metaStats).update()
ReportPRUsage(configuration, dataDirectory, metaStats).update()
ReportRepoActivity(configuration, dataDirectory, metaStats).update()
ReportRepositoryHistory(configuration, dataDirectory, metaStats).update()
ReportTokenlessAuth(configuration, dataDirectory, metaStats).update()
ReportUsers(configuration, dataDirectory, metaStats).update()
Expand Down