From 1fc9e67a6adad07d9775fb61ada14ae139be1008 Mon Sep 17 00:00:00 2001 From: Keshav Garg Date: Fri, 2 Aug 2019 17:38:30 +0530 Subject: [PATCH] Display more info. about unassigned issues This commit uses the issues.html general template to display the activity of unassigned issues. It displays some useful information about issues which were not being provided earlier Closes https://github.com/coala/community/issues/289 --- .moban.yaml | 1 - .nocover.yaml | 2 - community/urls.py | 12 ++--- community/views.py | 15 +++++- .../0010_unassignedissuesactivity.py | 24 ++++++++++ data/models.py | 8 ++++ setup.cfg | 3 -- templates/base.html | 2 +- .../unassigned_issues_scraper.py | 48 ------------------- 9 files changed, 52 insertions(+), 63 deletions(-) create mode 100644 data/migrations/0010_unassignedissuesactivity.py delete mode 100644 unassigned_issues/unassigned_issues_scraper.py diff --git a/.moban.yaml b/.moban.yaml index 3259df28..634770c4 100644 --- a/.moban.yaml +++ b/.moban.yaml @@ -11,7 +11,6 @@ packages: - ci_build - meta_review - twitter - - unassigned_issues dependencies: - getorg~=0.3.1 diff --git a/.nocover.yaml b/.nocover.yaml index 7af2e0fd..60f2ac50 100644 --- a/.nocover.yaml +++ b/.nocover.yaml @@ -12,8 +12,6 @@ nocover_file_globs: - meta_review/handler.py - openhub/*.py - twitter/*.py - # Optional coverage. Once off scripts. - - unassigned_issues/unassigned_issues_scraper.py # The following rules can remain here # django db - '*/migrations/*.py' diff --git a/community/urls.py b/community/urls.py index ed1b3e73..f6a4b025 100644 --- a/community/urls.py +++ b/community/urls.py @@ -9,7 +9,8 @@ from community.views import ( HomePageView, JoinCommunityView, - OrganizationTeams, InactiveIssuesList + OrganizationTeams, InactiveIssuesList, + UnassignedIssuesActivityList ) from gci.views import GCIStudentsList from gci.feeds import LatestTasksFeed as gci_tasks_rss @@ -18,9 +19,6 @@ from data.views import ContributorsListView from gamification.views import GamificationResults from meta_review.views import ContributorsMetaReview -from unassigned_issues.unassigned_issues_scraper import ( - unassigned_issues_activity_json, -) def get_index(): @@ -91,10 +89,10 @@ def get_index(): distill_file='inactive-issues/index.html', ), distill_url( - r'static/unassigned-issues.json', unassigned_issues_activity_json, - name='unassigned_issues_activity_json', + r'unassigned-issues/', UnassignedIssuesActivityList.as_view(), + name='unassigned-issues', distill_func=get_index, - distill_file='static/unassigned-issues.json', + distill_file='unassigned-issues/index.html', ), distill_url( r'gamification/$', GamificationResults.as_view(), diff --git a/community/views.py b/community/views.py index ddd0eb3c..c2cc1930 100644 --- a/community/views.py +++ b/community/views.py @@ -23,7 +23,7 @@ NewcomerPromotion, Feedback ) -from data.models import Team, InactiveIssue +from data.models import Team, InactiveIssue, UnassignedIssuesActivity from gamification.models import Participant as GamificationParticipant from meta_review.models import Participant as MetaReviewer @@ -231,3 +231,16 @@ def get_context_data(self, **kwargs): context = get_header_and_footer(context) context['page_name'] = 'Inactive Issues List' return context + + +class UnassignedIssuesActivityList(ListView): + + template_name = 'issues.html' + model = UnassignedIssuesActivity + ordering = 'hoster' + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context = get_header_and_footer(context) + context['page_name'] = 'Unassigned Issues Activity List' + return context diff --git a/data/migrations/0010_unassignedissuesactivity.py b/data/migrations/0010_unassignedissuesactivity.py new file mode 100644 index 00000000..cf251856 --- /dev/null +++ b/data/migrations/0010_unassignedissuesactivity.py @@ -0,0 +1,24 @@ +# Generated by Django 2.1.7 on 2019-08-02 12:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('data', '0009_inactiveissue'), + ] + + operations = [ + migrations.CreateModel( + name='UnassignedIssuesActivity', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('hoster', models.CharField(max_length=30)), + ('title', models.CharField(max_length=500)), + ('repository', models.CharField(max_length=100)), + ('number', models.SmallIntegerField()), + ('url', models.URLField()), + ], + ), + ] diff --git a/data/models.py b/data/models.py index b7f4afdc..71db35c8 100644 --- a/data/models.py +++ b/data/models.py @@ -124,3 +124,11 @@ class InactiveIssue(models.Model): repository = models.CharField(max_length=100) number = models.SmallIntegerField() url = models.URLField() + + +class UnassignedIssuesActivity(models.Model): + hoster = models.CharField(max_length=30) + title = models.CharField(max_length=500) + repository = models.CharField(max_length=100) + number = models.SmallIntegerField() + url = models.URLField() diff --git a/setup.cfg b/setup.cfg index 4a565768..71c8543d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,6 @@ testpaths = ci_build meta_review twitter - unassigned_issues python_files = test_*.py python_classes = *Test @@ -70,7 +69,6 @@ source = ci_build meta_review twitter - unassigned_issues omit = tests/* @@ -82,7 +80,6 @@ omit = meta_review/handler.py openhub/*.py twitter/*.py - unassigned_issues/unassigned_issues_scraper.py */migrations/*.py */management/commands/*.py meta_review/load_from_db.py diff --git a/templates/base.html b/templates/base.html index 9fc054c8..ec77054b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -79,7 +79,7 @@
  • Mentors
  • Google Code-in Students
  • Inactive issues
  • -
  • Unassigned issues activity
  • +
  • Unassigned issues activity
  • Project CI Build
  • {% if isTravis %}
  • TravisCI build info
  • diff --git a/unassigned_issues/unassigned_issues_scraper.py b/unassigned_issues/unassigned_issues_scraper.py deleted file mode 100644 index 2f57810b..00000000 --- a/unassigned_issues/unassigned_issues_scraper.py +++ /dev/null @@ -1,48 +0,0 @@ -import json - -from django.http import HttpResponse -from gci.config import get_api_key -from IGitt.GitHub import GitHubToken -from IGitt.GitHub.GitHubRepository import GitHubRepository -from IGitt.Interfaces import MergeRequestStates -from IGitt.Interfaces import IssueStates -from IGitt.Interfaces.CommitStatus import Status - -from community.git import get_org_name - - -def run(mr_requests): - issues_number_list = [] - for pr in mr_requests: - if pr.state is MergeRequestStates.OPEN: - for commit in pr.commits: - status = commit.combined_status - break - if status in [Status.PENDING, Status.SUCCESS]: - for issue in pr.closes_issues: - if issue.state is IssueStates.OPEN: - if pr.author.username not in ( - [a.username for a in issue.assignees]): - issues_number_list.append(issue.number) - issues_number_list.sort() - return issues_number_list - - -def unassigned_issues_activity_json(request): - try: - GH_TOKEN = get_api_key('GH') - except Exception: - return HttpResponse('[]') - org_name = get_org_name() - org_repo_name = org_name - # Here 'org_repo_name' is the name of repository of a organization. - # (assumed here, that name of repository is same as the organization name.) - # But you can change 'org_repo_name' as per your requirement. - repo_name = org_name + '/' + org_repo_name - # 'repo_name' is a full name of repository e.g. `fossasia/susi_server` - # which further used for query (assuming here 'org_name' is different from - # 'org_repo_name') - repo = GitHubRepository(GitHubToken(GH_TOKEN), repo_name) - mr_requests = repo.merge_requests - final_list = run(mr_requests) - return HttpResponse(json.dumps(final_list))