WIP: Started to add more stats to the product stats page.

This commit is contained in:
2024-02-09 18:45:33 +00:00
parent c55fdde3fc
commit 7c27aa31b6
4 changed files with 58 additions and 6 deletions

View File

@ -44,7 +44,10 @@ class DatabaseController(ABC):
"""
obj = of.__new__(of)
for attr, value in with_fields.items():
setattr(obj, attr, value)
try:
setattr(obj, attr, value)
except KeyError:
return of(value)
return obj
def do(self, query: str, params: list[str]):

View File

@ -76,6 +76,19 @@ class StatsController(DatabaseController):
return day_views
def read_product_views(self, id: int):
""" Returns the total number of views for a product """
params = [
id
]
# Total Views
query = """
SELECT count(id) FROM Views WHERE productID = ?
"""
return self.get_one(query, params, int)
def update(self):
print("Doing work")