浏览代码

cmd_acc: added command to list missed calls records

Daniel-Constantin Mierla 11 月之前
父节点
当前提交
13679f78af
共有 1 个文件被更改,包括 45 次插入0 次删除
  1. 45 0
      kamcli/commands/cmd_acc.py

+ 45 - 0
kamcli/commands/cmd_acc.py

@@ -231,6 +231,51 @@ def acc_list(ctx, oformat, ostyle, limit):
     ioutils_dbres_print(ctx, oformat, ostyle, res)
 
 
[email protected](
+    "mc-list",
+    short_help="List missed calls records",
+)
[email protected](
+    "oformat",
+    "--output-format",
+    "-F",
+    type=click.Choice(["raw", "json", "table", "dict"]),
+    default=None,
+    help="Format the output",
+)
[email protected](
+    "ostyle",
+    "--output-style",
+    "-S",
+    default=None,
+    help="Style of the output (tabulate table format)",
+)
[email protected](
+    "limit",
+    "--limit",
+    "-l",
+    type=int,
+    default=20,
+    help="The limit of listed records (default: 20)",
+)
+@pass_context
+def acc_mc_list(ctx, oformat, ostyle, limit):
+    """List missed calls records
+
+    \b
+    """
+    e = create_engine(ctx.gconfig.get("db", "rwurl"))
+    ctx.vlog("Showing missed calls records")
+    query = ""
+    if limit == 0:
+        query = "select * from missed_calls order by id desc"
+    else:
+        query = "select * from missed_calls order by id desc limit {0}".format(limit)
+    res = e.execute(query)
+    ioutils_dbres_print(ctx, oformat, ostyle, res)
+
+
+
 @cli.command(
     "cdrs-generate",
     short_help="Run SQL stored procedure to generate CDRS",