瀏覽代碼

cmd_acc: provide rate_group parameter for rates generate command

- GH #20
Daniel-Constantin Mierla 1 年之前
父節點
當前提交
16ec96c6aa
共有 1 個文件被更改,包括 13 次插入3 次删除
  1. 13 3
      kamcli/commands/cmd_acc.py

+ 13 - 3
kamcli/commands/cmd_acc.py

@@ -413,14 +413,24 @@ def acc_rates_proc_create(ctx):
     "rates-generate",
     help="Run SQL stored procedure to rate the CDRS and generate the costs",
 )
[email protected]("rate_group", nargs=-1, metavar="[<rate_group>]")
 @pass_context
-def acc_rates_generate(ctx):
-    """Run SQL stored procedure to rate the CDRS and generate the costs"""
+def acc_rates_generate(ctx, rate_group):
+    """Run SQL stored procedure to rate the CDRS and generate the costs
+
+    \b
+    Parameters:
+        <rate_group> - name of rating group
+    """
     ctx.vlog(
         "Run SQL stored procedure to rate the CDRS and generate the costs"
     )
     e = create_engine(ctx.gconfig.get("db", "rwurl"))
     with e.connect() as c:
         t = c.begin()
-        c.execute("call kamailio_rating()")
+        if not rate_group:
+            c.execute('call kamailio_rating("default")')
+        else:
+            for rg in rate_group:
+                c.execute("call kamailio_rating({0!r})".format(rg))
         t.commit()