I want to get a user's logs from a database that we use to record call logs and count how many logs they entered each day. That way I can do some nice charting using chart.js
What would be the way to head back for the last 7 days and get a single user's log count for each day?
The table looks sort of like this (simplified):
class Log(db.Model):
__tablename__ = 'log'
id = db.Column(db.Integer, primary_key=True)
logType = db.Column(db.String(100), nullable=False)
title = db.Column(db.String(100), nullable=False)
date_posted = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
content = db.Column(db.Text, nullable=False)
org_id = db.Column(db.Integer, db.ForeignKey('org.id'), nullable=False)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
I want to compile get this kind of data:
mon:12
tue:2
wed:8
thu:15
fri:13
sat:12
sun:11
I'm totally stumped as to how to go about this.
Thanks a tonne..