|
1 | 1 | from .ReportDaily import *
|
2 | 2 |
|
3 |
| -# Lists how many users pushed commits vs. how many used a seat in the last day, week, and month |
| 3 | +# Lists how many users pushed commits vs. how many used a seat in the last day, week, and four weeks |
4 | 4 | class ReportUsers(ReportDaily):
|
5 | 5 | def name(self):
|
6 | 6 | return "users"
|
7 | 7 |
|
8 | 8 | def updateDailyData(self):
|
9 |
| - self.header, newData = self.parseData(self.executeQuery(self.query(self.yesterday()))) |
| 9 | + self.header, newData = self.parseData(self.executeQuery(self.query())) |
10 | 10 | self.data.extend(newData)
|
11 | 11 | self.truncateData(self.timeRangeTotal())
|
12 | 12 | self.sortDataByDate()
|
@@ -36,20 +36,20 @@ def usersUsingSeatSubquery(self):
|
36 | 36 | users.suspended_at IS NULL'''
|
37 | 37 |
|
38 | 38 | # Collects the number of pushing users and users using a seat
|
39 |
| - def query(self, date): |
40 |
| - # Also compute the stats for a 7-day and a 30-day period |
41 |
| - sevenDaysEarlier = date - datetime.timedelta(6) |
42 |
| - thirtyDaysEarlier = date - datetime.timedelta(29) |
| 39 | + def query(self): |
| 40 | + oneDayAgo = self.yesterday() |
| 41 | + oneWeekAgo = self.daysAgo(7) |
| 42 | + fourWeeksAgo = self.daysAgo(28) |
43 | 43 |
|
44 | 44 | return '''
|
45 | 45 | SELECT
|
46 |
| - "''' + str(date) + '''" AS date, |
| 46 | + "''' + str(oneDayAgo) + '''" AS date, |
47 | 47 | usersPushingYesterday.count AS "pushing commits (last day)",
|
48 | 48 | usersPushingLastWeek.count AS "pushing commits (last week)",
|
49 |
| - usersPushingLastMonth.count AS "pushing commits (last month)", |
| 49 | + usersPushingLastFourWeeks.count AS "pushing commits (last four weeks)", |
50 | 50 | usersUsingSeat.count AS "using license"
|
51 | 51 | FROM
|
52 |
| - (''' + self.usersPushingSubquery([date, date]) + ''') AS usersPushingYesterday, |
53 |
| - (''' + self.usersPushingSubquery([sevenDaysEarlier, date]) + ''') AS usersPushingLastWeek, |
54 |
| - (''' + self.usersPushingSubquery([thirtyDaysEarlier, date]) + ''') AS usersPushingLastMonth, |
| 52 | + (''' + self.usersPushingSubquery([oneDayAgo, oneDayAgo]) + ''') AS usersPushingYesterday, |
| 53 | + (''' + self.usersPushingSubquery([oneWeekAgo, oneDayAgo]) + ''') AS usersPushingLastWeek, |
| 54 | + (''' + self.usersPushingSubquery([fourWeeksAgo, oneDayAgo]) + ''') AS usersPushingLastFourWeeks, |
55 | 55 | (''' + self.usersUsingSeatSubquery() + ''') AS usersUsingSeat'''
|
0 commit comments