script and sql to calculate offset for last x days
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 1 Dec 2020 10:19:28 +0000 (11:19 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 1 Dec 2020 10:20:34 +0000 (11:20 +0100)
gnuplot/calc-offset.sh [new file with mode: 0755]
gnuplot/calc-offset.sql [new file with mode: 0644]

diff --git a/gnuplot/calc-offset.sh b/gnuplot/calc-offset.sh
new file mode 100755 (executable)
index 0000000..84133c6
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+days=90
+test ! -z "$1" && days=$1
+
+cat calc-offset.sql | sed "s/90 days/$days days/" | psql -A -t -F' ' zc 
+
diff --git a/gnuplot/calc-offset.sql b/gnuplot/calc-offset.sql
new file mode 100644 (file)
index 0000000..3df7f50
--- /dev/null
@@ -0,0 +1,4 @@
+select pn,-avg(x_axis_angle),-avg(y_axis_angle) from zc
+where time > now() - interval '90 days'
+group by pn
+order by pn ;