Starting NitterInstance modelling.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2024-02-10 12:34:50 -05:00
parent 27a8a66dd3
commit abc2752292
11 changed files with 50 additions and 8 deletions

View File

@ -1,3 +0,0 @@
accessing
columnKeys
^ #('url' 'healthy' 'healthy_percentage_overall' 'rss' 'version')

View File

@ -0,0 +1,8 @@
accessing
columnsDictionary
^ {
'url' -> 'url' .
'healthy' -> 'healthy'.
'healthy_percentage_overall' -> 'uptime' .
'rss' -> 'rss' .
'version' -> 'version'} asDictionary

View File

@ -1,7 +1,8 @@
accessing accessing
instanceRows instanceRows
^ (self instances at: 'hosts') collect: [:rawRow | | newRow | ^ (self instances at: 'hosts') collect: [:rawRow | | newRow |
newRow := OrderedCollection new. newRow := NitterInstance new.
self columnKeys do: [:key | newRow add: (rawRow at: key) ]. self columnsDictionary keysAndValuesDo: [:key :value |
newRow writeSlotNamed: value value: (rawRow at: key) ].
newRow newRow
]. ].

View File

@ -1,4 +1,3 @@
accessing accessing
instances instances
^ self instancesCache
^ STONJSON fromString: 'https://status.d420.de/api/v1/instances' asUrl retrieveContents

View File

@ -0,0 +1,9 @@
accessing
instancesCache
| cache cacheFile |
cacheFile := FileLocator temp / 'nitter-instances.ston'.
cacheFile exists
ifFalse: [
cache := STON fromString: 'https://status.d420.de/api/v1/instances' asUrl retrieveContents.
MarkupFile exportAsFileOn: cacheFile containing: cache ].
^ STON fromString: cacheFile contents

View File

@ -11,6 +11,6 @@ viewInstancesFor: aView
columnNames doWithIndex: [:aName :index | columnNames doWithIndex: [:aName :index |
columnedList columnedList
column: aName column: aName
text: [:instanceRow | (instanceRow at: index) ifNil: [''] ] text: [:instanceRow | (instanceRow slots at: index) ifNil: [''] ]
]. ].
^ columnedList ^ columnedList

View File

@ -0,0 +1,5 @@
accessing
printOn: aStream
super printOn: aStream.
^ aStream
nextPutAll: '( ', self url ,' | uptime: ', self uptime asString, ' )'

View File

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

View File

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

View File

@ -0,0 +1,17 @@
{
"commentStamp" : "",
"super" : "Object",
"category" : "Socialmetrica",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"url",
"healthy",
"uptime",
"rss",
"version"
],
"name" : "NitterInstance",
"type" : "normal"
}