Browse Source

Model hit and usage add username and used id

master
venkataakhil 1 year ago
parent
commit
14d451b301
  1. 9
      smart_service/add_ons/report/model_download_report/model_download_report.py
  2. 8
      smart_service/add_ons/report/model_hit_report/model_hit_report.py

9
smart_service/add_ons/report/model_download_report/model_download_report.py

@ -23,8 +23,11 @@ def get_data(filters):
modelfilter=filters['model'] modelfilter=filters['model']
data = frappe.db.sql("""SELECT date(date) as date, device_id, device_type, app_version, download_vehicle_id, download_vehicle_version, data = frappe.db.sql("""SELECT date(date) as date, device_id, device_type, app_version, download_vehicle_id, download_vehicle_version,
download_vehicle_date, download_vehicle_language_id, download_vehicle_current_version, user_id download_vehicle_date, download_vehicle_language_id, download_vehicle_current_version, mh.user_id,
FROM {0}.`tabModel Hit` WHERE download_vehicle_id='{1}' and (date(date) between '{2}' and '{3}') order by download_vehicle_id;""".format(current_db_name, login_name,concat(first_name,' ',last_name) as user_name
FROM `tabModel Hit` mh
left join `tabApp Users` au on mh.user_id = au.user_id
WHERE download_vehicle_id='{1}' and (date(date) between '{2}' and '{3}') order by download_vehicle_id;""".format(current_db_name,
modelfilter, from_date, to_date), as_dict=1) modelfilter, from_date, to_date), as_dict=1)
for d in data: for d in data:
@ -52,6 +55,8 @@ def get_data(filters):
def get_columns(): def get_columns():
columns = [ columns = [
{"label": _("<b>Date</b>"), "fieldname": "date", "fieldtype": "Date", "width": 150}, {"label": _("<b>Date</b>"), "fieldname": "date", "fieldtype": "Date", "width": 150},
{"label": _("<b>User ID</b>"), "fieldname": "login_name", "fieldtype": "Data", "width": 125},
{"label": _("<b>User Name</b>"), "fieldname": "user_name", "fieldtype": "Data", "width": 125},
{"label": _("<b>Downloaded Vehicle</b>"), "fieldname": "download_vehicle_id", "fieldtype": "Data", "width": 150}, {"label": _("<b>Downloaded Vehicle</b>"), "fieldname": "download_vehicle_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Downloaded Language</b>"), "fieldname": "download_vehicle_language_id", "fieldtype": "Data", "width": 150}, {"label": _("<b>Downloaded Language</b>"), "fieldname": "download_vehicle_language_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Downloaded Version</b>"), "fieldname": "download_vehicle_current_version", "fieldtype": "Data", "width": 150}, {"label": _("<b>Downloaded Version</b>"), "fieldname": "download_vehicle_current_version", "fieldtype": "Data", "width": 150},

8
smart_service/add_ons/report/model_hit_report/model_hit_report.py

@ -90,7 +90,10 @@ def get_data(filters):
variantfilter=filters['variant'] variantfilter=filters['variant']
variantfilter=variantfilter.split(".") variantfilter=variantfilter.split(".")
data = frappe.db.sql("""SELECT date as date, device_id, device_type, module_id, vehicle_id, variant_id,variant_mapping_id, system_id, sub_system_id, data = frappe.db.sql("""SELECT date as date, device_id, device_type, module_id, vehicle_id, variant_id,variant_mapping_id, system_id, sub_system_id,
procedure_id, steps_id, count(*) as count, user_id, language FROM {0}.`tabModel Usage` WHERE vehicle_id='{1}' and variant_id='{2}' procedure_id, steps_id, count(*) as count, user_id, language,
login_name,concat(first_name,' ',last_name) as user_name
FROM `tabModel Usage` mu left join `tabApp Users` au on mu.user_id = au.user_id
WHERE vehicle_id='{1}' and variant_id='{2}'
and (date(date) between '{3}' and '{4}') GROUP BY date(date), user_id, module_id, device_id, vehicle_id, variant_id, variant_mapping_id, and (date(date) between '{3}' and '{4}') GROUP BY date(date), user_id, module_id, device_id, vehicle_id, variant_id, variant_mapping_id,
system_id, sub_system_id, procedure_id, steps_id, language system_id, sub_system_id, procedure_id, steps_id, language
order by module_id,vehicle_id, variant_id, variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id,language; order by module_id,vehicle_id, variant_id, variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id,language;
@ -119,6 +122,8 @@ def get_data(filters):
def get_columns(): def get_columns():
columns = [ columns = [
{"label": _("<b>Date</b>"), "fieldname": "date", "fieldtype": "Date", "width": 150}, {"label": _("<b>Date</b>"), "fieldname": "date", "fieldtype": "Date", "width": 150},
{"label": _("<b>User ID</b>"), "fieldname": "login_name", "fieldtype": "Data", "width": 125},
{"label": _("<b>User Name</b>"), "fieldname": "user_name", "fieldtype": "Data", "width": 125},
{"label": _("<b>Model</b>"), "fieldname": "vehicle_id", "fieldtype": "Data", "width": 150}, {"label": _("<b>Model</b>"), "fieldname": "vehicle_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Variant Mapping</b>"), "fieldname": "variant_mapping_id", "fieldtype": "Data", "width": 150}, {"label": _("<b>Variant Mapping</b>"), "fieldname": "variant_mapping_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Variant</b>"), "fieldname": "variant_id", "fieldtype": "Data", "width": 80}, {"label": _("<b>Variant</b>"), "fieldname": "variant_id", "fieldtype": "Data", "width": 80},
@ -129,6 +134,7 @@ def get_columns():
{"label": _("<b>Steps</b>"), "fieldname": "steps_id", "fieldtype": "Data", "width": 150}, {"label": _("<b>Steps</b>"), "fieldname": "steps_id", "fieldtype": "Data", "width": 150},
{"label": _("<b>Language</b>"), "fieldname": "language", "fieldtype": "Data", "width": 80}, {"label": _("<b>Language</b>"), "fieldname": "language", "fieldtype": "Data", "width": 80},
{"label": _("<b>Count</b>"), "fieldname": "count", "fieldtype": "Data", "width": 80}, {"label": _("<b>Count</b>"), "fieldname": "count", "fieldtype": "Data", "width": 80},
# {"label": _("<b>Zone</b>"), "fieldname": "zone", "fieldtype": "Data", "width": 150}, # {"label": _("<b>Zone</b>"), "fieldname": "zone", "fieldtype": "Data", "width": 150},
# {"label": _("<b>Area Office</b>"), "fieldname": "area", "fieldtype": "Data", "width": 150}, # {"label": _("<b>Area Office</b>"), "fieldname": "area", "fieldtype": "Data", "width": 150},
# {"label": _("<b>Dealer Code</b>"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 150}, # {"label": _("<b>Dealer Code</b>"), "fieldname": "dealer_code", "fieldtype": "Data", "width": 150},

Loading…
Cancel
Save