blob: 6d93d152120e786c9cc7ff2f13d12445c33eec1c [file] [log] [blame]
Chetan Gaonker7f4bf742016-05-04 15:56:08 -07001#
2# This query properly handles calls that span from the
3# previous reset period into the current period but
4# involves more work for the SQL server than those
5# below
6#
7query = "\
8 SELECT SUM(acctsessiontime - GREATEST((%b - UNIX_TIMESTAMP(acctstarttime)), 0)) \
9 FROM radacct \
10 WHERE username='%{${key}}' \
11 AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%b'"
12
13#
14# This query ignores calls that started in a previous
15# reset period and continue into into this one. But it
16# is a little easier on the SQL server
17#
18#query = "\
19# SELECT SUM(acctsessiontime) \
20# FROM radacct\
21# WHERE username='%{${key}}' \
22# AND acctstarttime > FROM_UNIXTIME('%b')"
23
24#
25# This query is the same as above, but demonstrates an
26# additional counter parameter '%e' which is the
27# timestamp for the end of the period
28#
29#query = "\
30# SELECT SUM(acctsessiontime) \
31# FROM radacct \
32# WHERE username='%{${key}}' \
33# AND acctstarttime BETWEEN FROM_UNIXTIME('%b') \
34# AND FROM_UNIXTIME('%e')"