This commit is contained in:
Felix Breidenstein 2020-10-18 22:50:10 +02:00
parent 1dc9d35475
commit 9154039644

12
info.py
View file

@ -1,6 +1,6 @@
#! /usr/bin/env python3
from sqlalchemy import create_engine
from models import Category, Transaction
from models import Tag, Transaction
from helper import get_session, list_profiles, build_database_filename, build_rules_filename
import sys
import click
@ -8,6 +8,7 @@ import click
@click.command(name="info")
def command():
first = True
for profile in list_profiles():
session = get_session(profile)
db_path = build_database_filename(profile)
@ -17,9 +18,9 @@ def command():
print(f" DB: {db_path}")
print(f" Rules: {rules_path}")
unsorted = session.query(Transaction).filter(Transaction.category_id == None).count()
unsorted = session.query(Transaction).filter(Transaction.tags == None).count()
transactions = session.query(Transaction).count()
categories = session.query(Category).count()
tags = session.query(Tag).count()
try:
unsorted_percent = round(unsorted / (transactions / 100), 1)
except ZeroDivisionError:
@ -27,5 +28,8 @@ def command():
print(f"Transactions: {transactions}")
print(f" Unsorted: {unsorted} ({unsorted_percent}%)")
print(f" Categories: {categories}")
print(f" Tags: {tags}")
if first:
first = False
else:
print("----------")