-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlatest.sh
More file actions
executable file
·53 lines (47 loc) · 844 Bytes
/
latest.sh
File metadata and controls
executable file
·53 lines (47 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash -e
# @installable
MYSELF="$(readlink -f "$0")"
MYDIR="${MYSELF%/*}"
ME=$(basename $MYSELF)
source $MYDIR/env
[[ -f $LOCAL_ENV ]] && source $LOCAL_ENV
source $MYDIR/log.sh
source $MYDIR/db.sh
limit=10
filter="and e.finish > (now()::date - interval '1 month')"
full=full
while test $# -gt 0
do
case "$1" in
--limit|-l)
shift
limit=$1
;;
--all|-a)
limit=10000
;;
--filter|-f)
shift
filter="and t.name ilike '%$1%'"
;;
--raw)
full=raw
;;
-*)
echo "bad option '$1'"
;;
esac
shift
done
info -n "latest executions:"
query="select
t.id, t.external_id ext, t.name, t.elapsed
from executions e
join tasks t on t.id=e.task_id
where 1=1
$filter
group by t.id
order by max(e.id) desc
limit $limit"
debug "$query"
$MYDIR/psql.sh "$query" --$full