Skip to content

Commit 8eb747d

Browse files
committed
Add agent apps card
1 parent 7c6168b commit 8eb747d

File tree

3 files changed

+1078
-149
lines changed

3 files changed

+1078
-149
lines changed

app/models/rollups/daily_agent.rb

Lines changed: 33 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -1,154 +1,39 @@
11
class Rollups::DailyAgent < ActiveRecord::Base
22
establish_connection :clickhouse
33

4-
AGENT_TAGS = {
5-
0 => "Unknown",
6-
1 => "HermesPod",
7-
2 => "Acast",
8-
3 => "Alexa",
9-
4 => "AllYouCanBooks",
10-
5 => "AntennaPod",
11-
6 => "Breaker",
12-
7 => "Castaway",
13-
8 => "CastBox",
14-
9 => "Castro",
15-
10 => "Clementine",
16-
11 => "Downcast",
17-
12 => "iTunes",
18-
13 => "NPR One",
19-
14 => "Overcast",
20-
15 => "Player FM",
21-
16 => "Pocket Casts",
22-
17 => "Podbean",
23-
18 => "PodcastAddict",
24-
19 => "The Podcast App",
25-
20 => "Podkicker",
26-
21 => "RadioPublic",
27-
22 => "Sonos",
28-
23 => "Stitcher",
29-
24 => "Zune",
30-
25 => "Apple Podcasts",
31-
26 => "Internet Explorer",
32-
27 => "Safari",
33-
28 => "Firefox",
34-
29 => "Chrome",
35-
30 => "Facebook",
36-
31 => "Twitter",
37-
32 => "Apple News",
38-
33 => "BeyondPod",
39-
34 => "NetCast",
40-
35 => "Desktop App",
41-
36 => "Mobile App",
42-
37 => "Smart Home",
43-
38 => "Smart TV",
44-
39 => "Desktop Browser",
45-
40 => "Mobile Browser",
46-
41 => "Windows",
47-
42 => "Android",
48-
43 => "iOS",
49-
44 => "Amazon OS",
50-
45 => "macOS",
51-
46 => "BlackBerryOS",
52-
47 => "Windows Phone",
53-
48 => "ChromeOS",
54-
49 => "Linux",
55-
50 => "webOS",
56-
51 => "gPodder",
57-
52 => "iHeartRadio",
58-
53 => "Juice Receiver",
59-
54 => "Laughable",
60-
55 => "Windows Media Player",
61-
56 => "PodCruncher",
62-
57 => "PodTrapper",
63-
58 => "PodcastRepublic",
64-
59 => "TED",
65-
60 => "TuneIn",
66-
61 => "Winamp",
67-
62 => "Google Podcasts",
68-
63 => "RSSRadio",
69-
64 => "Roku",
70-
65 => "ServeStream",
71-
66 => "uTorrent",
72-
67 => "Google Home",
73-
68 => "Smart Watch",
74-
69 => "WatchOS",
75-
70 => "Himalaya",
76-
71 => "MediaMonkey",
77-
72 => "iCatcher",
78-
73 => "KPCC App",
79-
74 => "Sonos OS",
80-
75 => "Podbbang",
81-
76 => "HardCast",
82-
77 => "Spotify",
83-
78 => "AhaRadio",
84-
79 => "Bullhorn",
85-
80 => "CloudPlayer",
86-
81 => "English Radio IELTS TOEFL",
87-
82 => "Pandora",
88-
83 => "Procast",
89-
84 => "Treble.fm",
90-
85 => "WNYC App",
91-
86 => "Bose",
92-
87 => "myTuner",
93-
88 => "sodes",
94-
89 => "WBEZ App",
95-
90 => "Wilson FM",
96-
91 => "Luminary",
97-
92 => "Edge",
98-
93 => "DoggCatcher",
99-
94 => "Chromecast",
100-
95 => "Squeezebox",
101-
96 => "Spreaker",
102-
97 => "VictorReader",
103-
98 => "Podcoin",
104-
99 => "Castamatic",
105-
100 => "Deezer",
106-
101 => "Audiobooks",
107-
102 => "Hamro Patro",
108-
103 => "HondaLink",
109-
104 => "Hubhopper",
110-
105 => "Instacast",
111-
106 => "KERA App",
112-
107 => "Kids Listen",
113-
108 => "Kodi",
114-
109 => "MusicBee",
115-
110 => "Orange Radio",
116-
111 => "Outcast",
117-
112 => "Playapod",
118-
113 => "Plex",
119-
114 => "PRI App",
120-
115 => "WBUR App",
121-
116 => "Opera",
122-
117 => "This American Life",
123-
118 => "Podimo",
124-
119 => "BashPodder",
125-
120 => "Outlook",
126-
121 => "Amazon Fire TV",
127-
122 => "Podcast Guru",
128-
123 => "Xiaoyuzhou",
129-
124 => "Nvidia Shield",
130-
125 => "Sony Bravia",
131-
126 => "Amazon Music",
132-
127 => "TikTok",
133-
128 => "SiriusXM",
134-
129 => "iVoox",
135-
130 => "Audible",
136-
131 => "Airr",
137-
132 => "Podhero",
138-
133 => "MixerBox",
139-
134 => "Xbox",
140-
135 => "Samsung Free",
141-
136 => "Snipd",
142-
137 => "Telmate",
143-
138 => "castget",
144-
139 => "Newsboat",
145-
140 => "Anghami",
146-
141 => "VLC",
147-
142 => "PRX Play",
148-
143 => "mowPod"
149-
}.freeze
4+
LABELS =
5+
begin
6+
agents_lock_pathname = Rails.root.join("vendor/agents.lock.yml")
7+
if File.exist?(agents_lock_pathname)
8+
db = YAML.load_file(agents_lock_pathname)
9+
agent_codes = db["agents"]
10+
.map { |v| [v["os"], v["name"], v["type"]] }
11+
.flatten
12+
.compact
13+
.uniq
14+
agent_label_lookup = agent_codes.map { |code| [db["tags"][code], code] }.to_h
15+
agent_label_lookup.invert.freeze
16+
else
17+
message = "Missing the vendor/agents.lock.yml file from prx-podagents\n"
18+
message += "Agent labels will be mangled until you download it!!"
19+
Rails.logger.error(msg: message)
20+
{}
21+
end
22+
end
15023

151-
def label
152-
AGENT_TAGS[code]
24+
def self.label_for(code)
25+
LABELS[code.to_s] || unknown_code(code)
26+
end
27+
28+
def self.code_for(label)
29+
LABELS.key(label) || label
30+
end
31+
32+
def self.unknown_code(code)
33+
if code.blank? || code == 0
34+
"Unknown"
35+
else
36+
"Other"
37+
end
15338
end
15439
end

app/views/metrics/_agent_apps_card.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<ul class="list-group list-group-flush position-relative">
33
<% agents.map do |agent| %>
44
<li class="list-group-item d-flex justify-content-between">
5-
<span class="z-1"><%= agent.label %></span>
5+
<span class="z-1"><%= Rollups::DailyAgent.label_for(agent[:code]) %></span>
66
<span class="z-1"><%= number_with_delimiter(agent[:count]) || 0 %></span>
77
</li>
88
<% end %>

0 commit comments

Comments
 (0)