Skip to content

Commit 081ea20

Browse files
committed
Homepage redesign
1 parent 625730e commit 081ea20

File tree

9 files changed

+523
-3
lines changed

9 files changed

+523
-3
lines changed

assets/css/app.css

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,44 @@
11
@import "tailwindcss";
22
/* This file is for your main application CSS */
3+
4+
@theme {
5+
--color-gold-100: #fff8e1;
6+
--color-gold-200: #ffecb3;
7+
--color-gold-300: #ffe082;
8+
--color-gold-400: #ffd54f;
9+
--color-gold-500: #ffca28;
10+
--color-gold-600: #ffc107;
11+
--color-gold-700: #ffb300;
12+
--color-gold-800: #ffa000;
13+
--color-gold-900: #ff8f00;
14+
15+
--color-silver-100: #f4f4f5;
16+
--color-silver-200: #e4e4e7;
17+
--color-silver-300: #d4d4d8;
18+
--color-silver-400: #a1a1aa;
19+
--color-silver-500: #9ca3af;
20+
--color-silver-600: #71717a;
21+
--color-silver-700: #52525b;
22+
--color-silver-800: #3f3f46;
23+
--color-silver-900: #27272a;
24+
25+
--color-bronze-100: #fef1e8;
26+
--color-bronze-200: #f9dbc5;
27+
--color-bronze-300: #f4c4a2;
28+
--color-bronze-400: #efae80;
29+
--color-bronze-500: #cd7f32;
30+
--color-bronze-600: #b87333;
31+
--color-bronze-700: #a65e2e;
32+
--color-bronze-800: #8c4c25;
33+
--color-bronze-900: #703b1c;
34+
35+
--color-broken-100: #fee2e2;
36+
--color-broken-200: #fecaca;
37+
--color-broken-300: #fca5a5;
38+
--color-broken-400: #f87171;
39+
--color-broken-500: #ef4444;
40+
--color-broken-600: #dc2626;
41+
--color-broken-700: #b91c1c;
42+
--color-broken-800: #991b1b;
43+
--color-broken-900: #7f1d1d;
44+
}

lib/plexus/apps.ex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,18 @@ defmodule Plexus.Apps do
165165
end)
166166
end
167167

168+
@spec apps_available_count :: pos_integer()
169+
def apps_available_count do
170+
Repo.aggregate(App, :count)
171+
end
172+
173+
@spec apps_count_since(DateTime.t()) :: pos_integer()
174+
def apps_count_since(datetime) do
175+
App
176+
|> where([app], app.inserted_at >= ^datetime)
177+
|> Repo.aggregate(:count)
178+
end
179+
168180
@spec subscribe :: :ok
169181
def subscribe do
170182
Phoenix.PubSub.subscribe(Plexus.PubSub, "apps")

lib/plexus/ratings.ex

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,74 @@ defmodule Plexus.Ratings do
7474
|> broadcast(:rating_deleted)
7575
end
7676

77+
@spec ratings_submitted_count :: pos_integer()
78+
def ratings_submitted_count do
79+
Repo.aggregate(Rating, :count)
80+
end
81+
82+
@spec ratings_count_since(DateTime.t()) :: pos_integer()
83+
def ratings_count_since(datetime) do
84+
Rating
85+
|> where([rating], rating.inserted_at >= ^datetime)
86+
|> Repo.aggregate(:count)
87+
end
88+
89+
def gold_de_googled_count do
90+
Rating
91+
|> where([rating], rating.score >= 4)
92+
|> where([rating], rating.rating_type == :native)
93+
|> Repo.aggregate(:count)
94+
end
95+
96+
def gold_micro_g_count do
97+
Rating
98+
|> where([rating], rating.score >= 4)
99+
|> where([rating], rating.rating_type == :micro_g)
100+
|> Repo.aggregate(:count)
101+
end
102+
103+
def silver_de_googled_count do
104+
Rating
105+
|> where([rating], rating.score >= 3 and rating.score < 4)
106+
|> where([rating], rating.rating_type == :native)
107+
|> Repo.aggregate(:count)
108+
end
109+
110+
def silver_micro_g_count do
111+
Rating
112+
|> where([rating], rating.score >= 3 and rating.score < 4)
113+
|> where([rating], rating.rating_type == :micro_g)
114+
|> Repo.aggregate(:count)
115+
end
116+
117+
def bronze_de_googled_count do
118+
Rating
119+
|> where([rating], rating.score >= 2 and rating.score < 3)
120+
|> where([rating], rating.rating_type == :native)
121+
|> Repo.aggregate(:count)
122+
end
123+
124+
def bronze_micro_g_count do
125+
Rating
126+
|> where([rating], rating.score >= 2 and rating.score < 3)
127+
|> where([rating], rating.rating_type == :micro_g)
128+
|> Repo.aggregate(:count)
129+
end
130+
131+
def broken_de_googled_count do
132+
Rating
133+
|> where([rating], rating.score < 2)
134+
|> where([rating], rating.rating_type == :native)
135+
|> Repo.aggregate(:count)
136+
end
137+
138+
def broken_micro_g_count do
139+
Rating
140+
|> where([rating], rating.score < 2)
141+
|> where([rating], rating.rating_type == :micro_g)
142+
|> Repo.aggregate(:count)
143+
end
144+
77145
defp broadcast({:error, _reason} = error, _event), do: error
78146

79147
defp broadcast({:ok, rating}, event) do

lib/plexus_web/components/layouts/app.html.heex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
href="https://github.com/techlore/Plexus-app?tab=readme-ov-file#download"
1717
class="text-gray-100 bg-gray-900 rounded-md p-2 hover:bg-gray-900/90"
1818
>
19-
Download App
19+
Download
2020
</a>
2121
</div>
2222
</div>
@@ -74,7 +74,7 @@
7474
</a>
7575
</div>
7676
<p class="mt-10 text-center text-sm/6 text-gray-400">
77-
{Date.utc_today().year()} &copy; Techlore
77+
{Date.utc_today().year} &copy; Techlore
7878
</p>
7979
</div>
8080
</footer>

lib/plexus_web/controllers/sitemap_controller.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ defmodule PlexusWeb.SitemapController do
5757
defp change_freq("/swaggerui"), do: "yearly"
5858
defp change_freq(_), do: "weekly"
5959

60-
defp last_mod("/") do
60+
defp last_mod(path) when path in ["/", "/apps"] do
6161
Plexus.Apps.fetch_most_recently_added_app!()
6262
|> Map.fetch!(:inserted_at)
6363
|> DateTime.to_date()

lib/plexus_web/live/home_live.ex

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
11
defmodule PlexusWeb.HomeLive do
22
use PlexusWeb, :live_view
3+
4+
alias Plexus.Apps
5+
alias Plexus.Ratings
6+
7+
@impl Phoenix.LiveView
8+
def mount(_params, _session, socket) do
9+
{:ok,
10+
socket
11+
|> assign(:page_title, "Crowdsourced de-Googled Android apps status ratings")
12+
|> assign(:metrics, metrics())}
13+
end
14+
15+
defp metrics do
16+
one_week_ago = DateTime.add(DateTime.utc_now(), -7, :day)
17+
18+
%{
19+
apps_available: Apps.apps_available_count(),
20+
new_apps: Apps.apps_count_since(one_week_ago),
21+
ratings_submitted: Ratings.ratings_submitted_count(),
22+
new_ratings: Ratings.ratings_count_since(one_week_ago),
23+
gold_de_googled: Ratings.gold_de_googled_count(),
24+
gold_micro_g: Ratings.gold_micro_g_count(),
25+
silver_de_googled: Ratings.silver_de_googled_count(),
26+
silver_micro_g: Ratings.silver_micro_g_count(),
27+
bronze_de_googled: Ratings.bronze_de_googled_count(),
28+
bronze_micro_g: Ratings.bronze_micro_g_count(),
29+
broken_de_googled: Ratings.broken_de_googled_count(),
30+
broken_micro_g: Ratings.broken_micro_g_count()
31+
}
32+
end
333
end

0 commit comments

Comments
 (0)