Code review: More modular code.
This commit is contained in:
parent
5d457e824a
commit
50a3ef901b
@ -1,17 +1,10 @@
|
||||
accessing
|
||||
exportTweetsHistogramWithBars: aNumberOfBars
|
||||
|
||||
| timeSpans labels tweetsByTimeSpan subtotals tweetsColor x tweetsHistogram diagram |
|
||||
timeSpans := self tweets timeSpansOf: aNumberOfBars.
|
||||
labels := (timeSpans collect: [ :timeSpan |
|
||||
((timeSpan start asDate asString removeSuffix: '2022'), '→ ', timeSpan end asDate asString removeSuffix: '2022')
|
||||
]) asArray.
|
||||
tweetsByTimeSpan := OrderedCollection new.
|
||||
1 to: labels size do: [ :i |
|
||||
tweetsByTimeSpan add: (self tweets messages select: [ :tweet |
|
||||
(timeSpans at: i) includes: (tweet created asDateAndTime)])
|
||||
].
|
||||
subtotals := tweetsByTimeSpan collect: [ :collection | collection size ].
|
||||
| tweetsByTimeSpan subtotals tweetsColor x tweetsHistogram diagram |
|
||||
|
||||
tweetsByTimeSpan := self collectMessages: [ self tweets] byTimeSpanSplits: aNumberOfBars.
|
||||
subtotals := tweetsByTimeSpan values collect: [ :collection | collection size ].
|
||||
tweetsColor := (Color r:(91/255) g:(131/255) b:(222/255)).
|
||||
x := 1 to: subtotals size.
|
||||
tweetsHistogram := RSChart new.
|
||||
@ -20,7 +13,7 @@ exportTweetsHistogramWithBars: aNumberOfBars
|
||||
diagram color: tweetsColor.
|
||||
tweetsHistogram addPlot: diagram.
|
||||
tweetsHistogram addDecoration: (RSHorizontalTick new
|
||||
fromNames: labels;
|
||||
fromNames: tweetsByTimeSpan keys;
|
||||
labelRotation: 0;
|
||||
fontSize: 80 /aNumberOfBars;
|
||||
yourself).
|
||||
|
@ -0,0 +1,15 @@
|
||||
accessing
|
||||
collectMessages: aBlock byTimeSpanSplits: anInteger
|
||||
| timespans spanLabels messagesByTimespan |
|
||||
timespans := aBlock value timeSpansOf: anInteger.
|
||||
spanLabels := (timespans collect: [ :timeSpan |
|
||||
((timeSpan start asDate greaseString removeSuffix: '2022'), '→ ', timeSpan end asDate greaseString removeSuffix: '2022')
|
||||
]) asArray.
|
||||
messagesByTimespan := OrderedDictionary new.
|
||||
spanLabels doWithIndex: [:label :i |
|
||||
messagesByTimespan
|
||||
at: label
|
||||
put: (aBlock value messages select: [ :message |
|
||||
(timespans at: i) includes: (message created asDateAndTime)])
|
||||
].
|
||||
^ messagesByTimespan
|
Loading…
Reference in New Issue
Block a user