summaryrefslogtreecommitdiffstats
path: root/generation/query.sh
diff options
context:
space:
mode:
authorHolger Cremer <HolgerCremer@gmail.com>2019-04-05 18:01:28 +0200
committerHolger Cremer <HolgerCremer@gmail.com>2019-04-05 18:01:28 +0200
commitd92aa9d79a3f80557119b660f7191e96b7d79878 (patch)
treece31b694a0f2604ea16a9ae5580426ea666941ba /generation/query.sh
parent61b2f90b4940d715d435898b38f11c37c3720607 (diff)
downloadserial-barcode-scanner-d92aa9d79a3f80557119b660f7191e96b7d79878.tar.bz2
Several pdf generation improvements.
- 2 scripts to create barcodes - "joined add" parameter to create partial lists for updates - a dockerfile to easy creation
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