summaryrefslogtreecommitdiffstats
path: root/generation/query.sh
diff options
context:
space:
mode:
authorholger <holgercremer@gmail.com>2019-11-01 21:55:22 +0100
committerGitHub <noreply@github.com>2019-11-01 21:55:22 +0100
commit04e0406316320f6039365b80de8c58c3c58413c5 (patch)
treece31b694a0f2604ea16a9ae5580426ea666941ba /generation/query.sh
parent2714fc190f01894eaaa64bf3869a4a4269ab1dcf (diff)
parentd92aa9d79a3f80557119b660f7191e96b7d79878 (diff)
downloadserial-barcode-scanner-04e0406316320f6039365b80de8c58c3c58413c5.tar.bz2
Merge pull request #45 from smilix/master
mqtt script & pdf generation improvements
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