]> git.phdru.name Git - xsetbg.git/blob - print-stats.py
Version 5.0.2
[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 __author__ = "Oleg Broytman <phd@phdru.name>"
9 __copyright__ = "Copyright (C) 2006-2015 PhiloSoft Design"
10 __license__ = "GNU GPL"
11
12 import sys
13 from time import localtime, asctime
14 from xsetbg_db import xsetbg_db
15
16 if not xsetbg_db:
17     sys.exit("Error: no database found")
18
19 print "Total files:", xsetbg_db.select().count()
20 print "Shown files:", xsetbg_db.select('last_shown IS NOT NULL').count()
21 print "Not shown files:", xsetbg_db.select('last_shown IS NULL').count()
22 last_shown = xsetbg_db.select('last_shown IS NOT NULL',
23                               orderBy='last_shown')[0].last_shown
24 print "Oldest:", asctime(localtime(last_shown))
25 min_max = xsetbg_db.select().accumulateMany(('MIN', 'id'), ('MAX', 'id'))
26 print "Min id:", min_max[0]
27 print "Max id:", min_max[1]