]> git.phdru.name Git - xsetbg.git/blob - print-stats.py
Fix(DB): Fix column encoding
[xsetbg.git] / print-stats.py
1 #! /usr/bin/env python
2 """Display stats: shown and non-shown files; oldest and newest and so on
3
4 This file is a part of XSetBg.
5
6 """
7
8 import sys
9 from time import localtime, asctime
10 from xsetbg_db import xsetbg_db
11
12 if not xsetbg_db:
13     sys.exit("Error: no database found")
14
15 print "Total files:", xsetbg_db.select().count()
16 print "Images:", xsetbg_db.select('is_image = 1').count()
17 print "Non-images:", xsetbg_db.select('is_image = 0').count()
18 print "Unknown:", xsetbg_db.select('is_image IS NULL').count()
19 print "Shown files:", xsetbg_db.select('last_shown IS NOT NULL').count()
20 print "Not shown files:", xsetbg_db.select('last_shown IS NULL').count()
21 last_shown = xsetbg_db.select('last_shown IS NOT NULL',
22                               orderBy='last_shown')[0].last_shown
23 print "Oldest:", asctime(localtime(last_shown))
24 min_max = xsetbg_db.select().accumulateMany(('MIN', 'id'), ('MAX', 'id'))
25 print "Min id:", min_max[0]
26 print "Max id:", min_max[1]