diff --git a/.moban.yaml b/.moban.yaml index 2ed895e8..3259df28 100644 --- a/.moban.yaml +++ b/.moban.yaml @@ -4,7 +4,6 @@ package_module: community packages: - community - activity - - inactive_issues - data - gci - gsoc diff --git a/.nocover.yaml b/.nocover.yaml index f6b73c6d..7af2e0fd 100644 --- a/.nocover.yaml +++ b/.nocover.yaml @@ -13,7 +13,6 @@ nocover_file_globs: - openhub/*.py - twitter/*.py # Optional coverage. Once off scripts. - - inactive_issues/inactive_issues_scraper.py - unassigned_issues/unassigned_issues_scraper.py # The following rules can remain here # django db diff --git a/community/urls.py b/community/urls.py index fa3c14d3..ed1b3e73 100644 --- a/community/urls.py +++ b/community/urls.py @@ -9,7 +9,7 @@ from community.views import ( HomePageView, JoinCommunityView, - OrganizationTeams + OrganizationTeams, InactiveIssuesList ) from gci.views import GCIStudentsList from gci.feeds import LatestTasksFeed as gci_tasks_rss @@ -18,7 +18,6 @@ from data.views import ContributorsListView from gamification.views import GamificationResults from meta_review.views import ContributorsMetaReview -from inactive_issues.inactive_issues_scraper import inactive_issues_json from unassigned_issues.unassigned_issues_scraper import ( unassigned_issues_activity_json, ) @@ -86,10 +85,10 @@ def get_index(): distill_file='meta-review/index.html', ), distill_url( - r'static/inactive-issues.json', inactive_issues_json, - name='inactive_issues_json', + r'inactive-issues/', InactiveIssuesList.as_view(), + name='inactive-issues', distill_func=get_index, - distill_file='static/inactive-issues.json', + distill_file='inactive-issues/index.html', ), distill_url( r'static/unassigned-issues.json', unassigned_issues_activity_json, diff --git a/community/views.py b/community/views.py index 0126a6d1..ddd0eb3c 100644 --- a/community/views.py +++ b/community/views.py @@ -23,7 +23,7 @@ NewcomerPromotion, Feedback ) -from data.models import Team +from data.models import Team, InactiveIssue from gamification.models import Participant as GamificationParticipant from meta_review.models import Participant as MetaReviewer @@ -218,3 +218,16 @@ def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context = get_header_and_footer(context) return context + + +class InactiveIssuesList(ListView): + + template_name = 'issues.html' + model = InactiveIssue + ordering = 'hoster' + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context = get_header_and_footer(context) + context['page_name'] = 'Inactive Issues List' + return context diff --git a/data/migrations/0009_inactiveissue.py b/data/migrations/0009_inactiveissue.py new file mode 100644 index 00000000..6bdaf3e1 --- /dev/null +++ b/data/migrations/0009_inactiveissue.py @@ -0,0 +1,24 @@ +# Generated by Django 2.1.7 on 2019-08-02 11:39 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('data', '0008_auto_20190802_0745'), + ] + + operations = [ + migrations.CreateModel( + name='InactiveIssue', + 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 295ec08f..b7f4afdc 100644 --- a/data/models.py +++ b/data/models.py @@ -116,3 +116,11 @@ def get_closes_issues_object(self): issue_object = issue_number.get_issue() issues_object_list.append(issue_object) return issues_object_list + + +class InactiveIssue(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/inactive_issues/inactive_issues_scraper.py b/inactive_issues/inactive_issues_scraper.py deleted file mode 100644 index 88c2e3a1..00000000 --- a/inactive_issues/inactive_issues_scraper.py +++ /dev/null @@ -1,67 +0,0 @@ -import time -import json - -from github import Github -from dateutil.parser import parse -from datetime import date -from django.http import HttpResponse -from gci.config import get_api_key - -from community.git import get_org_name - - -def run(issues): - issues_number_list = [] - for j in issues: - issue_no = j.number - events = j.get_events() - myevent_list = [] - data = [] - for i in events: - myevent_list.append(str(i.event)) - for i in events: - if i.commit_id is not None: - data.append(str(i.created_at)) - for i, myevents in reversed(list(enumerate(myevent_list))): - if myevents == 'unassigned': - break - elif myevents == 'assigned': - a = events[i].created_at - c = (date.fromtimestamp(time.time()) - a.date()).days - if c >= 60: # for checking assigned duration - - mydata = list(reversed(data)) - if len(mydata) != 0: - commit1 = parse(mydata[0]) - calculated_days = (date.fromtimestamp( - time.time()) - commit1.date()).days - if calculated_days >= 60: - # for checking last commit update - issues_number_list.append(issue_no) - else: - issues_number_list.append(issue_no) - break - return issues_number_list - - -def inactive_issues_json(request): - try: - GH_TOKEN = get_api_key('GH') - except Exception: - return HttpResponse('[]') - g1 = Github(GH_TOKEN) - org_name = get_org_name() - org = g1.get_organization(org_name) - repo = org.get_repo(org_name) - issues = repo.get_issues() - issues_list = [] - for myissue in issues: - labels = [] - for mylabel in myissue.labels: - labels.append(mylabel.name) - if 'status/blocked' not in labels: - if myissue.state == 'open' and myissue.pull_request is None: - issues_list.append(myissue) - - final_list = run(issues_list) - return HttpResponse(json.dumps(final_list)) diff --git a/setup.cfg b/setup.cfg index b9566437..4a565768 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,7 +9,6 @@ DJANGO_SETTINGS_MODULE = community.settings testpaths = community activity - inactive_issues data gci gsoc @@ -64,7 +63,6 @@ plugins = source = community activity - inactive_issues data gci gsoc @@ -84,7 +82,6 @@ omit = meta_review/handler.py openhub/*.py twitter/*.py - inactive_issues/inactive_issues_scraper.py unassigned_issues/unassigned_issues_scraper.py */migrations/*.py */management/commands/*.py diff --git a/templates/base.html b/templates/base.html index cfb2b6bf..7fdd2b08 100644 --- a/templates/base.html +++ b/templates/base.html @@ -78,7 +78,7 @@
  • Contributors Information
  • Mentors
  • Google Code-in Students
  • -
  • Inactive issues
  • +
  • Inactive issues
  • Unassigned issues activity
  • Project CI Build
  • {% if isTravis %} diff --git a/templates/issues.html b/templates/issues.html new file mode 100644 index 00000000..72ff2e38 --- /dev/null +++ b/templates/issues.html @@ -0,0 +1,36 @@ +{% extends 'base.html' %} +{% load staticfiles %} + +{% block main-content %} +
    +

    ~

    +

    + {{ page_name }} +

    +

    ~

    +
    +
    + + + + + + + + + + {% for issue in object_list %} + + + + + + {% endfor %} + +
    Hoster
    Title
    Issue
    {{ issue.hoster }}{{ issue.title }} + {{ issue.repository }}#{{ issue.number }} +
    +
    + +{% endblock %}