feat: Server-side rendered explore page#5443
Conversation
* feat: Add initial view for SSR explore page (#5423) * feat: Add learn to snap section to SSR explore page
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the explore page from a client-side React application to server-side rendering (SSR) using Flask templates. The backend now fetches recommendations data (popular, recent, trending snaps) and categories, passing them to Jinja2 templates instead of loading them via React and React Query.
Key Changes
- Backend now handles data fetching for popular/recent/trending snaps and categories in
explore_view() - React components replaced with Jinja2 templates for rendering snap lists and categories
- Client-side routing removed for
/exploreendpoint
Reviewed Changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| webapp/store/views.py | Adds server-side data fetching logic for explore page with API calls to recommendations service |
| tests/store/tests_explore.py | New unit tests for recommendations API endpoints |
| templates/explore/index.html | Main explore page template structure |
| templates/explore/_updated-snaps.html | Template partial for recently updated snaps section |
| templates/explore/_popular-snaps.html | Template partial for most popular snaps section |
| templates/explore/_trending-snaps.html | Template partial for trending snaps section |
| templates/explore/_categories.html | Template partial for categories section |
| static/sass/styles.scss | Adds styling for explore page highlight block and updates line-clamp utility |
| static/js/store/index.tsx | Removes /explore route from React Router |
| static/js/store/pages/Explore/* | Removes all React components and tests for client-side explore page |
| static/js/store/utils/formatCardData.ts | Removes utility no longer needed after SSR migration |
| static/js/store/types/* | Removes unused TypeScript types |
| static/js/store/hooks/* | Removes unused React hooks |
| except StoreApiError: | ||
| popular_snaps = [] | ||
|
|
||
| try: | ||
| recent_snaps = api_requests.get( | ||
| f"{recommendations_api_url}/recent" | ||
| ).json() | ||
| except StoreApiError: | ||
| recent_snaps = [] | ||
|
|
||
| try: | ||
| trending_snaps = api_requests.get( | ||
| f"{recommendations_api_url}/trending" | ||
| ).json() | ||
| except StoreApiError: |
There was a problem hiding this comment.
API request exceptions are caught as StoreApiError, but api_requests.get() (which is requests.get()) raises requests.exceptions.RequestException or its subclasses, not StoreApiError. The except block will never catch these exceptions. Either catch the correct exception type or ensure the code raises StoreApiError.
| except StoreApiError: | |
| popular_snaps = [] | |
| try: | |
| recent_snaps = api_requests.get( | |
| f"{recommendations_api_url}/recent" | |
| ).json() | |
| except StoreApiError: | |
| recent_snaps = [] | |
| try: | |
| trending_snaps = api_requests.get( | |
| f"{recommendations_api_url}/trending" | |
| ).json() | |
| except StoreApiError: | |
| except api_requests.exceptions.RequestException: | |
| popular_snaps = [] | |
| try: | |
| recent_snaps = api_requests.get( | |
| f"{recommendations_api_url}/recent" | |
| ).json() | |
| except api_requests.exceptions.RequestException: | |
| recent_snaps = [] | |
| try: | |
| trending_snaps = api_requests.get( | |
| f"{recommendations_api_url}/trending" | |
| ).json() | |
| except api_requests.exceptions.RequestException: |
There was a problem hiding this comment.
I think it would make sense to add some recommendation service helpers to the store-api package at some point in the future, that way we can handle these errors without relying on RequestException
There was a problem hiding this comment.
I agree. I'll make a ticket.
Done
Converts the explore page from a client-side rendered app to a server-side rendered page. There's a couple of minor visual differences which I've asked Leia about in chat - but otherwise they should be identical.
How to QA
Testing