From 0da5c06527833224ee82454070eb22a322fe4d96 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Fri, 15 Apr 2022 00:05:17 -0500 Subject: [PATCH] Initial methods for tweets histogram. --- .../Tweet.class/instance/belongsToSegment..st | 8 ++++++++ Socialmetrica.package/Tweet.class/instance/created.st | 2 +- .../TweetsCollection.class/instance/messages..st | 2 +- .../TweetsCollection.class/instance/messages.st | 2 +- .../TweetsCollection.class/instance/newest.st | 2 +- .../TweetsCollection.class/instance/pinned.st | 8 ++++++++ .../TweetsCollection.class/properties.json | 4 ++-- 7 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 Socialmetrica.package/Tweet.class/instance/belongsToSegment..st create mode 100644 Socialmetrica.package/TweetsCollection.class/instance/pinned.st diff --git a/Socialmetrica.package/Tweet.class/instance/belongsToSegment..st b/Socialmetrica.package/Tweet.class/instance/belongsToSegment..st new file mode 100644 index 0000000..1f1ca66 --- /dev/null +++ b/Socialmetrica.package/Tweet.class/instance/belongsToSegment..st @@ -0,0 +1,8 @@ +accessing +belongsToSegment: segmentBodersCollection + + segmentBodersCollection allButLast keysAndValuesDo: [ :i :elem | + (elem < self created and: [ self created <= (segmentBodersCollection at: i + 1) ]) + ifTrue: [ ^ i ] + ]. + ^ false \ No newline at end of file diff --git a/Socialmetrica.package/Tweet.class/instance/created.st b/Socialmetrica.package/Tweet.class/instance/created.st index dd73b5c..20b588b 100644 --- a/Socialmetrica.package/Tweet.class/instance/created.st +++ b/Socialmetrica.package/Tweet.class/instance/created.st @@ -1,3 +1,3 @@ accessing created - ^ created \ No newline at end of file + ^ created ifNotNil: [ ^ ZTimestamp fromString: created ] \ No newline at end of file diff --git a/Socialmetrica.package/TweetsCollection.class/instance/messages..st b/Socialmetrica.package/TweetsCollection.class/instance/messages..st index bcb1b20..aa324df 100644 --- a/Socialmetrica.package/TweetsCollection.class/instance/messages..st +++ b/Socialmetrica.package/TweetsCollection.class/instance/messages..st @@ -1,3 +1,3 @@ accessing messages: aTweetsCollection - ^ tweets := aTweetsCollection \ No newline at end of file + ^ messages := aTweetsCollection \ No newline at end of file diff --git a/Socialmetrica.package/TweetsCollection.class/instance/messages.st b/Socialmetrica.package/TweetsCollection.class/instance/messages.st index 55dcb18..0943f57 100644 --- a/Socialmetrica.package/TweetsCollection.class/instance/messages.st +++ b/Socialmetrica.package/TweetsCollection.class/instance/messages.st @@ -1,3 +1,3 @@ accessing messages - ^ tweets ifNil: [ tweets := OrderedCollection new] \ No newline at end of file + ^ messages ifNil: [ messages := OrderedCollection new ] \ No newline at end of file diff --git a/Socialmetrica.package/TweetsCollection.class/instance/newest.st b/Socialmetrica.package/TweetsCollection.class/instance/newest.st index c54134c..3a8e529 100644 --- a/Socialmetrica.package/TweetsCollection.class/instance/newest.st +++ b/Socialmetrica.package/TweetsCollection.class/instance/newest.st @@ -1,7 +1,7 @@ accessing newest self messages ifNil: [ ^ nil ]. - self messages ifNilEmpty: [ ^ nil ]. + self messages ifEmpty: [ ^ nil ]. self pinned created > self messages second created ifTrue: [ ^ self pinned ] ifFalse: [ ^ self messages second ] \ No newline at end of file diff --git a/Socialmetrica.package/TweetsCollection.class/instance/pinned.st b/Socialmetrica.package/TweetsCollection.class/instance/pinned.st new file mode 100644 index 0000000..232412f --- /dev/null +++ b/Socialmetrica.package/TweetsCollection.class/instance/pinned.st @@ -0,0 +1,8 @@ +accessing +pinned + | first second | + first := self messages first. + (first metadata at: 'pinned') = 1 + ifFalse: [ ^ first ]. + second := self messages second. + ^ first created \ No newline at end of file diff --git a/Socialmetrica.package/TweetsCollection.class/properties.json b/Socialmetrica.package/TweetsCollection.class/properties.json index d31a7b1..9a11b85 100644 --- a/Socialmetrica.package/TweetsCollection.class/properties.json +++ b/Socialmetrica.package/TweetsCollection.class/properties.json @@ -6,8 +6,8 @@ "pools" : [ ], "classvars" : [ ], "instvars" : [ - "tweets", - "query" + "query", + "messages" ], "name" : "TweetsCollection", "type" : "normal"