From d8d7dd4339b686a17c00756fa15259d0a0ddee43 Mon Sep 17 00:00:00 2001 From: Daniel Sitnik Date: Thu, 14 Nov 2024 00:23:52 -0300 Subject: [PATCH 1/4] new app: bluesky stats --- blueskystats/README.md | 40 ++++++++ blueskystats/bluesky_stats.star | 158 ++++++++++++++++++++++++++++++++ blueskystats/manifest.yaml | 6 ++ 3 files changed, 204 insertions(+) create mode 100644 blueskystats/README.md create mode 100644 blueskystats/bluesky_stats.star create mode 100644 blueskystats/manifest.yaml diff --git a/blueskystats/README.md b/blueskystats/README.md new file mode 100644 index 000000000..6bed004e9 --- /dev/null +++ b/blueskystats/README.md @@ -0,0 +1,40 @@ +# Bluesky Stats + +## Overview + +This is a simple app that displays statistics from [Bluesky](https://bsky.social/) such as the total number of users. + +Statistics are gathered from the website https://bsky.jazco.dev/stats. + +--- + +## Configuration (Schema) + +The app supports some configuration options like selecting the statistic you want to view, the color to use for the numbers, and an option to use dots instead of commas as thousands separator. + +The supported statistics are: + +- total users +- total posts +- total follows +- total likes + +--- + +## API Details + +There is a single and unauthenticated API used: https://bsky-search.jazco.io/stats. + +We are not sure if there is any kind of rate limiting implemented, but results are cached for 15 minutes using the http module native caching mechanism. + +--- + +## Error Handling + +The app has safeguards in place to identify potential errors and always display something on the screen. For instance, a non 200 response from the API will be handled and a message will be shown on the screen. + +--- + +## Future Improvements + +There's nothing much left to add here. The API returns more data like the `daily_data` field which could be used to render some charts. diff --git a/blueskystats/bluesky_stats.star b/blueskystats/bluesky_stats.star new file mode 100644 index 000000000..7a9fd7763 --- /dev/null +++ b/blueskystats/bluesky_stats.star @@ -0,0 +1,158 @@ +""" +Applet: Bluesky Stats +Summary: Display Bluesky statistics +Description: Display Bluesky statistics like the total number of users. Data courtesy of https://bsky.jazco.dev/stats. +Author: Daniel Sitnik +""" + +load("encoding/base64.star", "base64") +load("http.star", "http") +load("humanize.star", "humanize") +load("render.star", "render") +load("schema.star", "schema") + +DEFAULT_STAT = "total_users" +DEFAULT_STAT_COLOR = "#3a83f7" +DEFAULT_DOT_SEPARATOR = False +CACHE_TTL = 900 +BSKY_LOGO = base64.decode(""" +iVBORw0KGgoAAAANSUhEUgAAACYAAAAhCAYAAAC1ONkWAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAhGVYSWZNTQAqAAAACAAFARIAAwAAAAEAAQAAARoABQAAAAEAAABKARsABQAAAAEAAABSASgAAwAAAAEAAgAAh2kABAAAAAEAAABaAAAAAAAAAEgAAAABAAAASAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAJqADAAQAAAABAAAAIQAAAADF6JFIAAAACXBIWXMAAAsTAAALEwEAmpwYAAACNGlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MTA2MDwvZXhpZjpQaXhlbFlEaW1lbnNpb24+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4xMjAwPC9leGlmOlBpeGVsWERpbWVuc2lvbj4KICAgICAgICAgPGV4aWY6Q29sb3JTcGFjZT4xPC9leGlmOkNvbG9yU3BhY2U+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAg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+mMMMQrEJDZt0FZSx86FkeQa16WkyOZ26zpN6ScwcrnOUp33d2IjZ0lqRr+dvEhudttxe+WWp/DkGNF0z9/6lXTJDTicy1BPLo3wEw419P2G0/CuiV3yY6PiSph6j7GHwi8U9BwmZjJyDUi9BbgCfgTBGeAjvCOAf5TJyq1GivlBQnzYBlGOUYe6mJfmXGAUdTZ+m5jLkSKFxh7jCIU/hiS/O/QO6WXqKrc5n+rC0f/N9NPytemQyNJfgGr61jyvN6XU3QifnXWl+S8sdEuwDWfJ619hymLHOSHM0wAAAABJRU5ErkJggg== +""") + +def main(config): + """Main app method. + + Args: + config (config): App configuration. + + Returns: + render.Root: Root widget tree. + """ + + stat = config.str("stat", DEFAULT_STAT) + number_color = config.str("number_color", DEFAULT_STAT_COLOR) + dot_separator = config.bool("dot_separator", DEFAULT_DOT_SEPARATOR) + + # get data + res = http.get("https://bsky-search.jazco.io/stats", ttl_seconds = CACHE_TTL) + + # handle errors + if res.status_code != 200: + print("API error %d: %s" % (res.status_code, res.body())) + return render_api_error(str(int(res.status_code))) + + # transform to json + data = res.json() + + # get humanized (comma separator) stat value + stat_value = humanize.comma(int(data[stat])) + + # build stat name (just removes "total_" from the stat variables) + stat_name = stat.replace("total_", "") + + # check and reformat to use dot separator + if dot_separator: + stat_value = stat_value.replace(",", ".") + + # render display + return render.Root( + child = render.Box( + color = "#000000", + child = render.Column( + main_align = "space_evenly", + cross_align = "center", + expanded = True, + children = [ + render.Row( + expanded = True, + main_align = "center", + cross_align = "center", + children = [ + render.Image(src = BSKY_LOGO, height = 10), + render.Box(width = 2, height = 1, color = "#000000"), + render.Text("Bluesky", font = "Dina_r400-6"), + ], + ), + render.Text(stat_value, color = number_color), + render.Text(stat_name, color = "#afbac7", font = "tom-thumb"), + ], + ), + ), + ) + +def get_schema(): + """Creates the schema for the configuration screen. + + Returns: + schema.Schema: The schema for the configuration screen. + """ + + stats = [ + schema.Option(display = "Total Users", value = DEFAULT_STAT), + schema.Option(display = "Total Posts", value = "total_posts"), + schema.Option(display = "Total Follows", value = "total_follows"), + schema.Option(display = "Total Likes", value = "total_likes"), + ] + + return schema.Schema( + version = "1", + fields = [ + schema.Dropdown( + id = "stat", + name = "Statistic", + desc = "Select the statistic you want to view.", + icon = "hashtag", + options = stats, + default = stats[0].value, + ), + schema.Color( + id = "number_color", + name = "Number color", + desc = "The color of the statistic number.", + icon = "brush", + default = DEFAULT_STAT_COLOR, + palette = [DEFAULT_STAT_COLOR], + ), + schema.Toggle( + id = "dot_separator", + name = "Dot separator", + desc = "Use dot as thousands separator.", + icon = "circleDot", + default = DEFAULT_DOT_SEPARATOR, + ), + ], + ) + +def render_api_error(status_code): + """Renders a view when there's an API error. + + Args: + status_code (str): The http status code of the error. + + Returns: + render.Root: Root widget tree. + """ + return render.Root( + child = render.Box( + color = "#000000", + child = render.Column( + main_align = "space_evenly", + cross_align = "center", + expanded = True, + children = [ + render.Row( + expanded = True, + main_align = "center", + cross_align = "center", + children = [ + render.Image(src = BSKY_LOGO, height = 10), + render.Box(width = 2, height = 1, color = "#000000"), + render.Text("Bluesky", font = "Dina_r400-6"), + ], + ), + render.Text("API ERROR", color = "#ff0000"), + render.Text("CODE %d" % status_code, color = "#ffff00"), + ], + ), + ), + ) diff --git a/blueskystats/manifest.yaml b/blueskystats/manifest.yaml new file mode 100644 index 000000000..53a40494d --- /dev/null +++ b/blueskystats/manifest.yaml @@ -0,0 +1,6 @@ +--- +id: bluesky-stats +name: Bluesky Stats +summary: Display Bluesky statistics +desc: Display Bluesky statistics like the total number of users. Data courtesy of https://bsky.jazco.dev/stats. +author: Daniel Sitnik From cf0efc63cd22c0d1c39dd19489226647c9e46a0c Mon Sep 17 00:00:00 2001 From: Daniel Sitnik Date: Thu, 14 Nov 2024 18:17:32 -0300 Subject: [PATCH 2/4] refactor to bluesky users only --- blueskystats/README.md | 40 --------- blueskystats/manifest.yaml | 6 -- blueskyusers/README.md | 35 ++++++++ .../bluesky_users.star | 82 +++++++++++-------- blueskyusers/manifest.yaml | 6 ++ 5 files changed, 91 insertions(+), 78 deletions(-) delete mode 100644 blueskystats/README.md delete mode 100644 blueskystats/manifest.yaml create mode 100644 blueskyusers/README.md rename blueskystats/bluesky_stats.star => blueskyusers/bluesky_users.star (77%) create mode 100644 blueskyusers/manifest.yaml diff --git a/blueskystats/README.md b/blueskystats/README.md deleted file mode 100644 index 6bed004e9..000000000 --- a/blueskystats/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# Bluesky Stats - -## Overview - -This is a simple app that displays statistics from [Bluesky](https://bsky.social/) such as the total number of users. - -Statistics are gathered from the website https://bsky.jazco.dev/stats. - ---- - -## Configuration (Schema) - -The app supports some configuration options like selecting the statistic you want to view, the color to use for the numbers, and an option to use dots instead of commas as thousands separator. - -The supported statistics are: - -- total users -- total posts -- total follows -- total likes - ---- - -## API Details - -There is a single and unauthenticated API used: https://bsky-search.jazco.io/stats. - -We are not sure if there is any kind of rate limiting implemented, but results are cached for 15 minutes using the http module native caching mechanism. - ---- - -## Error Handling - -The app has safeguards in place to identify potential errors and always display something on the screen. For instance, a non 200 response from the API will be handled and a message will be shown on the screen. - ---- - -## Future Improvements - -There's nothing much left to add here. The API returns more data like the `daily_data` field which could be used to render some charts. diff --git a/blueskystats/manifest.yaml b/blueskystats/manifest.yaml deleted file mode 100644 index 53a40494d..000000000 --- a/blueskystats/manifest.yaml +++ /dev/null @@ -1,6 +0,0 @@ ---- -id: bluesky-stats -name: Bluesky Stats -summary: Display Bluesky statistics -desc: Display Bluesky statistics like the total number of users. Data courtesy of https://bsky.jazco.dev/stats. -author: Daniel Sitnik diff --git a/blueskyusers/README.md b/blueskyusers/README.md new file mode 100644 index 000000000..26cbb190e --- /dev/null +++ b/blueskyusers/README.md @@ -0,0 +1,35 @@ +# Bluesky Users + +## Overview + +This is a simple app that displays the total number of users on the [Bluesky](https://bsky.social/) social network. + +Data is gathered from the website https://bsky-users.theo.io. + +The app displays an animation of the user count increasing, according to a growth rate returned from the aforementioned website. + +--- + +## Configuration (Schema) + +The app supports some configuration options like changing the user count color and using dots instead of commas as thousands separator. + +--- + +## API Details + +There is a single and unauthenticated API being used: https://bsky-users.theo.io/api/stats. + +We are not sure if there is any kind of rate limiting implemented, but results are cached for 15 minutes using the http module native caching mechanism. + +--- + +## Error Handling + +The app has safeguards in place to identify potential errors and always display something on the screen. For instance, a non 200 response from the API will be handled and a message will be shown on the screen. + +--- + +## Future Improvements + +There's nothing left to add here since the API only returns the user count and the growth rate. diff --git a/blueskystats/bluesky_stats.star b/blueskyusers/bluesky_users.star similarity index 77% rename from blueskystats/bluesky_stats.star rename to blueskyusers/bluesky_users.star index 7a9fd7763..62af163a3 100644 --- a/blueskystats/bluesky_stats.star +++ b/blueskyusers/bluesky_users.star @@ -1,17 +1,17 @@ """ -Applet: Bluesky Stats -Summary: Display Bluesky statistics -Description: Display Bluesky statistics like the total number of users. Data courtesy of https://bsky.jazco.dev/stats. +Applet: Bluesky Users +Summary: Display Bluesky user count +Description: Display the total number of users on the Bluesky social network. Data courtesy of https://bsky-users.theo.io. Author: Daniel Sitnik """ load("encoding/base64.star", "base64") load("http.star", "http") load("humanize.star", "humanize") +load("math.star", "math") load("render.star", "render") load("schema.star", "schema") -DEFAULT_STAT = "total_users" DEFAULT_STAT_COLOR = "#3a83f7" DEFAULT_DOT_SEPARATOR = False CACHE_TTL = 900 @@ -29,12 +29,12 @@ def main(config): render.Root: Root widget tree. """ - stat = config.str("stat", DEFAULT_STAT) + # read config values number_color = config.str("number_color", DEFAULT_STAT_COLOR) dot_separator = config.bool("dot_separator", DEFAULT_DOT_SEPARATOR) # get data - res = http.get("https://bsky-search.jazco.io/stats", ttl_seconds = CACHE_TTL) + res = http.get("https://bsky-users.theo.io/api/stats", ttl_seconds = CACHE_TTL) # handle errors if res.status_code != 200: @@ -44,18 +44,19 @@ def main(config): # transform to json data = res.json() - # get humanized (comma separator) stat value - stat_value = humanize.comma(int(data[stat])) + # read data properties + user_count = data["last_user_count"] + growth_per_second = math.ceil(data["growth_per_second"]) - # build stat name (just removes "total_" from the stat variables) - stat_name = stat.replace("total_", "") + # render frames to represent user count increase + frames = render_frames(user_count, growth_per_second, number_color, dot_separator) - # check and reformat to use dot separator - if dot_separator: - stat_value = stat_value.replace(",", ".") + # calculate frame delay to display all frames in 15 seconds + delay = math.ceil(15000 / len(frames)) # render display return render.Root( + delay = delay, child = render.Box( color = "#000000", child = render.Column( @@ -73,13 +74,45 @@ def main(config): render.Text("Bluesky", font = "Dina_r400-6"), ], ), - render.Text(stat_value, color = number_color), - render.Text(stat_name, color = "#afbac7", font = "tom-thumb"), + render.Animation( + children = frames, + ), + render.Text("users", color = "#afbac7", font = "tom-thumb"), ], ), ), ) +def render_frames(user_count, growth_per_second, number_color, dot_separator): + """Renders the frames for a animation representing the user count increase. + + Args: + user_count (int): Current number of users. + growth_per_second (float): User growth rate per second. + number_color (str): Color used to format the user count number. + dot_separator (bool): Indicates if dot should be used as thousands separator. + + Returns: + list: List of frames. + """ + frames = [] + + # calculates how many users we would have after 15 seconds with the current growth rate + last_user_count = int(user_count + growth_per_second * 15) + + # diff between final and current count + count_diff = int(last_user_count - user_count) + + # create frames + for _ in range(count_diff): + frame_text = humanize.comma(int(user_count)) + if dot_separator: + frame_text = frame_text.replace(",", ".") + frames.append(render.Text(frame_text, color = number_color)) + user_count += 1 + + return frames + def get_schema(): """Creates the schema for the configuration screen. @@ -87,28 +120,13 @@ def get_schema(): schema.Schema: The schema for the configuration screen. """ - stats = [ - schema.Option(display = "Total Users", value = DEFAULT_STAT), - schema.Option(display = "Total Posts", value = "total_posts"), - schema.Option(display = "Total Follows", value = "total_follows"), - schema.Option(display = "Total Likes", value = "total_likes"), - ] - return schema.Schema( version = "1", fields = [ - schema.Dropdown( - id = "stat", - name = "Statistic", - desc = "Select the statistic you want to view.", - icon = "hashtag", - options = stats, - default = stats[0].value, - ), schema.Color( id = "number_color", name = "Number color", - desc = "The color of the statistic number.", + desc = "The color of the user count number.", icon = "brush", default = DEFAULT_STAT_COLOR, palette = [DEFAULT_STAT_COLOR], @@ -116,7 +134,7 @@ def get_schema(): schema.Toggle( id = "dot_separator", name = "Dot separator", - desc = "Use dot as thousands separator.", + desc = "Use dots as thousands separator.", icon = "circleDot", default = DEFAULT_DOT_SEPARATOR, ), diff --git a/blueskyusers/manifest.yaml b/blueskyusers/manifest.yaml new file mode 100644 index 000000000..0d4a1e9d8 --- /dev/null +++ b/blueskyusers/manifest.yaml @@ -0,0 +1,6 @@ +--- +id: bluesky-users +name: Bluesky Users +summary: Display Bluesky user count +desc: Display the total number of users on the Bluesky social network. Data courtesy of https://bsky-users.theo.io. +author: Daniel Sitnik From def7a23d893a6873b54cf74857ea74c5f442c090 Mon Sep 17 00:00:00 2001 From: Daniel Sitnik Date: Fri, 15 Nov 2024 13:27:58 -0300 Subject: [PATCH 3/4] add animation when users reach a millionth --- blueskyusers/bluesky_users.star | 47 +++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/blueskyusers/bluesky_users.star b/blueskyusers/bluesky_users.star index 62af163a3..8cf9a6e9b 100644 --- a/blueskyusers/bluesky_users.star +++ b/blueskyusers/bluesky_users.star @@ -105,21 +105,58 @@ def render_frames(user_count, growth_per_second, number_color, dot_separator): # create frames for _ in range(count_diff): - frame_text = humanize.comma(int(user_count)) - if dot_separator: - frame_text = frame_text.replace(",", ".") - frames.append(render.Text(frame_text, color = number_color)) + # check if user count has reached another million + if user_count % 1000000 != 0: + # most likely not, so just render the number + frame_text = humanize.comma(int(user_count)) + if dot_separator: + frame_text = frame_text.replace(",", ".") + frames.append(render.Text(frame_text, color = number_color)) + else: + # reached another million, render frames for a nice flashing animation! + frames += render_million(user_count, number_color, dot_separator) user_count += 1 return frames +def render_million(user_count, number_color, dot_separator): + """Renders colored frames to show that the user count has reached another million. + + Args: + user_count (int): Current number of users. + number_color (str): Color used to format the user count number. + dot_separator (bool): Indicates if dot should be used as thousands separator. + + Returns: + list: List of frames. + """ + frames = [] + + frame_text = humanize.comma(int(user_count)) + if dot_separator: + frame_text = frame_text.replace(",", ".") + + # add more frames with rainbow colors + for _ in range(8): + frames.append(render.Text(frame_text, color = number_color)) + frames.append(render.Text(frame_text, color = "#ffffff")) + frames.append(render.Text(frame_text, color = "#ff0000")) + frames.append(render.Text(frame_text, color = "#ff7f00")) + frames.append(render.Text(frame_text, color = "#ffff00")) + frames.append(render.Text(frame_text, color = "#00ff00")) + frames.append(render.Text(frame_text, color = "#0000ff")) + frames.append(render.Text(frame_text, color = "#4b0082")) + frames.append(render.Text(frame_text, color = "#9400d3")) + frames.append(render.Text(frame_text, color = number_color)) + + return frames + def get_schema(): """Creates the schema for the configuration screen. Returns: schema.Schema: The schema for the configuration screen. """ - return schema.Schema( version = "1", fields = [ From 6ea7ed0c22f4d4c4100fdfa3719e20a8717c3f97 Mon Sep 17 00:00:00 2001 From: Daniel Sitnik Date: Mon, 18 Nov 2024 10:13:27 -0300 Subject: [PATCH 4/4] lower cache to 2 minutes --- blueskyusers/bluesky_users.star | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blueskyusers/bluesky_users.star b/blueskyusers/bluesky_users.star index 8cf9a6e9b..76999ff9b 100644 --- a/blueskyusers/bluesky_users.star +++ b/blueskyusers/bluesky_users.star @@ -14,7 +14,7 @@ load("schema.star", "schema") DEFAULT_STAT_COLOR = "#3a83f7" DEFAULT_DOT_SEPARATOR = False -CACHE_TTL = 900 +CACHE_TTL = 120 BSKY_LOGO = base64.decode(""" iVBORw0KGgoAAAANSUhEUgAAACYAAAAhCAYAAAC1ONkWAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAhGVYSWZNTQAqAAAACAAFARIAAwAAAAEAAQAAARoABQAAAAEAAABKARsABQAAAAEAAABSASgAAwAAAAEAAgAAh2kABAAAAAEAAABaAAAAAAAAAEgAAAABAAAASAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAA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