| Version 2 (modified by , 10 hours ago) ( diff ) |
|---|
View of all builds
Actors
Guest, User, Admin
Scenario
- The user clicks on the "COMPLETED BUILDS" button
- A new page with all the completed and approved builds is displayed
- The user can sort by creation date, price and search by name
SELECT
b.id,
b.user_id,
b.name,
b.created_at,
b.total_price,
COALESCE(AVG(rb.value::float), 0) AS avgRating
FROM build AS b
LEFT JOIN rating_build AS rb
ON b.id = rb.build_id
WHERE
b.is_approved = true
AND b.name ILIKE ('%' || $q || '%')
GROUP BY
b.id, b.user_id, b.name, b.created_at, b.total_price
ORDER BY
CASE WHEN $sort = 'price_asc' THEN b.total_price END ASC,
CASE WHEN $sort = 'price_desc' THEN b.total_price END DESC,
CASE WHEN $sort = 'rating_desc' THEN COALESCE(AVG(rb.value::float), 0) END DESC,
CASE WHEN $sort = 'oldest' THEN b.created_at END ASC,
CASE WHEN $sort = 'newest' THEN b.created_at END DESC,
b.created_at DESC
LIMIT COALESCE($limit, 100);
Attachments (4)
- clickCompletedBuilds.png (76.8 KB ) - added by 8 hours ago.
- showBuildDetails.png (234.4 KB ) - added by 8 hours ago.
- completedBuildsPage.png (244.0 KB ) - added by 8 hours ago.
- sortBuilds.png (112.6 KB ) - added by 8 hours ago.
Download all attachments as: .zip
Note:
See TracWiki
for help on using the wiki.
