(user=None)
return q.scalar() or 0
Sum the total number of messages across all projects.
Sum the total number of messages across all projects.
Sum the total number of messages across all projects .
def total_messages(user=None):
    """
    Sum the total number of messages across all projects.
    """
    q = db.session.query(
        func.sum(Project.message_count)
    )
    if user:
        q = q.filter(Project.owner_id == user.id)

    return q.scalar() or 0
def total_messages ( user = None ) : q = db . session . query ( func . sum ( Project . message_count ) ) if user : q = q . filter ( Project . owner_id == user . id ) return q . scalar ( ) or 0