summaryrefslogtreecommitdiff
path: root/scripts/epgd-showmerge
blob: 5f06f710bc97e6f3699b5868a64f2770d70bf962 (plain)
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
#!/bin/bash

export MYSQL_PWD=epg

if [ "$1" == "-h" ]; then

  echo "  Usage: $0 [<channelid>] [<to-date>]"
  echo "     (without channelid the merge state will shown)"
  echo ""
  echo "  Example: $0 S19.2E-1-1010-11150 \"2013-10-01 16:00\""

  exit 0
fi

mysql -u epg2vdr -Depg2vdr -e "select from_unixtime(lastmerge) as 'last merge was at' from vdrs where uuid = 'epgd';"
mysql -u epg2vdr -Depg2vdr -e "select count(1) as 'events pending for merge' from events where source = 'vdr' and updsp > (select lastmerge from vdrs where uuid = 'epgd');"
mysql -u epg2vdr -Depg2vdr -e "select count(source),source from events group by source;"

if [ -z "$1" ]; then

  mysql -u epg2vdr -Depg2vdr -e "select count(*),source,updflg from events where starttime+duration >= unix_timestamp() group by source,updflg;"

else

  if [ -z "$2" ]; then
    to=`date +%Y-%m-%d -d "+ 1 day"`
  else
    to=$2
  fi

   echo "channel $1"
   mysql -u epg2vdr -Depg2vdr -e "select source,masterid,useid,updflg,delflg,from_unixtime(starttime) starttime,round(duration/60,0) duration,substr(title,1,45) title,from_unixtime(updsp) updsp  from events where channelid = '$1' and starttime+duration >= unix_timestamp() order by starttime,source desc limit 50;"

fi