Skip to content
Open
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
29 changes: 29 additions & 0 deletions physionet-django/console/templates/console/submission_stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,34 @@

</div>
</div>
<div class="card-header">
Projects (past 6 years)
</div>
<div class="card-body">
<div class="table-responsive">

<table class="table table-bordered">
<tr>
<th>Year</th>
<th>Created</th>
<th>Submitted</th>
<th>Resubmitted</th>
<th>Published</th>
<th>Rejected</th>
</tr>
{% for year, val in yearly_stats.items %}
<tr>
<td>{{ year }}</td>
<td>{{ val.0 }}</td>
<td>{{ val.1 }}</td>
<td>{{ val.2 }}</td>
<td>{{ val.3 }}</td>
<td>{{ val.4 }}</td>
</tr>
{% endfor %}
</table>

</div>
</div>
</div>
{% endblock %}
36 changes: 35 additions & 1 deletion physionet-django/console/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2445,8 +2445,42 @@ def submission_stats(request):
except AttributeError:
pass

# Aggregate counts per year (last 6 years)
current_year = datetime.today().year
yearly_stats = OrderedDict()
for y in range(current_year - 5, current_year + 1):
yearly_stats[y] = [0, 0, 0, 0, 0]

for project_set in all_projects:
for project in project_set:
create_yr = project.creation_datetime.year
if create_yr in yearly_stats:
yearly_stats[create_yr][0] += 1

for log in project.edit_log_history():
sub_yr = log.submission_datetime.year
if sub_yr in yearly_stats:
if log.is_resubmission:
yearly_stats[sub_yr][2] += 1
else:
yearly_stats[sub_yr][1] += 1
try:
if log.decision == 0 and log.decision_datetime is not None:
rej_yr = log.decision_datetime.year
if rej_yr in yearly_stats:
yearly_stats[rej_yr][4] += 1
except AttributeError:
pass

try:
pub_yr = project.publish_datetime.year
if pub_yr in yearly_stats:
yearly_stats[pub_yr][3] += 1
except AttributeError:
pass

return render(request, 'console/submission_stats.html',
{'submenu': 'submission', 'stats': stats})
{'submenu': 'submission', 'stats': stats, 'yearly_stats': yearly_stats})


@console_permission_required('project.can_view_stats')
Expand Down
Loading