Skip to content

Commit c05138b

Browse files
committed
feat: Add top rated section to explore page
1 parent fe83227 commit c05138b

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<section class="p-strip is-shallow u-no-padding--bottom">
22
<div class="u-fixed-width">
3-
<h2>Most popular snaps</h2>
3+
<h2>{{ title }}</h2>
44
</div>
55
</section>
66
<section class="p-strip is-shallow u-no-padding--bottom">
77
<div class="row">
8-
{% for snap in popular_snaps %}
8+
{% for snap in snaps_list %}
99
{% if loop.index <= 8 %}
1010
<div class="col-3">
1111
<p class="p-heading--4" style="float: left; margin-right: 1rem">{{ loop.index }}</p>

templates/explore/index.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,21 @@ <h1 class="p-heading--2">The app store for Linux</h1>
2727
{% endif %}
2828

2929
{% if popular_snaps %}
30-
{% include "explore/_popular-snaps.html" %}
30+
{% with snaps_list = popular_snaps, title = "Most popular snaps" %}
31+
{% include "explore/_snaps-list.html" %}
32+
{% endwith %}
3133
{% endif %}
3234

3335
{% if categories %}
3436
{% include "explore/_categories.html" %}
3537
{% endif %}
3638

39+
{% if top_rated_snaps %}
40+
{% with snaps_list = top_rated_snaps, title = "Top rated snaps" %}
41+
{% include "explore/_snaps-list.html" %}
42+
{% endwith %}
43+
{% endif %}
44+
3745
{% if trending_snaps %}
3846
{% include "explore/_trending-snaps.html" %}
3947
{% endif %}

webapp/store/views.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ def explore_view():
150150
except api_requests.exceptions.RequestException:
151151
trending_snaps = []
152152

153+
try:
154+
top_rated_snaps = api_requests.get(
155+
f"{recommendations_api_url}/top_rated"
156+
).json()
157+
except api_requests.exceptions.RequestException:
158+
top_rated_snaps = []
159+
153160
try:
154161
categories_results = device_gateway.get_categories()
155162
except StoreApiError:
@@ -166,6 +173,7 @@ def explore_view():
166173
popular_snaps=popular_snaps,
167174
recent_snaps=recent_snaps,
168175
trending_snaps=trending_snaps,
176+
top_rated_snaps=top_rated_snaps,
169177
)
170178

171179
@store.route("/youtube", methods=["POST"])

0 commit comments

Comments
 (0)