瀏覽代碼

cmd_acc: check if interval is greater than 0

- if not print the report for all records
Daniel-Constantin Mierla 11 月之前
父節點
當前提交
9251f4df81
共有 1 個文件被更改,包括 10 次插入3 次删除
  1. 10 3
      kamcli/commands/cmd_acc.py

+ 10 - 3
kamcli/commands/cmd_acc.py

@@ -528,10 +528,17 @@ def acc_report(ctx, oformat, ostyle, limit, interval, name):
     """
     e = create_engine(ctx.gconfig.get("db", "rwurl"))
     ctx.vlog("Showing accounting report: " + name)
+
     query = "SELECT `src_user`, count(*) AS `count` FROM acc"
-    query = query + " WHERE DATE_SUB(NOW(), INTERVAL {0} HOUR) <= time".format(
-        interval
-    )
+
+    if interval > 0:
+        query = (
+            query
+            + " WHERE DATE_SUB(NOW(), INTERVAL {0} HOUR) <= time".format(
+                interval
+            )
+        )
+
     query = query + " GROUP BY `src_user` ORDER BY count DESC"
 
     if limit > 0: