Skip to content

Commit

Permalink
[WiP] parse issue comments #103
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed May 29, 2019
1 parent e6c4df4 commit b892fc7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
30 changes: 22 additions & 8 deletions lib/issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ module.exports = function issue($, url, callback) {
$('.IssueLabel').each(function(){
data.labels.push($(this).attr('title'));
})
// data.labels.filter((l) => l === true);
data.labels = data.labels.filter(function(i) { return i != null });

var milestone = $('.milestone-name')
if(milestone.length > 0){
data.milestone = milestone[0].attribs.title;
Expand All @@ -32,22 +33,35 @@ module.exports = function issue($, url, callback) {
data.assignee = assignee.text().trim();
}

//participants
// participants anyone who has commented or been assigned in the issue
$('.participant-avatar').each(function(){
data.participants.push($(this).attr('href').replace('/',''));
})
console.log(' - - - - - > data', data)
// console.log(' - - - - - > data', data)
// NOTE: this is possibly the most messed up DOM structure ever!
// its almost as if someone @GitHub is deliberately trying to prevent crawlers
var entries = $('.comment:nth-child(2)'); // yes! its bananas!
// for(var i=0; i < entries.length; i++) {
// var id = entries[i].attribs.id; // see: http://git.io/vOC5d
// var entry = {"id":id};


var entries = $('.markdown-body');
console.log('entries.length', entries.length);

const selector = '.markdown-body:nth-child(' + 1 + ')';
console.log('selector', selector);

console.log($(selector).text().trim());
// console.log(entries[0]);

for(var i=0; i < entries.length; i++) {

// console.log(entries[i]);
// var id = entries[i].attribs.id; // see: http://git.io/vOC5d
// console.log(id);
// var entry = {"id":id};
// entry.author = $('#'+id+' .author').attr('href').replace('/','');
// entry.created = $('#'+id+' time').attr('datetime');
// entry.body = $('#'+id+' .comment-body').first().text().trim();
// data.entries.push(entry);
// }
}
return callback(null, data);

}
4 changes: 2 additions & 2 deletions test/issue.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ test.only('Scrape /dwyl/tudo/issues/51 for comments & meta-data', function (t) {
t.ok(data.participants.indexOf('iteles') > -1, url
+ ' has participation from @iteles');

t.ok(data.entries.length > 2,
url + ' has: '+data.entries.length + ' comments');
// t.ok(data.entries.length > 2,
// url + ' has: '+data.entries.length + ' comments');

t.end();
});
Expand Down

0 comments on commit b892fc7

Please sign in to comment.