Render human readable times and some more INTRADASTING information about pull requests

This commit is contained in:
R. Tyler Croy 2012-04-12 21:32:07 -07:00
parent 55feacab47
commit 949ec1cee7
6 changed files with 250 additions and 8 deletions

View File

@ -1,4 +1,78 @@
smalltalk.addPackage('Despair-UI', {});
smalltalk.addClass('PullRequestTile', smalltalk.Widget, ['pull', 'minutesOld'], 'Despair-UI');
smalltalk.addMethod(
unescape('_withPull_'),
smalltalk.method({
selector: unescape('withPull%3A'),
fn: function (aPullRequest){
var self=this;
(self['@pull']=aPullRequest);
return self;}
}),
smalltalk.PullRequestTile);
smalltalk.addMethod(
unescape('_renderOn_'),
smalltalk.method({
selector: unescape('renderOn%3A'),
fn: function (html){
var self=this;
(function($rec){smalltalk.send($rec, "_class_", [smalltalk.send("pull_request_tile sadness_", "__comma", [smalltalk.send(smalltalk.send(self, "_sadness", []), "_asString", [])])]);return smalltalk.send($rec, "_with_", [(function(){smalltalk.send(smalltalk.send(html, "_strong", []), "_with_", [smalltalk.send(self['@pull'], "_title", [])]);smalltalk.send(html, "_br", []);smalltalk.send(html, "_with_", [smalltalk.send("Last updated: ", "__comma", [smalltalk.send(self, "_lastUpdated", [])])]);smalltalk.send(html, "_br", []);return smalltalk.send(html, "_with_", [smalltalk.send(self, "_sadness", [])]);})]);})(smalltalk.send(html, "_div", []));
return self;}
}),
smalltalk.PullRequestTile);
smalltalk.addMethod(
unescape('_lastUpdated'),
smalltalk.method({
selector: unescape('lastUpdated'),
fn: function (){
var self=this;
try{var now=nil;
var then=nil;
var delta=nil;
var places=nil;
(places=(1));
(now=smalltalk.send(smalltalk.send((smalltalk.Date || Date), "_now", []), "_time", []));
(then=smalltalk.send(smalltalk.send(self['@pull'], "_updatedAt", []), "_time", []));
(delta=((($receiver = ((($receiver = now).klass === smalltalk.Number) ? $receiver -then : smalltalk.send($receiver, "__minus", [then]))).klass === smalltalk.Number) ? $receiver /(1000) : smalltalk.send($receiver, "__slash", [(1000)])));
(self['@minutesOld']=((($receiver = delta).klass === smalltalk.Number) ? $receiver /(60) : smalltalk.send($receiver, "__slash", [(60)])));
((($receiver = ((($receiver = delta).klass === smalltalk.Number) ? $receiver >(86400) : smalltalk.send($receiver, "__gt", [(86400)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (function(){throw({name: 'stReturn', selector: '_lastUpdated', fn: function(){return smalltalk.send(smalltalk.send(((($receiver = delta).klass === smalltalk.Number) ? $receiver /(86400) : smalltalk.send($receiver, "__slash", [(86400)])), "_printShowingDecimalPlaces_", [places]), "__comma", [" days ago"])}})})();})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return (function(){throw({name: 'stReturn', selector: '_lastUpdated', fn: function(){return smalltalk.send(smalltalk.send(((($receiver = delta).klass === smalltalk.Number) ? $receiver /(86400) : smalltalk.send($receiver, "__slash", [(86400)])), "_printShowingDecimalPlaces_", [places]), "__comma", [" days ago"])}})})();})]));
(function(){throw({name: 'stReturn', selector: '_lastUpdated', fn: function(){return smalltalk.send(smalltalk.send(self['@minutesOld'], "_printShowingDecimalPlaces_", [places]), "__comma", [" minutes ago"])}})})();
return self;
} catch(e) {if(e.name === 'stReturn' && e.selector === '_lastUpdated'){return e.fn()} throw(e)}}
}),
smalltalk.PullRequestTile);
smalltalk.addMethod(
unescape('_sadness'),
smalltalk.method({
selector: unescape('sadness'),
fn: function (){
var self=this;
try{((($receiver = ((($receiver = self['@minutesOld']).klass === smalltalk.Number) ? $receiver >(1440) * (60) : smalltalk.send($receiver, "__gt", [(1440) * (60)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("veryhigh")}})})();})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return (function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("veryhigh")}})})();})]));
((($receiver = ((($receiver = self['@minutesOld']).klass === smalltalk.Number) ? $receiver >(1440) * (14) : smalltalk.send($receiver, "__gt", [(1440) * (14)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("high")}})})();})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return (function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("high")}})})();})]));
((($receiver = ((($receiver = self['@minutesOld']).klass === smalltalk.Number) ? $receiver >(1440) * (5) : smalltalk.send($receiver, "__gt", [(1440) * (5)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("medium")}})})();})() : (function(){return (function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("low")}})})();})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return (function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("medium")}})})();}), (function(){return (function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("low")}})})();})]));
(function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("bug")}})})();
return self;
} catch(e) {if(e.name === 'stReturn' && e.selector === '_sadness'){return e.fn()} throw(e)}}
}),
smalltalk.PullRequestTile);
smalltalk.addMethod(
unescape('_initialize'),
smalltalk.method({
selector: unescape('initialize'),
fn: function (){
var self=this;
smalltalk.send(self, "_initialize", [], smalltalk.Widget);
(self['@minutesOld']=(0));
return self;}
}),
smalltalk.PullRequestTile);
smalltalk.addClass('Project', smalltalk.Widget, ['repo', 'pulls'], 'Despair-UI');
smalltalk.addMethod(
unescape('_initialize'),
@ -30,6 +104,7 @@ selector: unescape('renderOn%3A'),
fn: function (html){
var self=this;
smalltalk.send(html, "_with_", [self['@repo']]);
(function($rec){smalltalk.send($rec, "_id_", [self['@repo']]);smalltalk.send($rec, "_class_", ["project_tile"]);return smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(self['@pulls'], "_do_", [(function(pull){return (function($rec){smalltalk.send($rec, "_withPull_", [pull]);return smalltalk.send($rec, "_renderOn_", [html]);})(smalltalk.send((smalltalk.PullRequestTile || PullRequestTile), "_new", []));})]);})]);})(smalltalk.send(html, "_div", []));
smalltalk.send(html, "_br", []);
return self;}
}),

View File

@ -1,4 +1,103 @@
smalltalk.addPackage('Despair-UI', {});
smalltalk.addClass('PullRequestTile', smalltalk.Widget, ['pull', 'minutesOld'], 'Despair-UI');
smalltalk.addMethod(
unescape('_withPull_'),
smalltalk.method({
selector: unescape('withPull%3A'),
category: 'initializers',
fn: function (aPullRequest){
var self=this;
(self['@pull']=aPullRequest);
return self;},
args: ["aPullRequest"],
source: unescape('withPull%3A%20aPullRequest%0A%09pull%20%3A%3D%20aPullRequest.'),
messageSends: [],
referencedClasses: []
}),
smalltalk.PullRequestTile);
smalltalk.addMethod(
unescape('_renderOn_'),
smalltalk.method({
selector: unescape('renderOn%3A'),
category: 'rendering',
fn: function (html){
var self=this;
(function($rec){smalltalk.send($rec, "_class_", [smalltalk.send("pull_request_tile sadness_", "__comma", [smalltalk.send(smalltalk.send(self, "_sadness", []), "_asString", [])])]);return smalltalk.send($rec, "_with_", [(function(){smalltalk.send(smalltalk.send(html, "_strong", []), "_with_", [smalltalk.send(self['@pull'], "_title", [])]);smalltalk.send(html, "_br", []);smalltalk.send(html, "_with_", [smalltalk.send("Last updated: ", "__comma", [smalltalk.send(self, "_lastUpdated", [])])]);smalltalk.send(html, "_br", []);return smalltalk.send(html, "_with_", [smalltalk.send(self, "_sadness", [])]);})]);})(smalltalk.send(html, "_div", []));
return self;},
args: ["html"],
source: unescape('renderOn%3A%20html%0A%09html%20div%0A%09%09class%3A%20%27pull_request_tile%20sadness_%27%2C%20%28self%20sadness%20asString%29%3B%0A%09%09with%3A%20%5B%0A%09%09%09html%20strong%20with%3A%20%28pull%20title%29.%0A%09%09%09html%20br.%0A%09%09%09html%20with%3A%20%27Last%20updated%3A%20%27%2C%20self%20lastUpdated.%0A%09%09%09html%20br.%0A%09%09%09html%20with%3A%20%28self%20sadness%29.%0A%09%5D.'),
messageSends: ["class:", unescape("%2C"), "asString", "sadness", "with:", "strong", "title", "br", "lastUpdated", "div"],
referencedClasses: []
}),
smalltalk.PullRequestTile);
smalltalk.addMethod(
unescape('_lastUpdated'),
smalltalk.method({
selector: unescape('lastUpdated'),
category: 'rendering',
fn: function (){
var self=this;
try{var now=nil;
var then=nil;
var delta=nil;
var places=nil;
(places=(1));
(now=smalltalk.send(smalltalk.send((smalltalk.Date || Date), "_now", []), "_time", []));
(then=smalltalk.send(smalltalk.send(self['@pull'], "_updatedAt", []), "_time", []));
(delta=((($receiver = ((($receiver = now).klass === smalltalk.Number) ? $receiver -then : smalltalk.send($receiver, "__minus", [then]))).klass === smalltalk.Number) ? $receiver /(1000) : smalltalk.send($receiver, "__slash", [(1000)])));
(self['@minutesOld']=((($receiver = delta).klass === smalltalk.Number) ? $receiver /(60) : smalltalk.send($receiver, "__slash", [(60)])));
((($receiver = ((($receiver = delta).klass === smalltalk.Number) ? $receiver >(86400) : smalltalk.send($receiver, "__gt", [(86400)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (function(){throw({name: 'stReturn', selector: '_lastUpdated', fn: function(){return smalltalk.send(smalltalk.send(((($receiver = delta).klass === smalltalk.Number) ? $receiver /(86400) : smalltalk.send($receiver, "__slash", [(86400)])), "_printShowingDecimalPlaces_", [places]), "__comma", [" days ago"])}})})();})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return (function(){throw({name: 'stReturn', selector: '_lastUpdated', fn: function(){return smalltalk.send(smalltalk.send(((($receiver = delta).klass === smalltalk.Number) ? $receiver /(86400) : smalltalk.send($receiver, "__slash", [(86400)])), "_printShowingDecimalPlaces_", [places]), "__comma", [" days ago"])}})})();})]));
(function(){throw({name: 'stReturn', selector: '_lastUpdated', fn: function(){return smalltalk.send(smalltalk.send(self['@minutesOld'], "_printShowingDecimalPlaces_", [places]), "__comma", [" minutes ago"])}})})();
return self;
} catch(e) {if(e.name === 'stReturn' && e.selector === '_lastUpdated'){return e.fn()} throw(e)}},
args: [],
source: unescape('lastUpdated%0A%09%7C%20now%20then%20delta%20places%7C%0A%09places%20%3A%3D%201.%20%22Only%20print%20out%20to%201%20decimal%20places%20in%20our%20deltas%22%0A%09now%20%3A%3D%20Date%20now%20time.%0A%09then%20%3A%3D%20pull%20updatedAt%20time.%0A%09%22Stupid%20JavaScript%20gives%20you%20microseconds%2C%20just%20to%20be%20a%20pain%20in%20the%20ass%22%0A%09delta%20%3A%3D%20%28%28now%20-%20then%29%20/%201000%29.%20%22Turn%20this%20into%20seconds%22%0A%0A%09minutesOld%20%3A%3D%20%28delta%20/%2060%29.%0A%0A%09delta%20%3E%2086400%20ifTrue%3A%20%5B%20%5E%20%28%28delta%20/%2086400%29%20printShowingDecimalPlaces%3A%20places%29%2C%20%27%20days%20ago%27%20%5D.%0A%09%0A%09%5E%20%28minutesOld%20printShowingDecimalPlaces%3A%20places%29%2C%20%27%20minutes%20ago%27.'),
messageSends: ["time", "now", "updatedAt", unescape("/"), unescape("-"), "ifTrue:", unescape("%3E"), unescape("%2C"), "printShowingDecimalPlaces:"],
referencedClasses: ["Date"]
}),
smalltalk.PullRequestTile);
smalltalk.addMethod(
unescape('_sadness'),
smalltalk.method({
selector: unescape('sadness'),
category: 'rendering',
fn: function (){
var self=this;
try{((($receiver = ((($receiver = self['@minutesOld']).klass === smalltalk.Number) ? $receiver >(1440) * (60) : smalltalk.send($receiver, "__gt", [(1440) * (60)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("veryhigh")}})})();})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return (function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("veryhigh")}})})();})]));
((($receiver = ((($receiver = self['@minutesOld']).klass === smalltalk.Number) ? $receiver >(1440) * (14) : smalltalk.send($receiver, "__gt", [(1440) * (14)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("high")}})})();})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return (function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("high")}})})();})]));
((($receiver = ((($receiver = self['@minutesOld']).klass === smalltalk.Number) ? $receiver >(1440) * (5) : smalltalk.send($receiver, "__gt", [(1440) * (5)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return (function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("medium")}})})();})() : (function(){return (function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("low")}})})();})()) : smalltalk.send($receiver, "_ifTrue_ifFalse_", [(function(){return (function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("medium")}})})();}), (function(){return (function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("low")}})})();})]));
(function(){throw({name: 'stReturn', selector: '_sadness', fn: function(){return smalltalk.symbolFor("bug")}})})();
return self;
} catch(e) {if(e.name === 'stReturn' && e.selector === '_sadness'){return e.fn()} throw(e)}},
args: [],
source: unescape('sadness%0A%09%22%20More%20than%20two%20months%20old%20and%20we%27ll%20be%20super%20pissed%22%0A%09minutesOld%20%3E%20%281440%20*%2060%29%20ifTrue%3A%20%5B%20%5E%20%23veryhigh%20%5D.%0A%0A%09%22%20More%20than%20two%20weeks%20old%2C%20we%27ll%20be%20highly%20saddened%20%22%0A%09minutesOld%20%3E%20%281440%20*%2014%29%20ifTrue%3A%20%5B%20%5E%20%23high%20%5D.%0A%0A%09%22%20If%20our%20pull%20request%20is%20more%20than%20five%20days%20old%2C%20we%27ll%20be%20medium%20sad%20%22%0A%09minutesOld%20%3E%20%281440%20*%205%29%0A%09%09ifTrue%3A%20%5B%20%5E%20%23medium%20%5D%0A%09%09ifFalse%3A%20%5B%20%5E%20%23low%20%5D.%0A%0A%09%5E%20%23bug.'),
messageSends: ["ifTrue:", unescape("%3E"), unescape("*"), "ifTrue:ifFalse:"],
referencedClasses: []
}),
smalltalk.PullRequestTile);
smalltalk.addMethod(
unescape('_initialize'),
smalltalk.method({
selector: unescape('initialize'),
category: 'initializers',
fn: function (){
var self=this;
smalltalk.send(self, "_initialize", [], smalltalk.Widget);
(self['@minutesOld']=(0));
return self;},
args: [],
source: unescape('initialize%0A%09super%20initialize.%0A%09minutesOld%20%3A%3D%200.'),
messageSends: ["initialize"],
referencedClasses: []
}),
smalltalk.PullRequestTile);
smalltalk.addClass('Project', smalltalk.Widget, ['repo', 'pulls'], 'Despair-UI');
smalltalk.addMethod(
unescape('_initialize'),
@ -41,12 +140,13 @@ category: 'rendering',
fn: function (html){
var self=this;
smalltalk.send(html, "_with_", [self['@repo']]);
(function($rec){smalltalk.send($rec, "_id_", [self['@repo']]);smalltalk.send($rec, "_class_", ["project_tile"]);return smalltalk.send($rec, "_with_", [(function(){return smalltalk.send(self['@pulls'], "_do_", [(function(pull){return (function($rec){smalltalk.send($rec, "_withPull_", [pull]);return smalltalk.send($rec, "_renderOn_", [html]);})(smalltalk.send((smalltalk.PullRequestTile || PullRequestTile), "_new", []));})]);})]);})(smalltalk.send(html, "_div", []));
smalltalk.send(html, "_br", []);
return self;},
args: ["html"],
source: unescape('renderOn%3A%20html%0A%09html%20with%3A%20repo.%0A%09html%20br.'),
messageSends: ["with:", "br"],
referencedClasses: []
source: unescape('renderOn%3A%20html%0A%09html%20with%3A%20repo.%0A%09html%20div%0A%09%09id%3A%20repo%3B%0A%09%09class%3A%20%27project_tile%27%3B%0A%09%09with%3A%20%5B%0A%09%09%09pulls%20do%3A%20%5B%20%3Apull%20%7C%0A%09%09%09%09PullRequestTile%20new%20withPull%3A%20pull%3B%20renderOn%3A%20html.%0A%09%09%5D%0A%09%5D.%0A%09html%20br.'),
messageSends: ["with:", "id:", "class:", "do:", "withPull:", "renderOn:", "new", "div", "br"],
referencedClasses: ["PullRequestTile"]
}),
smalltalk.Project);

View File

@ -32,7 +32,7 @@ smalltalk.method({
selector: unescape('loadPullRequests'),
fn: function (){
var self=this;
smalltalk.send(smalltalk.send(self['@repos'], "_keys", []), "_do_", [(function(repo){var fullname=nil;
smalltalk.send(smalltalk.send(smalltalk.send(self['@repos'], "_keys", []), "_reversed", []), "_do_", [(function(repo){var fullname=nil;
(fullname=smalltalk.send(smalltalk.send(self['@username'], "__comma", [unescape("/")]), "__comma", [repo]));return smalltalk.send((smalltalk.PullRequest || PullRequest), "_fetchFor_withEachDo_finally_", [fullname, (function(pull){var stack=nil;
(stack=smalltalk.send(self['@repos'], "_at_ifAbsent_", [repo, (function(){return nil;})]));return (($receiver = stack) != nil && $receiver != undefined) ? (function(){return smalltalk.send(stack, "_add_", [pull]);})() : nil;}), (function(){var stack=nil;
(stack=smalltalk.send(self['@repos'], "_at_ifAbsent_", [repo, (function(){return nil;})]));return ((($receiver = ((($receiver = smalltalk.send(stack, "_size", [])).klass === smalltalk.Number) ? $receiver >(0) : smalltalk.send($receiver, "__gt", [(0)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_activateRepo_", [repo]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self, "_activateRepo_", [repo]);})]));})]);})]);

View File

@ -43,14 +43,14 @@ selector: unescape('loadPullRequests'),
category: 'actions',
fn: function (){
var self=this;
smalltalk.send(smalltalk.send(self['@repos'], "_keys", []), "_do_", [(function(repo){var fullname=nil;
smalltalk.send(smalltalk.send(smalltalk.send(self['@repos'], "_keys", []), "_reversed", []), "_do_", [(function(repo){var fullname=nil;
(fullname=smalltalk.send(smalltalk.send(self['@username'], "__comma", [unescape("/")]), "__comma", [repo]));return smalltalk.send((smalltalk.PullRequest || PullRequest), "_fetchFor_withEachDo_finally_", [fullname, (function(pull){var stack=nil;
(stack=smalltalk.send(self['@repos'], "_at_ifAbsent_", [repo, (function(){return nil;})]));return (($receiver = stack) != nil && $receiver != undefined) ? (function(){return smalltalk.send(stack, "_add_", [pull]);})() : nil;}), (function(){var stack=nil;
(stack=smalltalk.send(self['@repos'], "_at_ifAbsent_", [repo, (function(){return nil;})]));return ((($receiver = ((($receiver = smalltalk.send(stack, "_size", [])).klass === smalltalk.Number) ? $receiver >(0) : smalltalk.send($receiver, "__gt", [(0)]))).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(self, "_activateRepo_", [repo]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(self, "_activateRepo_", [repo]);})]));})]);})]);
return self;},
args: [],
source: unescape('loadPullRequests%0A%09repos%20keys%20do%3A%20%5B%20%3Arepo%20%7C%0A%09%09%7C%20fullname%20%7C%0A%09%09fullname%20%3A%3D%20username%2C%20%27/%27%2C%20repo.%0A%09%09PullRequest%20fetchFor%3A%20fullname%0A%09%09%09withEachDo%3A%20%5B%20%3Apull%20%7C%0A%09%09%09%09%7C%20stack%20%7C%0A%09%09%09%09stack%20%3A%3D%20%28repos%20at%3A%20repo%20ifAbsent%3A%20%5Bnil%5D%29.%0A%09%09%09%09stack%20ifNotNil%3A%20%5B%20stack%20add%3A%20pull%20%5D.%0A%09%09%09%5D%0A%09%09%09finally%3A%20%5B%0A%09%09%09%09%7C%20stack%20%7C%0A%09%09%09%09stack%20%3A%3D%20%28repos%20at%3A%20repo%20ifAbsent%3A%20%5B%5D%29.%0A%09%09%09%09%28stack%20size%29%20%3E%200%20ifTrue%3A%20%5B%20self%20activateRepo%3A%20repo%20%5D.%0A%09%09%09%5D%0A%09%5D.'),
messageSends: ["do:", "keys", unescape("%2C"), "fetchFor:withEachDo:finally:", "at:ifAbsent:", "ifNotNil:", "add:", "ifTrue:", unescape("%3E"), "size", "activateRepo:"],
source: unescape('loadPullRequests%0A%09repos%20keys%20reversed%20do%3A%20%5B%20%3Arepo%20%7C%0A%09%09%7C%20fullname%20%7C%0A%09%09fullname%20%3A%3D%20username%2C%20%27/%27%2C%20repo.%0A%09%09PullRequest%20fetchFor%3A%20fullname%0A%09%09%09withEachDo%3A%20%5B%20%3Apull%20%7C%0A%09%09%09%09%7C%20stack%20%7C%0A%09%09%09%09stack%20%3A%3D%20%28repos%20at%3A%20repo%20ifAbsent%3A%20%5Bnil%5D%29.%0A%09%09%09%09stack%20ifNotNil%3A%20%5B%20stack%20add%3A%20pull%20%5D.%0A%09%09%09%5D%0A%09%09%09finally%3A%20%5B%0A%09%09%09%09%7C%20stack%20%7C%0A%09%09%09%09stack%20%3A%3D%20%28repos%20at%3A%20repo%20ifAbsent%3A%20%5B%5D%29.%0A%09%09%09%09%28stack%20size%29%20%3E%200%20ifTrue%3A%20%5B%20self%20activateRepo%3A%20repo%20%5D.%0A%09%09%09%5D%0A%09%5D.'),
messageSends: ["do:", "reversed", "keys", unescape("%2C"), "fetchFor:withEachDo:finally:", "at:ifAbsent:", "ifNotNil:", "add:", "ifTrue:", unescape("%3E"), "size", "activateRepo:"],
referencedClasses: ["PullRequest"]
}),
smalltalk.DespairApp);

View File

@ -1,4 +1,63 @@
Smalltalk current createPackage: 'Despair-UI' properties: #{}!
Widget subclass: #PullRequestTile
instanceVariableNames: 'pull minutesOld'
category: 'Despair-UI'!
!PullRequestTile methodsFor: 'initializers'!
withPull: aPullRequest
pull := aPullRequest.
!
initialize
super initialize.
minutesOld := 0.
! !
!PullRequestTile methodsFor: 'rendering'!
renderOn: html
html div
class: 'pull_request_tile sadness_', (self sadness asString);
with: [
html strong with: (pull title).
html br.
html with: 'Last updated: ', self lastUpdated.
html br.
html with: (self sadness).
].
!
lastUpdated
| now then delta places|
places := 1. "Only print out to 1 decimal places in our deltas"
now := Date now time.
then := pull updatedAt time.
"Stupid JavaScript gives you microseconds, just to be a pain in the ass"
delta := ((now - then) / 1000). "Turn this into seconds"
minutesOld := (delta / 60).
delta > 86400 ifTrue: [ ^ ((delta / 86400) printShowingDecimalPlaces: places), ' days ago' ].
^ (minutesOld printShowingDecimalPlaces: places), ' minutes ago'.
!
sadness
" More than two months old and we'll be super pissed"
minutesOld > (1440 * 60) ifTrue: [ ^ #veryhigh ].
" More than two weeks old, we'll be highly saddened "
minutesOld > (1440 * 14) ifTrue: [ ^ #high ].
" If our pull request is more than five days old, we'll be medium sad "
minutesOld > (1440 * 5)
ifTrue: [ ^ #medium ]
ifFalse: [ ^ #low ].
^ #bug.
! !
Widget subclass: #Project
instanceVariableNames: 'repo pulls'
category: 'Despair-UI'!
@ -19,6 +78,14 @@ withRepo: aRepo andPullRequests: anArrayOfRequests
renderOn: html
html with: repo.
html div
id: repo;
class: 'project_tile';
with: [
pulls do: [ :pull |
PullRequestTile new withPull: pull; renderOn: html.
]
].
html br.
! !

View File

@ -12,7 +12,7 @@ activeRepos
!DespairApp methodsFor: 'actions'!
loadPullRequests
repos keys do: [ :repo |
repos keys reversed do: [ :repo |
| fullname |
fullname := username, '/', repo.
PullRequest fetchFor: fullname