aboutsummaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2013-01-24 16:15:56 +0100
committerJochen Topf <jochen@topf.org>2013-01-24 16:15:56 +0100
commitceb79b1e639597a930d466e34f3d113f6e51c3d4 (patch)
treeca704d498cc15e05b3eebe97b1313532b683f876 /sources
parent38095b40997a08a0b7e5155da442fa77165ce556 (diff)
downloadtaginfo-ceb79b1e639597a930d466e34f3d113f6e51c3d4.tar
taginfo-ceb79b1e639597a930d466e34f3d113f6e51c3d4.tar.gz
Add history database to update scripts
Diffstat (limited to 'sources')
-rw-r--r--sources/master/history_init.sql17
-rw-r--r--sources/master/history_update.sql14
-rwxr-xr-xsources/master/update.sh8
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."