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

15 lines
607 B
Smalltalk
Raw Permalink Normal View History

2022-04-16 17:08:30 +00:00
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