35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
#! /usr/bin/env python3
|
|
from sqlalchemy import create_engine
|
|
from models import Tag, Transaction
|
|
from helper import get_session, list_profiles, build_database_filename, build_rules_filename
|
|
import sys
|
|
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)
|
|
rules_path = build_rules_filename(profile)
|
|
|
|
print(f"Profile: {profile}")
|
|
print(f" DB: {db_path}")
|
|
print(f" Rules: {rules_path}")
|
|
|
|
unsorted = session.query(Transaction).filter(Transaction.tags == None).count()
|
|
transactions = session.query(Transaction).count()
|
|
tags = session.query(Tag).count()
|
|
try:
|
|
unsorted_percent = round(unsorted / (transactions / 100), 1)
|
|
except ZeroDivisionError:
|
|
unsorted_percent = 0
|
|
|
|
print(f"Transactions: {transactions}")
|
|
print(f" Unsorted: {unsorted} ({unsorted_percent}%)")
|
|
print(f" Tags: {tags}")
|
|
if first:
|
|
first = False
|
|
else:
|
|
print("----------")
|