Browse Source

Model hit& download query order by fix

master
administrator 11 months ago
parent
commit
f9dddd6d60
  1. 2
      smart_service/add_ons/report/model_download_report/model_download_report.py
  2. 5
      smart_service/add_ons/report/model_hit_report/model_hit_report.py

2
smart_service/add_ons/report/model_download_report/model_download_report.py

@ -27,7 +27,7 @@ def get_data(filters):
login_name,concat(first_name,' ',last_name) as user_name login_name,concat(first_name,' ',last_name) as user_name
FROM `tabModel Hit` mh FROM `tabModel Hit` mh
left join `tabApp Users` au on mh.user_id = au.user_id 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 ORDER BY date DESC;""".format(current_db_name, WHERE download_vehicle_id='{1}' and (date(date) between '{2}' and '{3}') ORDER BY download_vehicle_id,date DESC;""".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:

5
smart_service/add_ons/report/model_hit_report/model_hit_report.py

@ -31,7 +31,7 @@ def get_data(filters):
count(*) as count, user_id, language FROM {0}.`tabModel Usage` WHERE vehicle_id='{1}' and variant_id='{2}' and (date(date) between '{3}' and '{4}') count(*) as count, user_id, language FROM {0}.`tabModel Usage` 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, system_id, sub_system_id, procedure_id, steps_id, 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 language
order by module_id,vehicle_id, variant_id, variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id,language ORDER BY date DESC; order by module_id,vehicle_id, variant_id, variant_mapping_id, system_id, sub_system_id, procedure_id, steps_id,language,date DESC;
""".format(current_db_name, modelfilter, variantfilter[1], from_date, to_date), as_dict=1) """.format(current_db_name, modelfilter, variantfilter[1], from_date, to_date), as_dict=1)
for d in data: for d in data:
@ -104,7 +104,8 @@ def get_data(filters):
try: try:
dealer_info=frappe.db.sql("""SELECT dealer FROM {0}.`tabApp Users` where user_id='{1}';""".format(current_db_name, d['user_id']), as_dict=1) dealer_info=frappe.db.sql("""SELECT dealer FROM {0}.`tabApp Users` where user_id='{1}';""".format(current_db_name, d['user_id']), as_dict=1)
dealer_info=dealer_info[-1]['dealer'] dealer_info=dealer_info[-1]['dealer']
dealer_details=frappe.db.sql("""SELECT dealer_name,dealer_code,area as location,zone FROM {0}.`tabApp Dealer` where name='{1}';""".format(current_db_name, dealer_info), as_dict=1) dealer_details=frappe.db.sql("""SELECT dealer_name,dealer_code,area as location,zone FROM {0}.`tabApp Dealer`
where name='{1}';""".format(current_db_name, dealer_info), as_dict=1)
dealer_details=dealer_details[-1] dealer_details=dealer_details[-1]
d['dealer_code']=dealer_details['dealer_code'] d['dealer_code']=dealer_details['dealer_code']
d['dealer_name']=dealer_details['dealer_name'] d['dealer_name']=dealer_details['dealer_name']

Loading…
Cancel
Save