Creating replies and retweets filtering and modifying histograms.

This commit is contained in:
ruidajo 2022-04-18 17:29:09 -05:00
parent bfa2a2ab99
commit 8d87ee3ed7
8 changed files with 64 additions and 6 deletions

View File

@ -0,0 +1,29 @@
accessing
exportRepliesHistogramWithBars: aNumberOfBars
| tweetsByTimeSpan subtotals repliesColor x tweetsHistogram diagram |
tweetsByTimeSpan := self collectMessages: [ self replies ] byTimeSpanSplits: aNumberOfBars.
subtotals := tweetsByTimeSpan values collect: [ :collection | collection size ].
repliesColor := (Color r:(246/255) g:(185/255) b:(46/255)).
x := 1 to: subtotals size.
tweetsHistogram := RSChart new.
tweetsHistogram extent: 800@200.
diagram := RSBarPlot new x: x y:subtotals.
diagram color: repliesColor.
tweetsHistogram addPlot: diagram.
tweetsHistogram addDecoration: (RSHorizontalTick new
fromNames: tweetsByTimeSpan keys;
labelRotation: 0;
fontSize: 80 /aNumberOfBars;
yourself).
tweetsHistogram addDecoration: (RSVerticalTick new
integer;
fontSize: 80 /aNumberOfBars).
tweetsHistogram build.
tweetsHistogram canvas pngExporter
zoomToShapes;
noFixedShapes;
fileName: (self folder / 'replies-histogram.png')fullName;
export.
^ self folder / 'replies-histogram.png'

View File

@ -21,9 +21,9 @@ exportTweetsHistogramWithBars: aNumberOfBars
integer; integer;
fontSize: 80 /aNumberOfBars). fontSize: 80 /aNumberOfBars).
tweetsHistogram build. tweetsHistogram build.
tweetsHistogram canvas pdfExporter tweetsHistogram canvas pngExporter
zoomToShapes; zoomToShapes;
noFixedShapes; noFixedShapes;
fileName: (self folder / 'trinos.pdf')fullName; fileName: (self folder / 'tweets-histogram.png')fullName;
export. export.
^ self folder / 'trinos.pdf' ^ self folder / 'tweets-histogram.png'

View File

@ -0,0 +1,7 @@
accessing
replies
self messages ifEmpty: [ self getMessages ].
^ TweetsCollection new
messages: (self messages messages select: [ :each | (each metadata at: 'replie to') isNotEmpty ]);
yourself

View File

@ -0,0 +1,7 @@
accessing
retweets
self messages ifEmpty: [ self getMessages ].
^ TweetsCollection new
messages: (self messages messages select: [ :each | each authorId ~= self id]);
yourself

View File

@ -1,6 +1,6 @@
accessing accessing
tweets tweets
self messages messages ifEmpty: [ self getMessages ]. self messages ifEmpty: [ self getMessages ].
^ TweetsCollection new ^ TweetsCollection new
messages: (self messages messages select: [ :each | each authorId = self id ]); messages: (self messages messages select: [ :each | each authorId = self id ]);
yourself yourself

View File

@ -1,4 +1,5 @@
accessing accessing
created created
(created endsWith: 'GMT') ifTrue: [ ^ DateAndTime fromString: ((created splitOn: $,) second withoutSuffix: 'GMT') ]. created class = DateAndTime ifTrue: [ ^ created ].
^ DateAndTime fromString: created ^ (created endsWith: 'GMT') ifTrue: [ ^ DateAndTime fromString: ((created splitOn: $,) second withoutSuffix: 'GMT') ].
"^ DateAndTime fromString: created"

View File

@ -0,0 +1,9 @@
accessing
ifEmpty: aBlock
"Evaluate the given block, answering its value if the receiver is empty, otherwise answer the receiver."
"Note that the fact that this method returns its receiver in case the receiver is not empty allows one to write expressions like the following ones: self classifyMethodAs: (myProtocol ifEmpty: ['As yet unclassified'])"
^ self isEmpty
ifTrue: [ aBlock value ]
ifFalse: [ self ]

View File

@ -0,0 +1,5 @@
accessing
isEmpty
"Answer whether the receiver contains any elements."
^self size = 0