WIP: Started to add more stats to the product stats page.
This commit is contained in:
@ -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]):
|
||||
|
@ -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")
|
||||
|
||||
|
Reference in New Issue
Block a user