Refactoring messages.

This commit is contained in:
ruidajo 2023-07-27 11:20:19 -05:00
parent 43662d3fce
commit 57186f444f
2 changed files with 15 additions and 8 deletions

View File

@ -0,0 +1,8 @@
accessing
configureDefaultReportingPeriod
[ config at: 'reportingPeriod' ]
onErrorDo: [ self config
at: 'reportingPeriod'
put: (Timespan
starting: messages oldest created asDateAndTime
ending: messages newest created asDateAndTime + 1 minute) ]

View File

@ -1,13 +1,12 @@
accessing accessing
messages messages
messages ifNil: [ messages := TweetsCollection new ]. messages ifNil: [ messages := TweetsCollection new ].
messages ifEmpty: [ self getLocalMessages ]. messages ifEmpty: [ self getLocalMessages ].
messages ifEmpty: [ self getRemoteMessagesFromHtml ]. messages ifEmpty: [ self getRemoteMessagesFromHtml ].
[ config at: 'reportingPeriod' ] config at: 'reportingPeriod' ifAbsent: [ ^ messages ].
onErrorDo: [ self config "self configureDefaultReportingPeriod."
at: 'reportingPeriod' ^ messages
put: (Timespan select: [ :message |
starting: (messages oldest created asDateAndTime) message created
ending: (messages newest created asDateAndTime + 1 minute)) ]. between: self reportingPeriod start
^ messages select: [ :message | message created between: self reportingPeriod start and: self reportingPeriod end ] and: self reportingPeriod end ]