mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-04 04:39:11 +00:00
style: format code with black
This commit is contained in:
@@ -16,91 +16,51 @@ def execute(filters=None):
|
||||
chart_data, summary = get_chart_summary_data(data)
|
||||
return columns, data, None, chart_data, summary
|
||||
|
||||
|
||||
def get_columns():
|
||||
return [
|
||||
{
|
||||
"label": _("Published Date"),
|
||||
"fieldname": "publish_date",
|
||||
"fieldtype": "Date",
|
||||
"width": 100
|
||||
},
|
||||
{
|
||||
"label": _("Title"),
|
||||
"fieldname": "title",
|
||||
"fieldtype": "Data",
|
||||
"width": 200
|
||||
},
|
||||
{
|
||||
"label": _("Duration"),
|
||||
"fieldname": "duration",
|
||||
"fieldtype": "Duration",
|
||||
"width": 100
|
||||
},
|
||||
{
|
||||
"label": _("Views"),
|
||||
"fieldname": "view_count",
|
||||
"fieldtype": "Float",
|
||||
"width": 200
|
||||
},
|
||||
{
|
||||
"label": _("Likes"),
|
||||
"fieldname": "like_count",
|
||||
"fieldtype": "Float",
|
||||
"width": 200
|
||||
},
|
||||
{
|
||||
"label": _("Dislikes"),
|
||||
"fieldname": "dislike_count",
|
||||
"fieldtype": "Float",
|
||||
"width": 100
|
||||
},
|
||||
{
|
||||
"label": _("Comments"),
|
||||
"fieldname": "comment_count",
|
||||
"fieldtype": "Float",
|
||||
"width": 100
|
||||
}
|
||||
{"label": _("Published Date"), "fieldname": "publish_date", "fieldtype": "Date", "width": 100},
|
||||
{"label": _("Title"), "fieldname": "title", "fieldtype": "Data", "width": 200},
|
||||
{"label": _("Duration"), "fieldname": "duration", "fieldtype": "Duration", "width": 100},
|
||||
{"label": _("Views"), "fieldname": "view_count", "fieldtype": "Float", "width": 200},
|
||||
{"label": _("Likes"), "fieldname": "like_count", "fieldtype": "Float", "width": 200},
|
||||
{"label": _("Dislikes"), "fieldname": "dislike_count", "fieldtype": "Float", "width": 100},
|
||||
{"label": _("Comments"), "fieldname": "comment_count", "fieldtype": "Float", "width": 100},
|
||||
]
|
||||
|
||||
|
||||
def get_data(filters):
|
||||
return frappe.db.sql("""
|
||||
return frappe.db.sql(
|
||||
"""
|
||||
SELECT
|
||||
publish_date, title, provider, duration,
|
||||
view_count, like_count, dislike_count, comment_count
|
||||
FROM `tabVideo`
|
||||
WHERE view_count is not null
|
||||
and publish_date between %(from_date)s and %(to_date)s
|
||||
ORDER BY view_count desc""", filters, as_dict=1)
|
||||
ORDER BY view_count desc""",
|
||||
filters,
|
||||
as_dict=1,
|
||||
)
|
||||
|
||||
|
||||
def get_chart_summary_data(data):
|
||||
labels, likes, views = [], [], []
|
||||
total_views = 0
|
||||
|
||||
for row in data:
|
||||
labels.append(row.get('title'))
|
||||
likes.append(row.get('like_count'))
|
||||
views.append(row.get('view_count'))
|
||||
total_views += flt(row.get('view_count'))
|
||||
|
||||
labels.append(row.get("title"))
|
||||
likes.append(row.get("like_count"))
|
||||
views.append(row.get("view_count"))
|
||||
total_views += flt(row.get("view_count"))
|
||||
|
||||
chart_data = {
|
||||
"data" : {
|
||||
"labels" : labels,
|
||||
"datasets" : [
|
||||
{
|
||||
"name" : "Likes",
|
||||
"values" : likes
|
||||
},
|
||||
{
|
||||
"name" : "Views",
|
||||
"values" : views
|
||||
}
|
||||
]
|
||||
"data": {
|
||||
"labels": labels,
|
||||
"datasets": [{"name": "Likes", "values": likes}, {"name": "Views", "values": views}],
|
||||
},
|
||||
"type": "bar",
|
||||
"barOptions": {
|
||||
"stacked": 1
|
||||
},
|
||||
"barOptions": {"stacked": 1},
|
||||
}
|
||||
|
||||
summary = [
|
||||
|
||||
Reference in New Issue
Block a user