-
Notifications
You must be signed in to change notification settings - Fork 18
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
Create vendor agnostic JSON format between issue data sources and consumers #74
Changes from all commits
75a0a4b
805346b
7c6a31f
001cdbe
96f051b
97e5247
ae04f4c
c6ede87
00bcff2
7fccf32
7bd4fe5
7b62762
36c2198
7530f5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,12 +30,12 @@ | |
<div class='card-flex'> | ||
<template is="dom-repeat" items="{{users}}" | ||
filter="filterUsers" sort="sortUsers" | ||
observe="data"> | ||
observe="issueList"> | ||
<paper-item> | ||
<paper-item-body two-line> | ||
<div>{{item.user}}</div> | ||
<!-- TODO(suzyh): convert to templatized HTML --> | ||
<div secondary inner-h-t-m-l="[[milestones(item.data, releases)]]" class='milestones'></div> | ||
<div secondary inner-h-t-m-l="[[milestones(item.issueList, releases)]]" class='milestones'></div> | ||
</paper-item-body> | ||
</paper-item> | ||
</template> | ||
|
@@ -61,26 +61,26 @@ | |
}, | ||
|
||
filterUsers(item) { | ||
if (item.data == undefined) | ||
if (item.issueList == undefined) | ||
return false; | ||
return (item.data.filter(a => a.M != undefined).length > 0); | ||
return (item.issueList.filter(a => a.M != undefined).length > 0); | ||
}, | ||
|
||
sortUsers(a, b) { | ||
if (a.data == undefined || b.data == undefined) | ||
if (a.issueList == undefined || b.issueList == undefined) | ||
return 0; | ||
var minMilestoneA = undefined | ||
for (var i = 0; i < a.data.length; i++) { | ||
var milestone = Number(a.data[i].M); | ||
for (var i = 0; i < a.issueList.length; i++) { | ||
var milestone = Number(a.issueList[i].M); | ||
if (milestone == 0) | ||
continue; | ||
if (minMilestoneA == undefined || milestone < minMilestoneA) | ||
minMilestoneA = milestone; | ||
} | ||
|
||
var minMilestoneB = undefined | ||
for (var i = 0; i < b.data.length; i++) { | ||
var milestone = Number(b.data[i].M); | ||
for (var i = 0; i < b.issueList.length; i++) { | ||
var milestone = Number(b.issueList[i].M); | ||
if (milestone == 0) | ||
continue; | ||
if (minMilestoneB == undefined || milestone < minMilestoneB) | ||
|
@@ -103,14 +103,14 @@ | |
}.bind(this)); | ||
}, | ||
|
||
milestones: function(data, releases) { | ||
milestones: function(issueList, releases) { | ||
var div = "<div style='color: white; border-radius: 4px; padding: 0px 6px;"; | ||
if (data == undefined) | ||
if (issueList == undefined) | ||
return "pending" | ||
var milestones = {}; | ||
data = data.filter(a => a.M); | ||
data.forEach(a => a.M = Number(a.M) ? Math.max(Number(a.M), releases.stable) : a.M); | ||
data.forEach(a => milestones[a.M] ? milestones[a.M]++ : milestones[a.M] = 1); | ||
issueList = issueList.filter(a => a.M); | ||
issueList.forEach(a => a.M = Number(a.M) ? Math.max(Number(a.M), releases.stable) : a.M); | ||
issueList.forEach(a => milestones[a.M] ? milestones[a.M]++ : milestones[a.M] = 1); | ||
var result = ""; | ||
var keys = Object.keys(milestones).sort(); | ||
for (var key of keys) { | ||
|
@@ -131,17 +131,16 @@ | |
usersChanged: function(users) { | ||
// TODO: this probably only works for all-or-nothing changes to users right now. | ||
users.forEach(function(user, idx) { | ||
registerSource('cz-issues', {owner: user.email}, function(data) { | ||
for (var i = 0; i < data.length; i++) { | ||
for (var j = 0; j < data[i].labels.length; j++) { | ||
var label = data[i].labels[j]; | ||
registerSource('cz-crbug-issues', {owner: user.email}, function(issueList) { | ||
for (var issue of issueList) { | ||
for (var label of issue.labels) { | ||
if (label.substring(0, 2).toLowerCase() == 'm-') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suspect this 'm-xx' label processing belongs in Issue.create as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. M doesn't really make sense for issues other than monorail, nor is it used by any other dash. I'd rather leave this behaviour scoped to this particular dash. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair call. |
||
data[i].M = label.substring(2); | ||
issue.M = label.substring(2); | ||
break; | ||
} | ||
} | ||
} | ||
this.set('users.' + idx + '.data', data); | ||
this.set('users.' + idx + '.issueList', issueList); | ||
}.bind(this)); | ||
}.bind(this)); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving the crbug-specific constructor into the issue library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issues-lib is supposed to be vendor agnostic code, I don't think it makes sense to put Crbug specific code in there. This function performs the transformation from Crbug issue data into generic issue data. Would you prefer it live in crbug-lib.js?