33 lines
1 KiB
Python
33 lines
1 KiB
Python
#! /usr/bin/env python3
|
|
import sys
|
|
|
|
import click
|
|
from sqlalchemy import create_engine
|
|
|
|
from schmeckels.helper import build_database_filename, build_rules_filename, get_data_dir, get_session, get_rules
|
|
from schmeckels.models import Tag, Transaction
|
|
|
|
|
|
@click.command(name="info")
|
|
def command():
|
|
session = get_session()
|
|
data_dir = get_data_dir()
|
|
db_path = build_database_filename(data_dir)
|
|
rules_path = build_rules_filename(data_dir)
|
|
rules = get_rules()
|
|
|
|
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}")
|
|
print(f" Rules: {len(rules)}")
|