#5 Changed styling and added product ranking in category to the stats page

This commit is contained in:
2024-02-11 15:52:12 +00:00
parent 9943a1492c
commit 83829af06f
5 changed files with 66 additions and 22 deletions

View File

@ -90,6 +90,34 @@ class StatsController(DatabaseController):
return self.get_one(query, params, int)
def read_ranking(self, id: int):
params = [
id
]
query = """
SELECT
ranking
FROM
(
SELECT
p.id as id,
RANK() OVER (
PARTITION BY p.categoryID
ORDER BY COUNT(v.productID) DESC
)AS ranking
FROM
Products p
LEFT JOIN
Views v ON p.id = v.productID
GROUP BY
p.id, p.categoryID
)
WHERE id = ?
"""
return self.get_one(query, params, int)
def update(self):
print("Doing work")