Socialmetrica/Socialmetrica.package/TwitterUser.class/instance/collectMessages.byTimeSpanSplits..st

15 lines
607 B
Smalltalk

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