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
8 changes: 8 additions & 0 deletions data_processor/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,5 +235,13 @@ def issue_distribution(owner, repo):
data = queries.issue_distribution(index)
return jsonify(data=data)

@app.route('/<owner>/<repo>/active_issues')
@crossdomain(origin='*')
@cached()
def active_issues(owner, repo):
index = index_name(owner, repo)
data = queries.active_issues(index)
return jsonify(data=data)

if __name__ == '__main__':
app.run(host='0.0.0.0', threaded=True)
18 changes: 18 additions & 0 deletions data_processor/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,24 @@ def total_events(index, start=None, end=None):
counts[c['term']] = c['count']
return counts


def active_issues(index):
"""
Find the issues that have been active during the past week
"""
now = datetime.datetime.now()
limit = now - datetime.timedelta(weeks=1)
issues = S().indexes(index).doctypes('IssuesEvent', 'IssueCommentEvent', 'PullRequestEvent', 'PullRequestReviewCommentEvent') \
.filter(updated_at__gt=limit).values_dict()

issues = all(issues)

active_issues = [i for i in list(issues)]
active_issues = active_issues[:LIMIT]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are getting all issues and then slicing them back to a few. Try doing something like active = [i for i in issues[:LIMIT]].


return active_issues


def most_active_issues(index, start=None, end=None):
"""
Finds the 10 most active open issues - by total number of events.
Expand Down