#5 Changed styling and added product ranking in category to the stats page
This commit is contained in:
@ -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")
|
||||
|
||||
|
Reference in New Issue
Block a user