|
12 | 12 | from canonicalwebteam.store_api.dashboard import Dashboard |
13 | 13 | from canonicalwebteam.store_api.publishergw import PublisherGW |
14 | 14 | from canonicalwebteam.store_api.devicegw import DeviceGW |
| 15 | +from canonicalwebteam.snap_recommendations import SnapRecommendations |
15 | 16 |
|
16 | 17 | from webapp.api.exceptions import ApiError |
17 | 18 | from webapp.store.snap_details_views import snap_details_views |
|
29 | 30 | dashboard = Dashboard(api_session) |
30 | 31 | publisher_gateway = PublisherGW("snap", api_publisher_session) |
31 | 32 | device_gateway = DeviceGW("snap", api_session) |
| 33 | +snap_recommendations = SnapRecommendations(session) |
32 | 34 |
|
33 | 35 |
|
34 | 36 | def store_blueprint(store_query=None): |
@@ -125,35 +127,23 @@ def store_view(): |
125 | 127 |
|
126 | 128 | @store.route("/explore") |
127 | 129 | def explore_view(): |
128 | | - recommendations_api_url = ( |
129 | | - "https://recommendations.snapcraft.io/api/category" |
130 | | - ) |
131 | | - |
132 | 130 | try: |
133 | | - popular_snaps = api_requests.get( |
134 | | - f"{recommendations_api_url}/popular" |
135 | | - ).json() |
| 131 | + popular_snaps = snap_recommendations.get_popular() |
136 | 132 | except api_requests.exceptions.RequestException: |
137 | 133 | popular_snaps = [] |
138 | 134 |
|
139 | 135 | try: |
140 | | - recent_snaps = api_requests.get( |
141 | | - f"{recommendations_api_url}/recent" |
142 | | - ).json() |
| 136 | + recent_snaps = snap_recommendations.get_recent() |
143 | 137 | except api_requests.exceptions.RequestException: |
144 | 138 | recent_snaps = [] |
145 | 139 |
|
146 | 140 | try: |
147 | | - trending_snaps = api_requests.get( |
148 | | - f"{recommendations_api_url}/trending" |
149 | | - ).json() |
| 141 | + trending_snaps = snap_recommendations.get_trending() |
150 | 142 | except api_requests.exceptions.RequestException: |
151 | 143 | trending_snaps = [] |
152 | 144 |
|
153 | 145 | try: |
154 | | - top_rated_snaps = api_requests.get( |
155 | | - f"{recommendations_api_url}/top_rated" |
156 | | - ).json() |
| 146 | + top_rated_snaps = snap_recommendations.get_top_rated() |
157 | 147 | except api_requests.exceptions.RequestException: |
158 | 148 | top_rated_snaps = [] |
159 | 149 |
|
|
0 commit comments