From 419aa176ab29275a4e84548af1382d27332b8063 Mon Sep 17 00:00:00 2001 From: ruidajo Date: Mon, 2 May 2022 22:31:41 -0500 Subject: [PATCH] Modifying date displays in histograms and fixing empty replies and quotes exporter. --- .../NitterUser.class/instance/createdAt.st | 1 + .../instance/exportQuotesHistogram.st | 11 +++++++++++ .../instance/exportRepliesHistogramWithBars..st | 13 ++++++++++++- .../instance/collectMessages.byTimeSpanSplits..st | 6 ++++-- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Socialmetrica.package/NitterUser.class/instance/createdAt.st b/Socialmetrica.package/NitterUser.class/instance/createdAt.st index 1dafde8..ab72b75 100644 --- a/Socialmetrica.package/NitterUser.class/instance/createdAt.st +++ b/Socialmetrica.package/NitterUser.class/instance/createdAt.st @@ -5,5 +5,6 @@ createdAt joinDateString := joinDateString copyReplaceAll: '3 May' with: '03 May'. joinDateString := joinDateString copyReplaceAll: '5 May' with: '05 May'. joinDateString := joinDateString copyReplaceAll: '2 Feb' with: '02 Feb'. + joinDateString := joinDateString copyReplaceAll: '6 Mar' with: '06 Mar'. createdAt := (ZTimestampFormat fromString:'4:05 PM - 03 Feb 2001') parse: joinDateString. ] \ No newline at end of file diff --git a/Socialmetrica.package/NitterUser.class/instance/exportQuotesHistogram.st b/Socialmetrica.package/NitterUser.class/instance/exportQuotesHistogram.st index fb3f10d..157435d 100644 --- a/Socialmetrica.package/NitterUser.class/instance/exportQuotesHistogram.st +++ b/Socialmetrica.package/NitterUser.class/instance/exportQuotesHistogram.st @@ -3,6 +3,17 @@ exportQuotesHistogram | quotesOccurrences labels diagram quotesHistogram | + self quotes ifEmpty: [ + quotesHistogram := RSChart new. + quotesHistogram extent: 800@200. + quotesHistogram build. + quotesHistogram canvas pdfExporter + zoomToShapes; + noFixedShapes; + fileName: (self folder / 'quotes-histogram.pdf')fullName; + export. + ^ self + ]. quotesOccurrences := self quotesSortedByOccurrences. labels := quotesOccurrences keys. labels := labels collect: [ :profiles | ('@', profiles) ]. diff --git a/Socialmetrica.package/NitterUser.class/instance/exportRepliesHistogramWithBars..st b/Socialmetrica.package/NitterUser.class/instance/exportRepliesHistogramWithBars..st index 2081562..0af4189 100644 --- a/Socialmetrica.package/NitterUser.class/instance/exportRepliesHistogramWithBars..st +++ b/Socialmetrica.package/NitterUser.class/instance/exportRepliesHistogramWithBars..st @@ -2,7 +2,18 @@ accessing exportRepliesHistogramWithBars: aNumberOfBars | tweetsByTimeSpan subtotals tweetsHistogram diagram | - + + self replies ifEmpty: [ + tweetsHistogram := RSChart new. + tweetsHistogram extent: 800@200. + tweetsHistogram build. + tweetsHistogram canvas pdfExporter + zoomToShapes; + noFixedShapes; + fileName: (self folder / 'replies-histogram.pdf')fullName; + export. + ^ self + ]. tweetsByTimeSpan := self collectMessages: [ self replies ] byTimeSpanSplits: aNumberOfBars. subtotals := tweetsByTimeSpan values collect: [ :collection | collection size ]. tweetsHistogram := RSChart new. diff --git a/Socialmetrica.package/TwitterUser.class/instance/collectMessages.byTimeSpanSplits..st b/Socialmetrica.package/TwitterUser.class/instance/collectMessages.byTimeSpanSplits..st index ab8739e..ccfb441 100644 --- a/Socialmetrica.package/TwitterUser.class/instance/collectMessages.byTimeSpanSplits..st +++ b/Socialmetrica.package/TwitterUser.class/instance/collectMessages.byTimeSpanSplits..st @@ -2,8 +2,10 @@ 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') + spanLabels := (timespans collect: [ :timeSpan | | start end | + start := (timeSpan start dayOfMonth) asString, ' ', ((timeSpan start monthName) asString copyFrom:1 to: 3). + end := (timeSpan end dayOfMonth) asString, ' ', ((timeSpan end monthName) asString copyFrom:1 to: 3). + start, '→ ', end ]) asArray. messagesByTimespan := OrderedDictionary new. spanLabels doWithIndex: [:label :i |