#5 Added ability to get a quick overview of all of the product stats on one page.
This commit is contained in:
parent
d09d597905
commit
8f0e995471
@ -29,7 +29,7 @@ class StatsController(DatabaseController):
|
|||||||
cursor = self._conn.execute(
|
cursor = self._conn.execute(
|
||||||
"SELECT * FROM Views",
|
"SELECT * FROM Views",
|
||||||
)
|
)
|
||||||
rows = cursor.fetchmany()
|
rows = cursor.fetchall()
|
||||||
|
|
||||||
if rows is None:
|
if rows is None:
|
||||||
return None
|
return None
|
||||||
|
@ -15,20 +15,23 @@ blueprint = Blueprint("stats", __name__, url_prefix='/stats')
|
|||||||
|
|
||||||
@blueprint.route('/')
|
@blueprint.route('/')
|
||||||
def stats_index():
|
def stats_index():
|
||||||
|
""" Main page to view all of the statistics for the site """
|
||||||
db = StatsController()
|
db = StatsController()
|
||||||
data = db.read()
|
data = db.read()
|
||||||
return ""
|
return render_template("index.html", content="stats.html", data=data)
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route('/product/<int:id>')
|
@blueprint.route('/product/<int:id>')
|
||||||
def view_product_stats(id: int):
|
def view_product_stats(id: int):
|
||||||
|
""" Page to view statistics for a given product """
|
||||||
db = StatsController()
|
db = StatsController()
|
||||||
data = db.read_product(id)
|
data = db.read_product(id)
|
||||||
return ""
|
return render_template("index.html", content="stats.html", data=data)
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route('/user/<int:id>')
|
@blueprint.route('/user/<int:id>')
|
||||||
def view_user_stats(id: int):
|
def view_user_stats(id: int):
|
||||||
|
""" Page to view statistics for a given user """
|
||||||
db = StatsController()
|
db = StatsController()
|
||||||
data = db.read_user(id)
|
data = db.read_user(id)
|
||||||
return ""
|
return render_template("index.html", content="stats.html", data=data)
|
||||||
|
17
templates/stats.html
Normal file
17
templates/stats.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='css/products.css') }}">
|
||||||
|
|
||||||
|
<div class="product-container">
|
||||||
|
{% if data != None %}
|
||||||
|
{% for stat in data %}
|
||||||
|
<a href="/stats/product/{{stat.productID}}" class="product product-link">
|
||||||
|
<div class="product-title">{{stat.userID}}</div>
|
||||||
|
<div class="product-content-container">
|
||||||
|
<div class="product-details">
|
||||||
|
<div class="product-price">£{{stat.productID}}</div>
|
||||||
|
<div class="product-description hide-overflow ">{{stat.viewDate}}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user