Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completed task: "Update Issues for Repository route to get all issue data". #85

Merged
merged 11 commits into from Aug 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions git-technetium/public/partials/issues.partial.html
Expand Up @@ -26,12 +26,20 @@ <h3 class="panel-title"><i class="fa fa-bar-chart-o fa-fw"></i> Issues </h3>
<table class="table table-bordered table-hover table-striped tablesorter">
<thead>
<tr>
<th class="header">Issue Title</th>
<th class="header">#</th>
<th class="header">Title</th>
<th class="header">State</th>
<th class="header">Opened by</th>
<th class="header">Assigned to</th>
</tr>
</thead>
<tbody>
<tr data-ng-repeat="issueTitle in pageData">
<td>{{ issueTitle }}</td>
<tr data-ng-repeat="issue in pageData">
<td>{{ issue.number }}</td>
<td><a ng-href="http://github.com/DrkSephy/git-technetium/issues/{{ issue.number }}">{{ issue.title }}</a></td>
<td>{{ issue.state }}</td>
<td><a ng-href="http://github.com/{{ issue.creator }}">{{ issue.creator }}</a></td>
<td><a ng-href="http://github.com/{{ issue.assignee }}">{{ issue.assignee }}</a></td>
</tr>
</tbody>
</table>
Expand Down
47 changes: 33 additions & 14 deletions git-technetium/routes.js
Expand Up @@ -15,24 +15,43 @@ module.exports = function(router, request, async, CLIENT_ID, CLIENT_SECRET) {
* ownerName (string): The owner username of the target repository
* repoName (string): The target repository name
* Postcondition:
* An array, where each element contains the title of an issue in the repository
* An array of objects such that each object contains the following:
* number (integer): The number of an issue in the repository
* title (string) : The title of an issue in the repository
* state (string) : The state (open, closed) of an issue in the repository
* creator (string) : The username of the person who opened the issue
* assignee (string) : The username of the person who was assigned the issue
**/
router.get('/issues', function(req, res) {
request({
url: 'https://api.github.com/repos/' + req.query.owner + '/' + req.query.repo + '/issues?state=all' + '&' + 'client_id=' + CLIENT_ID + '&' + 'client_secret=' + CLIENT_SECRET,
headers: { 'user-agent': 'git-technetium' },
json: true
}, function(error, response, body) {
if(!error && response.statusCode === 200) {
var issueTitles = [];
for(var issueIndex = 0; issueIndex < body.length; issueIndex++) {
if(!body[issueIndex].pull_request) {
issueTitles.push(body[issueIndex].title);
var issueData = [];
var getData = function(pageCounter) {
request({
url: 'https://api.github.com/repos/' + req.query.owner + '/' + req.query.repo + '/issues?state=all' + '&page=' + pageCounter + '&client_id=' + CLIENT_ID + '&' + 'client_secret=' + CLIENT_SECRET,
headers: { 'user-agent': 'git-technetium' },
json: true
}, function(error, response, body) {
if(!error && response.statusCode === 200) {
for(var issueIndex = 0; issueIndex < body.length; issueIndex++) {
if(!body[issueIndex].pull_request) {
issueData.push({
number: body[issueIndex].number,
title: body[issueIndex].title,
state: body[issueIndex].state,
creator: body[issueIndex].user.login,
assignee: body[issueIndex].assignee ? body[issueIndex].assignee.login : ''
});
}
}

if(body.length < 30) {
res.send(issueData);
} else {
getData(pageCounter + 1);
}
}
res.send(issueTitles);
}
});
});
};
getData(1);
});

/**
Expand Down
2 changes: 1 addition & 1 deletion notes/tasks.txt
Expand Up @@ -61,7 +61,7 @@ of 30 datasets.
|
+ - - Update Number of Issues Closed per Contributor route to get all data......[ X ]
|
+ - - Update Issues for Repository route to get all issue data..................[ ]
+ - - Update Issues for Repository route to get all issue data..................[ X ]

#####################################################################################
# Tasks / Road map (Project Inception ~ August 9th, 2014) #
Expand Down