-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Feedbin stats section to daily packet
- Loading branch information
1 parent
18ef2bd
commit 4b490dd
Showing
11 changed files
with
84 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class FeedbinApi | ||
def self.generate_client | ||
endpoint_url = Monolithium.config.feedbin_endpoint_url | ||
password = Monolithium.config.feedbin_password | ||
username = Monolithium.config.feedbin_username | ||
return unless endpoint_url && password && username | ||
|
||
Faraday.new(url: endpoint_url) do |f| | ||
f.adapter Faraday.default_adapter | ||
f.request :authorization, :basic, username, password | ||
f.request :json | ||
f.response :json | ||
end | ||
end | ||
|
||
def self.client | ||
@client ||= generate_client | ||
end | ||
|
||
def self.get_unread_entries | ||
return unless client | ||
|
||
url = "/v2/unread_entries.json" | ||
response = client.get(url) | ||
response.body | ||
end | ||
|
||
def self.get_entry(entry_id) | ||
return unless client | ||
|
||
url = "/v2/entries/#{entry_id}.json" | ||
response = client.get(url) | ||
response.body | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class FeedbinStats | ||
def self.compute | ||
unread_entry_ids = FeedbinApi.get_unread_entries | ||
first_entry_id = unread_entry_ids.min | ||
oldest_entry = FeedbinApi.get_entry(first_entry_id) | ||
oldest_published_on = Date.parse(oldest_entry["published"]) | ||
oldest_ago = (Date.today - oldest_published_on).to_i | ||
[unread_entry_ids.count, oldest_ago] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pHjuU/ByM1jPqsmRZwCRgBfT5j7qznqc4t2j3zY+BzyKmQvWW+X09UNnlQXE0eJJ30g7KmMeTJ6pV7JibA7e2+CzYs+0ip3qnTyOkGNcdIom+V//vf5PoKk1KZ7UoxfV7sslSCOXnlDbjNfYhWYxT8OgHOQhQc/Z2jxeMasogzyxGi8kV4IcQpAH+QXmlqi3QjIsO4K1li2wCClaEQnZBHWSoy2Vz+1AZYo+Ug3LiGia4QRlpXUlJCNdit1rmoAIMfTZmVjsmu86N8PKMlu6zkhy/xOzyLDFglUW2Fy/ydL27JpwR9pAPN+ArkG+EF112m0NShhc9rQof1bvb8HlclxOFmwB0puAJJS/x6YfS9DORhE8h1jRu2ytP4C/gjTpYyPVFnaDp72UUnwkXD9ymIRTSok9pYGfvhqiRYURkMaRCWAcMDiaLfXpbaGMrJRAGL+5ZpSPmPCk1PQsD2PFSJHTOjzshrt3Zb0r/PYJrZ93BQczuMKv/9qU20KpdCQKOT/sGzOvUTD529uK/kiG472at4mFyE7YnwBOe3Xu3XPxf/DjxASiyWFRf+X6swsPX154KuueCVLssPaXS+ZCWB4WITWC9tP/VFwiQiycW/ma/Kds94urbg2z8EHmJ8nimhbvcXAQoxPsqCvWcRIUuQ6cMnRh/KJX8f79d5rHzmmqHCzQRUJOi+1rys2jVATOhwHNgdULc1j+nC101In1mzwH90HApLGiIfJr9+SqAWT/6QlQMhMPM5ahNS+E+k30LfxQan5moe6reMWbr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WaTw0JNATPkLrInKcy3VPxQ7V8pe0D5795w02itVuNG3sKWulPFsD7sh8/Q3RU5G2RMuF17ECIDiYBpJ+uQeIaw==--D5xacH6f7UnVOulj--5Z5Jka+gZTCWSlUZS1g3ig== |
6 changes: 6 additions & 0 deletions
6
db/migrate/20241103214523_add_feedbin_stats_to_daily_packets.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AddFeedbinStatsToDailyPackets < ActiveRecord::Migration[7.2] | ||
def change | ||
add_column :daily_packets, :feedbin_unread_count, :integer, null: false, default: 0 | ||
add_column :daily_packets, :feedbin_oldest_ago, :integer, null: false, default: 0 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters