Overview over today's files.
This commit is contained in:
parent
ac07af0b6b
commit
adeefd304f
40
MosDb.py
40
MosDb.py
@ -57,9 +57,18 @@ class MosDb():
|
||||
return self.get_id("mosusers", "name", username)
|
||||
|
||||
def date_to_stamp(self, datestring):
|
||||
"""Converts given local time to UTC unix stamp
|
||||
For SQLite queries, use strftime('%s', '2017-03-08T17:46:52', 'utc')
|
||||
"""
|
||||
dt = datetime.strptime(datestring, "%Y-%m-%dT%H:%M:%S")
|
||||
return dt.timestamp()
|
||||
|
||||
def stamp_to_date(self, stamp):
|
||||
"""Converts given UTC unix stamp to local time
|
||||
"""
|
||||
dt = datetime.fromtimestamp(stamp)
|
||||
return dt.strftime("%Y-%m-%dT%H:%M:%S")
|
||||
|
||||
def add_link(self, obj_id, planning_id):
|
||||
self.db_insert_or_replace("mosobjlinks", {"objId": obj_id, "planningId": planning_id})
|
||||
|
||||
@ -138,3 +147,34 @@ class MosDb():
|
||||
self.db_insert_or_replace("moslufs", {"objId": obj_id, "lufs": lufs, "lra": lra, "ldiff": ldiff})
|
||||
self.commit()
|
||||
|
||||
def get_today_oa(self):
|
||||
"""Finds today's OA Material with LUFS values
|
||||
"""
|
||||
self.c.execute(
|
||||
"SELECT mo.objId, ml.planningId, mo.objSlug, po.created, mu.name, lu.lufs, lu.lra, lu.ldiff \
|
||||
FROM mosobjects mo \
|
||||
LEFT JOIN moslufs lu ON mo.objId=lu.objId \
|
||||
LEFT JOIN mosobjlinks ml ON mo.objId=ml.objId \
|
||||
LEFT JOIN mosobjects po ON ml.planningId=po.objId \
|
||||
LEFT JOIN mosservers ms ON mo.mosId=ms.mosId \
|
||||
LEFT JOIN mosgroups mg ON mo.groupId=mg.groupId \
|
||||
LEFT JOIN mosusers mu ON po.createdBy=mu.userId \
|
||||
WHERE mo.isDeleted=0 \
|
||||
AND ms.mosServer LIKE \"StudioA%\" \
|
||||
AND mg.objGroup=\"OA Material\" \
|
||||
AND po.created >= strftime('%s', date('now', 'start of day'))"
|
||||
)
|
||||
result = []
|
||||
for row in self.c.fetchall():
|
||||
result.append({
|
||||
"objId": row[0],
|
||||
"planningId": row[1],
|
||||
"name": row[2],
|
||||
"created": self.stamp_to_date(row[3]),
|
||||
"createdBy": row[4],
|
||||
"lu": row[5],
|
||||
"lra": row[6],
|
||||
"ldiff": row[7]
|
||||
})
|
||||
return result
|
||||
|
||||
|
51
show_today.py
Executable file
51
show_today.py
Executable file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import sys
|
||||
import MosDb
|
||||
|
||||
db = MosDb.MosDb()
|
||||
|
||||
items = db.get_today_oa()
|
||||
db.finish()
|
||||
|
||||
longest_name = 9
|
||||
longest_author = 5
|
||||
for i in items:
|
||||
if len(i["name"]) > longest_name:
|
||||
longest_name = len(i["name"])
|
||||
if len(i["createdBy"]) > longest_author:
|
||||
longest_author = len(i["createdBy"])
|
||||
|
||||
# Output table
|
||||
output_text = ("{:19} | {:" + str(longest_name) + "} | {:" + str(longest_author) + "} | {:>5} | {:>5} | {:>5}\n").format(
|
||||
"Datum",
|
||||
"OnAir-MAZ",
|
||||
"Autor",
|
||||
"LUFS",
|
||||
"LRA",
|
||||
"±LU"
|
||||
)
|
||||
output_text += ("{:-<19} | {:-<" + str(longest_name) + "} | {:-<" + str(longest_author) + "} | {:->5} | {:->5} | {:->5}\n").format("", "", "", "", "", "")
|
||||
for i in items:
|
||||
print(repr(i))
|
||||
lu = i["lu"]
|
||||
if lu is None:
|
||||
lu = "-"
|
||||
lra = i["lra"]
|
||||
if lra is None:
|
||||
lra = "-"
|
||||
ldiff = i["ldiff"]
|
||||
if ldiff is None:
|
||||
ldiff = "-"
|
||||
output_text += ("{} | {:" + str(longest_name) + "} | {:" + str(longest_author) + "} | {:>5} | {:>5} | {:>5}\n").format(
|
||||
i["created"],
|
||||
i["name"],
|
||||
i["createdBy"],
|
||||
lu,
|
||||
lra,
|
||||
ldiff
|
||||
)
|
||||
|
||||
print(output_text)
|
Loading…
x
Reference in New Issue
Block a user