Skip to content
Snippets Groups Projects
Commit ecbf01f7 authored by jurgenhaas's avatar jurgenhaas
Browse files

#1 Implement poller for Redmine

parent c1c70b28
No related branches found
No related tags found
No related merge requests found
......@@ -60,13 +60,12 @@ BaseTrackerSource.prototype.readItems = function(items, sort) {
}
this.debug('Last activity: ' + this.formatDate(this.lastActivity));
var i, item, message;
var i, item;
for (i in items) {
item = items[i];
if (this.isItemNew(item)) {
if (this.notifyItem(item)) {
this.debug('Notify');
this.debug(message);
this.dashboard.emit('newTrackerItem', this, item);
}
......
/**
* Module dependencies.
*/
var request = require('request');
var util = require('util');
var BaseTrackerSource = require('../baseSource');
/**
* Redmine TrackerSource, to receive latest changes from and report to targets
*
* @param {String} id
* @param {Integer} lastActivity
* @param {String} url
* @param {Array} params
* @api public
*/
function RedmineTrackerSource(id, lastActivity, url, params) {
RedmineTrackerSource.super_.call(this, id, lastActivity, url, params);
}
util.inherits(RedmineTrackerSource, BaseTrackerSource);
RedmineTrackerSource.type = 'Redmine';
RedmineTrackerSource.prototype.poll = function() {
var source = this;
var url = source.url + '/issues.json?key=' + source.password + '&sort=updated_on&updated_on=%3E%3D' + source.formatDate(source.lastActivity);
if (source.project_include) {
url += "&project_id=" + source.project_include;
}
source.debug(url);
request
.get(url,
function(error, response, body) {
var res = JSON.parse(body);
source.debug(body);
source.readItems(res.issues, false);
})
.on('error', function(e) {
source.debug('ERROR: ' + e.message);
});
};
RedmineTrackerSource.prototype.notifyItem = function(item) {
return !(this.hideMine && (item['assigned_to']['name'] == this.username));
};
RedmineTrackerSource.prototype.renderItem = function(item, linkCB, imageCB) {
return item['assigned_to']['name'] + ': ' + linkCB(item['id'], this.url + '/issues/' + item['id']) + ' ' + item['subject'];
};
RedmineTrackerSource.prototype.getItemDate = function(item) {
return item['updated_on'];
};
RedmineTrackerSource.prototype.formatDate = function(timestamp) {
return timestamp || new Date().toISOString().substr(0, 19) + 'Z';
};
module.exports = RedmineTrackerSource;
......@@ -5,6 +5,7 @@ var TrackerSourceCollection = function(sources) {
TrackerSourceCollection.prototype.addDefaultSources = function() {
this.add(require('./jira/jiraSource.js'));
this.add(require('./redmine/redmineSource.js'));
this.add(require('./rss/rssSource.js'));
this.add(require('./teamwork/teamworkSource.js'));
this.add(require('./youtrack/youtrackSource.js'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment