From c713ad9d28c9d3b0006a70b78a7b02dc23c5062c Mon Sep 17 00:00:00 2001 From: ruidajo Date: Wed, 1 Jun 2022 23:32:31 -0500 Subject: [PATCH] Modifying asDictionary for exporting as static web report. --- .../NitterUser.class/instance/asDictionary.st | 7 ++++-- .../instance/tweetsByWeeksTimeSpan.st | 24 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 Socialmetrica.package/NitterUser.class/instance/tweetsByWeeksTimeSpan.st diff --git a/Socialmetrica.package/NitterUser.class/instance/asDictionary.st b/Socialmetrica.package/NitterUser.class/instance/asDictionary.st index 86a5f99..f92d2c3 100644 --- a/Socialmetrica.package/NitterUser.class/instance/asDictionary.st +++ b/Socialmetrica.package/NitterUser.class/instance/asDictionary.st @@ -1,8 +1,9 @@ accessing asDictionary - | tweets | + | tweets tweetsHistogramData | tweets := self messages. + tweetsHistogramData := self tweetsByWeeksTimeSpan. ^ { 'profile-card-avatar' -> self profileImageFile fullName. 'profile-card-avatar-url' -> self profileImageUrl. 'profile-card-fullname' -> self name . @@ -10,5 +11,7 @@ asDictionary 'profile-bio' -> self profileBio. 'messages-size' -> tweets size. 'messages-newest' -> tweets newest created asDate greaseString. - 'messages-oldest' -> tweets oldest created asDate greaseString + 'messages-oldest' -> tweets oldest created asDate greaseString. + 'tweets-histogram-labels' -> tweetsHistogramData third. + 'tweets-histogram-quantity' -> tweetsHistogramData second. } asDictionary \ No newline at end of file diff --git a/Socialmetrica.package/NitterUser.class/instance/tweetsByWeeksTimeSpan.st b/Socialmetrica.package/NitterUser.class/instance/tweetsByWeeksTimeSpan.st new file mode 100644 index 0000000..9a84e68 --- /dev/null +++ b/Socialmetrica.package/NitterUser.class/instance/tweetsByWeeksTimeSpan.st @@ -0,0 +1,24 @@ +accessing +tweetsByWeeksTimeSpan + + | weeks floor divisions tweetsByTimeSpan xAxis labels | + weeks := ((self newestTweet created - self oldestTweet created) days / 7). + floor := weeks floor. + (weeks - floor) > 0.4 + ifTrue: [ divisions := floor ] + ifFalse: [ divisions := floor + 1 ]. + tweetsByTimeSpan := self collectMessages: [ self tweets] byTimeSpanSplits: divisions. + xAxis := OrderedCollection new. + (tweetsByTimeSpan values collect: [ :collection | collection size ]) do: [ :number | + xAxis add: ($' asString), (number asString), ($' asString) + ]. + labels := OrderedCollection new. + tweetsByTimeSpan keys do: [ :string | + labels add: ($' asString), string, ($' asString) + ]. + ^ { + tweetsByTimeSpan. + ('[', (',' join: xAxis), ']'). + ('[', (',' join: labels), ']'). + } + \ No newline at end of file