Skip to content

Commit

Permalink
cmd_acc: check if interval is greater than 0
Browse files Browse the repository at this point in the history
- if not print the report for all records
  • Loading branch information
miconda committed Oct 14, 2024
1 parent f04c6b1 commit 9251f4d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions kamcli/commands/cmd_acc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 9251f4d

Please sign in to comment.