Chetan Gaonker | 7f4bf74 | 2016-05-04 15:56:08 -0700 | [diff] [blame] | 1 | # |
| 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 | # |
| 7 | query = "\ |
| 8 | SELECT SUM(AcctSessionTime - GREATER((%b - AcctStartTime::ABSTIME::INT4), 0)) \ |
| 9 | FROM radacct \ |
| 10 | WHERE UserName='%{${key}}' \ |
| 11 | AND AcctStartTime::ABSTIME::INT4 + 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::ABSTIME::INT4 > '%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::ABSTIME::INT4 BETWEEN '%b' \ |
| 34 | # AND '%e'" |