Skip to content

Commit

Permalink
frontend: provide statistics on how many users submitted at least one…
Browse files Browse the repository at this point in the history
… build in past month

Fixes: # 3315
  • Loading branch information
xsuchy authored and praiskup committed Sep 6, 2024
1 parent 414fc74 commit 11cdd66
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions frontend/coprs_frontend/coprs/logic/builds_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ def get_running_tasks_by_time(cls, start, end):

return result

@classmethod
def get_users_by_time(cls, start, end):
""" Returns number of user that submitted at least one build in
the period.
"""
result = db.session.query(models.Build.user_id)\
.join(models.BuildChroot)\
.filter(models.BuildChroot.ended_on > start)\
.filter(models.BuildChroot.started_on < end)\
.group_by(models.Build.user_id).count()
return result

@classmethod
def get_chroot_histogram(cls, start, end):
chroots = []
Expand All @@ -150,6 +162,7 @@ def get_chroot_histogram(cls, start, end):
l[0] = mock_chroot.name
return chroots


@classmethod
def get_pending_jobs_bucket(cls, start, end):
query = text("""
Expand Down
6 changes: 6 additions & 0 deletions frontend/coprs_frontend/coprs/templates/status/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ <h3>Builds during last 24 hours</h3>
<h3>Builds during last 90 days</h3>
<div id="chartNinetyDays" class="line-chart-pf"></div>
</div>
<div class="row">
<h3>Number of users that submitted at least one build in past 30 days.</h3>
</div>
<div class="row">
<h4>{{ users_in_past_month }}</h4>
</div>
<div class="row">
<h3>Builds divided by chroots</h3>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def stats():
curr_time = int(time())
chroots_24h = builds_logic.BuildsLogic.get_chroot_histogram(curr_time - 86400, curr_time)
chroots_90d = builds_logic.BuildsLogic.get_chroot_histogram(curr_time - 90*86400, curr_time)
users_in_past_month = builds_logic.BuildsLogic.get_users_by_time(curr_time - 30*86400, curr_time)
data_24h = builds_logic.BuildsLogic.get_task_graph_data('10min')
data_90d = builds_logic.BuildsLogic.get_task_graph_data('24h')
actions_24h = builds_logic.ActionsLogic.get_action_graph_data('10min')
Expand All @@ -173,6 +174,7 @@ def stats():
return flask.render_template("status/stats.html",
data1=data_24h,
data2=data_90d,
users_in_past_month=users_in_past_month,
chroots1=chroots_24h,
chroots2=chroots_90d,
actions1=actions_24h,
Expand Down

0 comments on commit 11cdd66

Please sign in to comment.