Twitter user now includes tweets. Improvements on data collection and presentation.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2021-08-19 22:43:03 -05:00
parent e045592827
commit 907deb5752
15 changed files with 54 additions and 30 deletions

View File

@ -1,12 +0,0 @@
accessing
gtUsersMentioning: userName On: aView
<gtView>
^ aView columnedList
title: 'Users mentioning @',userName translated;
priority: 5;
items: [ self usersMentioning: userName ];
column: 'Imagen'
icon: [ :aTwitterUser | aTwitterUser profileImage asElement asScalableElement size: 32 @ 32 ]
width: 75;
column: 'User Name' text: [ :aTwitterUser | aTwitterUser userName ];
column: 'Name' text: [ :aTwitterUser | aTwitterUser name ]

View File

@ -2,6 +2,7 @@ accessing
userEndPointFor: username selecting: tweetsOrMentions
"I build a shared URL for querying last 100 mentions or tweets for a particular user.
Second parameter should be only 'tweets' or 'mentions', dateString, if present, should be YYYY-MM-DD."
| commonQueryParameters |
commonQueryParameters := '?expansions=author_id&tweet.fields=conversation_id,created_at&user.fields=username,name,profile_image_url&max_results=100'.
| commonQueryParameters userFields |
userFields := 'user.fields=username,name,description,profile_image_url'.
commonQueryParameters := '?expansions=author_id&tweet.fields=conversation_id,created_at&', userFields, '&max_results=100'.
^ self usersBaseEndPoint, (self userIDFrom: username), '/', tweetsOrMentions, commonQueryParameters

View File

@ -0,0 +1,5 @@
accessing
usersGroupMentioning: userName
^ TwitterUsersGroup new
users: (self usersMentioning: userName);
title: 'Users mentioning @', userName

View File

@ -1,6 +1,12 @@
accessing
messagesAuthors
| groupedTweets |
self includes at: 'users' ifAbsent: [ ^ nil ].
^ (self includes at: 'users') collect: [:userDict |
TwitterUser new fromDictionary: userDict
groupedTweets := self data groupedBy: [:each | each at: 'author_id' ].
^ (self includes at: 'users') collect: [:userDict | | user |
user := TwitterUser new fromDictionary: userDict.
(groupedTweets at: (user id)) do: [:tweetDict |
user tweets add: (Tweet new fromDictionary: tweetDict)
].
user.
]

View File

@ -0,0 +1,3 @@
accessing
description
^ description

View File

@ -3,4 +3,5 @@ fromDictionary: userDict
id := userDict at: 'id'.
name := userDict at: 'name'.
userName := userDict at: 'username'.
profileImageUrl := userDict at: 'profile_image_url'.
profileImageUrl := userDict at: 'profile_image_url'.
description := userDict at: 'description'.

View File

@ -9,6 +9,7 @@ gtViewContactDetailsOn: aView
details := String streamContents: [:aStream |
aStream nextPutAll: self name.
aStream cr.
aStream nextPutAll: self description.
].
container := BlElement new

View File

@ -0,0 +1,3 @@
accessing
id
^ id

View File

@ -0,0 +1,3 @@
accessing
metrics: aDictionary
metrics := aDictionary

View File

@ -0,0 +1,3 @@
accessing
metrics
^ metrics ifNil: [ metrics := Dictionary new]

View File

@ -0,0 +1,3 @@
accessing
tweets: aTweetsCollection
tweets := aTweetsCollection

View File

@ -0,0 +1,3 @@
accessing
tweets
^ tweets ifNil: [ tweets := OrderedCollection new]

View File

@ -9,7 +9,10 @@
"id",
"name",
"userName",
"profileImageUrl"
"profileImageUrl",
"description",
"metrics",
"tweets"
],
"name" : "TwitterUser",
"type" : "normal"

View File

@ -0,0 +1,13 @@
accessing
gtTwitterUsersGroupOn: aView
<gtView>
^ aView columnedList
title: self title translated;
priority: 5;
items: [ self users ];
column: 'Imagen'
icon: [ :aTwitterUser | aTwitterUser profileImage asElement asScalableElement size: 32 @ 32 ]
width: 75;
column: 'User Name' text: [ :aTwitterUser | '@', aTwitterUser userName ];
column: 'Name' text: [ :aTwitterUser | aTwitterUser name ];
column: 'Mentions' text: [ :aTwitterUser | aTwitterUser tweets size asString ]

View File

@ -1,12 +0,0 @@
accessing
gtUsersMentioningOn: aView
<gtView>
^ aView columnedList
title: self title translated;
priority: 5;
items: [ self users ];
column: 'Imagen'
icon: [ :aTwitterUser | aTwitterUser profileImage asElement asScalableElement size: 32 @ 32 ]
width: 75;
column: 'User Name' text: [ :aTwitterUser | aTwitterUser userName ];
column: 'Name' text: [ :aTwitterUser | aTwitterUser name ]