summaryrefslogtreecommitdiffstats
path: root/generation/query.sh
diff options
context:
space:
mode:
Diffstat (limited to 'generation/query.sh')
-rwxr-xr-xgeneration/query.sh18
1 files changed, 17 insertions, 1 deletions
diff --git a/generation/query.sh b/generation/query.sh
index 67accaf..a6a9783 100755
--- a/generation/query.sh
+++ b/generation/query.sh
@@ -1 +1,17 @@
-sqlite3 shop.db "SELECT id,firstname,lastname FROM users LEFT JOIN authentication ON users.id = authentication.user WHERE (users.disabled IS NULL or users.disabled != 1) and id > 0" | sed "s~|~,~g" > users.csv
+#!/bin/bash
+
+if [[ "$1" != "" ]]; then
+ # format YYYY-MM-DD, e.g. 2017-01-01
+ DATE_PART="AND joined_at > strftime('%s', '$1')"
+fi
+
+SQL=`cat <<EOF
+SELECT id,firstname,lastname FROM users
+LEFT JOIN authentication ON users.id = authentication.user
+WHERE (users.disabled IS NULL or users.disabled != 1)
+AND id > 0
+$DATE_PART
+EOF
+`
+sqlite3 shop.db "$SQL" \
+ | sed "s~|~,~g" > users.csv