From 8453356514edb9027391ce7818c60114319987ba Mon Sep 17 00:00:00 2001 From: Andrei Emelianenko Date: Wed, 5 Jun 2024 00:01:14 +0300 Subject: [PATCH 1/2] Updated the logic of adding the last 10 pull requests and issues to the context on the main page home.py , added a new template to compontents/latest_issues_and_pr.html , changed the code in the JS script. --- contributors/views/home.py | 30 +++++-------------- static/js/time_and_type_selector.js | 2 +- .../components/time_note_issues_and_pr.html | 6 ++++ templates/home.html | 5 ++-- 4 files changed, 17 insertions(+), 26 deletions(-) diff --git a/contributors/views/home.py b/contributors/views/home.py index 94176555..31bea87a 100644 --- a/contributors/views/home.py +++ b/contributors/views/home.py @@ -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( @@ -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( @@ -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, }, ) diff --git a/static/js/time_and_type_selector.js b/static/js/time_and_type_selector.js index c8951d7e..ece7051e 100644 --- a/static/js/time_and_type_selector.js +++ b/static/js/time_and_type_selector.js @@ -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')); diff --git a/templates/components/time_note_issues_and_pr.html b/templates/components/time_note_issues_and_pr.html index 1aa91299..6be32a69 100644 --- a/templates/components/time_note_issues_and_pr.html +++ b/templates/components/time_note_issues_and_pr.html @@ -13,4 +13,10 @@ {% trans "for the past month" %} + diff --git a/templates/home.html b/templates/home.html index 796c513c..65e46034 100644 --- a/templates/home.html +++ b/templates/home.html @@ -21,9 +21,8 @@

{% trans "Top 10 contributors" %}

{% trans "New PRs and issues" %}

- {% include 'components/time_note_issues_and_pr.html' %} - {% include 'components/issues_and_pr_for_week.html' %} - {% include 'components/issues_and_pr_for_month.html' %} +

{% trans "Latest in recent times" %}

+ {% include 'components/latest_issues_and_pr.html' %}
From 3fadf5c0a69c758f8e4708437eb9f7d22d5ede14 Mon Sep 17 00:00:00 2001 From: Andrei Emelianenko Date: Thu, 6 Jun 2024 14:39:01 +0300 Subject: [PATCH 2/2] added new template file in components(latest_issues_and_pr.html) --- templates/components/latest_issues_and_pr.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 templates/components/latest_issues_and_pr.html diff --git a/templates/components/latest_issues_and_pr.html b/templates/components/latest_issues_and_pr.html new file mode 100644 index 00000000..7ac57dc4 --- /dev/null +++ b/templates/components/latest_issues_and_pr.html @@ -0,0 +1,18 @@ +{% load i18n %} + +
+ + {% 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 %} +