fix info
This commit is contained in:
parent
1dc9d35475
commit
9154039644
1 changed files with 8 additions and 4 deletions
12
info.py
12
info.py
|
@ -1,6 +1,6 @@
|
||||||
#! /usr/bin/env python3
|
#! /usr/bin/env python3
|
||||||
from sqlalchemy import create_engine
|
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
|
from helper import get_session, list_profiles, build_database_filename, build_rules_filename
|
||||||
import sys
|
import sys
|
||||||
import click
|
import click
|
||||||
|
@ -8,6 +8,7 @@ import click
|
||||||
|
|
||||||
@click.command(name="info")
|
@click.command(name="info")
|
||||||
def command():
|
def command():
|
||||||
|
first = True
|
||||||
for profile in list_profiles():
|
for profile in list_profiles():
|
||||||
session = get_session(profile)
|
session = get_session(profile)
|
||||||
db_path = build_database_filename(profile)
|
db_path = build_database_filename(profile)
|
||||||
|
@ -17,9 +18,9 @@ def command():
|
||||||
print(f" DB: {db_path}")
|
print(f" DB: {db_path}")
|
||||||
print(f" Rules: {rules_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()
|
transactions = session.query(Transaction).count()
|
||||||
categories = session.query(Category).count()
|
tags = session.query(Tag).count()
|
||||||
try:
|
try:
|
||||||
unsorted_percent = round(unsorted / (transactions / 100), 1)
|
unsorted_percent = round(unsorted / (transactions / 100), 1)
|
||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
|
@ -27,5 +28,8 @@ def command():
|
||||||
|
|
||||||
print(f"Transactions: {transactions}")
|
print(f"Transactions: {transactions}")
|
||||||
print(f" Unsorted: {unsorted} ({unsorted_percent}%)")
|
print(f" Unsorted: {unsorted} ({unsorted_percent}%)")
|
||||||
print(f" Categories: {categories}")
|
print(f" Tags: {tags}")
|
||||||
|
if first:
|
||||||
|
first = False
|
||||||
|
else:
|
||||||
print("----------")
|
print("----------")
|
||||||
|
|
Loading…
Add table
Reference in a new issue