M README => README +4 -0
@@ 12,3 12,7 @@ scripts:
unmarks each GAMEURL, as if it were never marked
* stats.tcl DB-PATH ?GAMEURL ...?
if no GAMEURLs are present, prints database stats. otherwise, prints the played status of each GAMEURL
+* ignore.tcl DB-PATH GAMEURL ?GAMEURL ...?
+ marks each GAMEURL to be ignored by stats.tcl
+* unignore.tcl DB-PATH GAMEURL ?GAMEURL ...?
+ unmarks each GAMEURL to be ignored by stats.tcl
M db/games.db => db/games.db +0 -0
A ignore.tcl => ignore.tcl +34 -0
@@ 0,0 1,34 @@
+#!/bin/env tclsh
+
+package require sqlite3
+
+proc fatal {reason {code -1}} {
+ puts stderr "$argv0: fatal: $reason"
+ exit $code
+}
+
+
+proc usage {} {
+ global argv0
+ puts stderr "usage: $argv0 DB-PATH GAME-URL ?GAME-URL ...?"
+ exit -1
+}
+if {[llength $argv] < 2} usage
+set gameurls [lassign $argv dbpath]
+
+
+if {[catch {sqlite3 db $dbpath -create false}]} {
+ fatal "can't open \"$dbpath\""
+}
+
+
+foreach url $gameurls {
+ if {![db exists {SELECT * FROM titles WHERE href = :url}]} {
+ puts stderr "game not in database: $url"
+ continue
+ }
+ db eval {
+ UPDATE titles SET ignore = 0
+ WHERE href = :url
+ }
+}
M setup.tcl => setup.tcl +2 -1
@@ 23,6 23,7 @@ if {[catch {sqlite3 db $dbpath}]} {
}
db eval {
- CREATE TABLE titles(name TEXT NOT NULL, href TEXT NOT NULL PRIMARY KEY, played TEXT);
+ CREATE TABLE titles(name TEXT NOT NULL, href TEXT NOT NULL PRIMARY KEY, played TEXT, ignore INT DEFAULT 0);
CREATE INDEX titles_name ON titles(name);
+ CREATE INDEX titles_ignore ON titles(ignore);
}
M stats.tcl => stats.tcl +2 -2
@@ 21,8 21,8 @@ if {[catch {sqlite3 db $dbpath -create false}]} {
}
if {[llength $gameurls] == 0} {
- set total [db eval {SELECT count(*) FROM titles}]
- set played [db eval {SELECT count(*) FROM titles WHERE played NOT NULL}]
+ set total [db eval {SELECT count(*) FROM titles WHERE ignore = 0}]
+ set played [db eval {SELECT count(*) FROM titles WHERE played NOT NULL AND ignore = 0}]
puts "database \"[file tail [file rootname $dbpath]]\":"
puts "- $total games"
A unignore.tcl => unignore.tcl +34 -0
@@ 0,0 1,34 @@
+#!/bin/env tclsh
+
+package require sqlite3
+
+proc fatal {reason {code -1}} {
+ puts stderr "$argv0: fatal: $reason"
+ exit $code
+}
+
+
+proc usage {} {
+ global argv0
+ puts stderr "usage: $argv0 DB-PATH GAME-URL ?GAME-URL ...?"
+ exit -1
+}
+if {[llength $argv] < 2} usage
+set gameurls [lassign $argv dbpath]
+
+
+if {[catch {sqlite3 db $dbpath -create false}]} {
+ fatal "can't open \"$dbpath\""
+}
+
+
+foreach url $gameurls {
+ if {![db exists {SELECT * FROM titles WHERE href = :url}]} {
+ puts stderr "game not in database: $url"
+ continue
+ }
+ db eval {
+ UPDATE titles SET ignore = 1
+ WHERE href = :url
+ }
+}