diff options
-rw-r--r-- | sources/master/history_init.sql | 17 | ||||
-rw-r--r-- | sources/master/history_update.sql | 14 | ||||
-rwxr-xr-x | sources/master/update.sh | 8 |
3 files changed, 39 insertions, 0 deletions
diff --git a/sources/master/history_init.sql b/sources/master/history_init.sql new file mode 100644 index 0000000..8d1794c --- /dev/null +++ b/sources/master/history_init.sql @@ -0,0 +1,17 @@ +-- ============================================================================ +-- +-- Taginfo +-- +-- history_init.sql +-- +-- ============================================================================ + +.bail ON + +DROP TABLE IF EXISTS history_stats; +CREATE TABLE history_stats ( + udate TEXT, + key TEXT, + value INT64 +); + diff --git a/sources/master/history_update.sql b/sources/master/history_update.sql new file mode 100644 index 0000000..4aabb21 --- /dev/null +++ b/sources/master/history_update.sql @@ -0,0 +1,14 @@ +-- ============================================================================ +-- +-- Taginfo +-- +-- history_update.sql +-- +-- ============================================================================ + +.bail ON + +ATTACH DATABASE '__DIR__/taginfo-master.db' AS master; + +INSERT INTO history_stats (udate, key, value) SELECT datetime('now'), key, value FROM master.master_stats; + diff --git a/sources/master/update.sh b/sources/master/update.sh index e90571d..d030134 100755 --- a/sources/master/update.sh +++ b/sources/master/update.sh @@ -25,6 +25,7 @@ fi echo "Running with ruby set as '${EXEC_RUBY}'" DATABASE=$DIR/taginfo-master.db +HISTORYDB=$DIR/taginfo-history.db echo "`$DATECMD` Create search database..." @@ -33,10 +34,17 @@ $EXEC_RUBY -pe "\$_.sub!(/__DIR__/, '$DIR')" search.sql | sqlite3 $DIR/taginfo-s rm -f $DATABASE +echo "`$DATECMD` Create master database..." sqlite3 $DATABASE <languages.sql $EXEC_RUBY -pe "\$_.sub!(/__DIR__/, '$DIR')" master.sql | sqlite3 $DATABASE $EXEC_RUBY -pe "\$_.sub!(/__DIR__/, '$DIR')" interesting_tags.sql | sqlite3 $DATABASE $EXEC_RUBY -pe "\$_.sub!(/__DIR__/, '$DIR')" interesting_relation_types.sql | sqlite3 $DATABASE +echo "`$DATECMD` Updating history database..." +if [ ! -e $HISTORYDB ]; then + sqlite3 $HISTORYDB < history_init.sql +fi +$EXEC_RUBY -pe "\$_.sub!(/__DIR__/, '$DIR')" history_update.sql | sqlite3 $HISTORYDB + echo "`$DATECMD` Done master." |