#5 Latest views are now displayed on the stats page
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
in the web app
|
||||
"""
|
||||
import json
|
||||
import random
|
||||
from flask import Blueprint
|
||||
|
||||
from flask import render_template, redirect, request, session, flash
|
||||
@ -19,8 +20,6 @@ def stats_index():
|
||||
db = StatsController()
|
||||
data = db.read()
|
||||
test = list(map(lambda d: d.productID, data))
|
||||
for i in test:
|
||||
print(i)
|
||||
return render_template("index.html", content="stats.html", data=test)
|
||||
|
||||
|
||||
@ -28,8 +27,23 @@ def stats_index():
|
||||
def view_product_stats(id: int):
|
||||
""" Page to view statistics for a given product """
|
||||
db = StatsController()
|
||||
data = db.read_days(id, 7)
|
||||
return render_template("index.html", content="stats.html", data=data)
|
||||
|
||||
prev_days: int = request.args.get('prev_days', 7, int)
|
||||
data = db.read_days(id, prev_days)
|
||||
|
||||
product_frequency_data = dict(map(
|
||||
# lambda k, v: (k, random.randint(0, 100)),
|
||||
lambda k, v: (k, len(v)),
|
||||
data.keys(),
|
||||
data.values()
|
||||
))
|
||||
|
||||
return render_template(
|
||||
"index.html",
|
||||
content="stats.html",
|
||||
headings=list(reversed(product_frequency_data.keys())),
|
||||
data=list(reversed(product_frequency_data.values()))
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route('/user/<int:id>')
|
||||
|
Reference in New Issue
Block a user