Skip to content

Commit

Permalink
Merge pull request #422 from thiSSSnake/new-tabs-home
Browse files Browse the repository at this point in the history
Обновил логику добавления в контекст последних 10 пулл реквестов и проблем на главной странице
  • Loading branch information
fey authored Jun 7, 2024
2 parents dacf9a7 + 3fadf5c commit 4ddf012
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 26 deletions.
30 changes: 8 additions & 22 deletions contributors/views/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,8 @@ def get_context_data(self, **kwargs): # noqa: WPS210
Contributor.objects.visible_with_weekly_stats()
)

contributions_for_month = (
Contribution.objects.visible_for_month()
)

contributions_for_week = (
Contribution.objects.visible_for_week()
latest_contributions = (
Contribution.objects.all()
)

top10_committers_of_month = get_top10(
Expand Down Expand Up @@ -67,20 +63,12 @@ def get_context_data(self, **kwargs): # noqa: WPS210
contributors_for_week, 'comments',
)

latest_month_issues = get_latest_contributions(
contributions_for_month, 'iss',
)

latest_week_issues = get_latest_contributions(
contributions_for_week, 'iss',
)

latest_month_pr = get_latest_contributions(
contributions_for_month, 'pr',
latest_issues = get_latest_contributions(
latest_contributions, 'iss',
)

latest_week_pr = get_latest_contributions(
contributions_for_week, 'pr',
latest_pr = get_latest_contributions(
latest_contributions, 'pr',
)

context.update(
Expand All @@ -95,10 +83,8 @@ def get_context_data(self, **kwargs): # noqa: WPS210
'top10_reporters_of_week': top10_reporters_of_week,
'top10_commentators_of_week': top10_commentators_of_week,
'contributions_for_year': Contribution.objects.for_year(),
'latest_month_issues': latest_month_issues,
'latest_week_issues': latest_week_issues,
'latest_month_pr': latest_month_pr,
'latest_week_pr': latest_week_pr,
'latest_time_issues': latest_issues,
'latest_time_pr': latest_pr,
},
)

Expand Down
2 changes: 1 addition & 1 deletion static/js/time_and_type_selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function time_note(data_type) {


document.addEventListener('DOMContentLoaded', start('top-week'));
document.addEventListener('DOMContentLoaded', start('latest-for-week'));
document.addEventListener('DOMContentLoaded', start('latest-in-recent-times'));
document.addEventListener('DOMContentLoaded', time_note('top-10-items'));
document.addEventListener('DOMContentLoaded', time_note('latest-issues-and-prs'));

18 changes: 18 additions & 0 deletions templates/components/latest_issues_and_pr.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% load i18n %}

<div class="card latest-issues-and-prs latest-in-recent-times">
<div class="card-header">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item">
<a class="nav-link px-2 active" name="pull-requests" href="#">{% trans 'by pull requests' %}</a>
</li>
<li class="nav-item">
<a class="nav-link px-2" name="issues" href="#">{% trans 'by issues' %}</a>
</li>
</ul>
</div>
{% with tab='components/top_issues.html' %}
{% include tab with latest_issues=latest_time_pr class='pull-requests' %}
{% include tab with latest_issues=latest_time_issues class='issues' %}
{% endwith %}
</div>
6 changes: 6 additions & 0 deletions templates/components/time_note_issues_and_pr.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@
{% trans "for the past month" %}
</a>
</li>
<li class="nav-item">
<a class="nav-link time-note py-1" href="#"
name="latest-in-recent-times">
{% trans "Recent" %}
</a>
</li>
</ul>
5 changes: 2 additions & 3 deletions templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ <h2 class="top-10-title">{% trans "Top 10 contributors" %}</h2>
<div class="col-md-6">
<h2 class="latest-issues-and-prs-heading">{% trans "New PRs and issues" %}</h2>
<div class="latest-issues-and-prs">
{% include 'components/time_note_issues_and_pr.html' %}
{% include 'components/issues_and_pr_for_week.html' %}
{% include 'components/issues_and_pr_for_month.html' %}
<h4>{% trans "Latest in recent times" %}</h3>
{% include 'components/latest_issues_and_pr.html' %}
</div>
</div>
</div>
Expand Down

0 comments on commit 4ddf012

Please sign in to comment.