Commit faff49e67cc84e5fa54a14136d98a6126f176499
Fix issue state computation
Charles Lehner committed on 8/2/2016, 12:43:13 AMParent: c6fc57f70589db3b77746a523628b797dae2341f
Files changed
modules/git.js | changed |
modules/git.js | ||
---|---|---|
@@ -28,35 +28,23 @@ | ||
28 | 28 | } |
29 | 29 | |
30 | 30 | function getIssueState(id, cb) { |
31 | 31 | pull( |
32 | - sbot_links({dest: id, rel: 'issues', values: true}), | |
32 | + sbot_links({dest: id, rel: 'issues', values: true, reverse: true}), | |
33 | 33 | pull.map(function (msg) { |
34 | 34 | var issues = msg.value.content.issues |
35 | 35 | if (!Array.isArray(issues)) return |
36 | 36 | return issues.filter(function (issue) { |
37 | 37 | return issue.link === id |
38 | - }).map(function (issue) { | |
39 | - return { | |
40 | - ts: msg.value.timestamp, | |
41 | - open: issue.open, | |
42 | - merged: issue.merged, | |
43 | - } | |
44 | 38 | }) |
45 | 39 | }), |
46 | 40 | pull.flatten(), |
41 | + pull.map(function (issue) { | |
42 | + return issue.merged ? 'merged' : issue.open ? 'open' : 'closed' | |
43 | + }), | |
44 | + pull.take(1), | |
47 | 45 | pull.collect(function (err, updates) { |
48 | - if (err) return cb(err) | |
49 | - var open = true, merged = false | |
50 | - updates.sort(function (a, b) { | |
51 | - return b.ts - a.ts | |
52 | - }).forEach(function (update) { | |
53 | - if (update.open != null) | |
54 | - open = update.open | |
55 | - if (update.merged != null) | |
56 | - merged = update.merged | |
57 | - }) | |
58 | - cb(null, open ? 'open' : merged ? 'merged' : 'closed') | |
46 | + cb(err, updates && updates[0] || 'open') | |
59 | 47 | }) |
60 | 48 | ) |
61 | 49 | } |
62 | 50 |
Built with git-ssb-web