@ -21,21 +21,20 @@ def get_data(filters):
from_date = filters [ ' from_date ' ]
from_date = filters [ ' from_date ' ]
to_date = filters [ ' to_date ' ]
to_date = filters [ ' to_date ' ]
modelfilter = filters [ ' model ' ]
modelfilter = filters [ ' model ' ]
# try:
# vId=frappe.db.sql("""SELECT myid FROM _d6463952657fa86c.tabVehicle where vehicle='{0}';""".format(modelfilter), as_dict=1)
data = frappe . db . sql ( """ SELECT date(date) as date, device_id, device_type, app_version, download_vehicle_id, download_vehicle_version,
# vId=vId[-1]
download_vehicle_date , download_vehicle_language_id , download_vehicle_current_version , user_id
# vId=vId['myid']
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,
# except:
modelfilter , from_date , to_date ) , as_dict = 1 )
# frappe.msgprint('Vehicle ID Mismatching.')
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
FROM { 0 } . ` tabModel Hit ` WHERE download_vehicle_id = ' {1} ' and ( date ( date ) between ' {2} ' and ' {3} ' ) ; """ .format(current_db_name, modelfilter, from_date, to_date), as_dict=1)
for d in data :
for d in data :
d [ ' download_vehicle_id ' ] = modelfilter
d [ ' download_vehicle_id ' ] = modelfilter
if d [ ' user_id ' ] :
if d [ ' user_id ' ] :
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 ' ]
@ -53,16 +52,16 @@ def get_data(filters):
def get_columns ( ) :
def get_columns ( ) :
columns = [
columns = [
{ " label " : _ ( " <b>Date</b> " ) , " fieldname " : " date " , " fieldtype " : " Date " , " width " : 100 } ,
{ " label " : _ ( " <b>Date</b> " ) , " fieldname " : " date " , " fieldtype " : " Date " , " width " : 100 } ,
{ " label " : _ ( " <b>Downloaded Vehicle</b> " ) , " fieldname " : " download_vehicle_id " , " fieldtype " : " Data " , " width " : 170 } ,
{ " label " : _ ( " <b>Downloaded Version</b> " ) , " fieldname " : " download_vehicle_current_version " , " fieldtype " : " Data " , " width " : 150 } ,
{ " label " : _ ( " <b>Downloaded Language</b> " ) , " fieldname " : " download_vehicle_language_id " , " fieldtype " : " Data " , " width " : 150 } ,
{ " label " : _ ( " <b>App Version</b> " ) , " fieldname " : " app_version " , " fieldtype " : " Data " , " width " : 150 } ,
{ " label " : _ ( " <b>Zone</b> " ) , " fieldname " : " zone " , " fieldtype " : " Data " , " width " : 100 } ,
{ " label " : _ ( " <b>Zone</b> " ) , " fieldname " : " zone " , " fieldtype " : " Data " , " width " : 100 } ,
{ " 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 } ,
{ " label " : _ ( " <b>Dealer Name</b> " ) , " fieldname " : " dealer_name " , " fieldtype " : " Data " , " width " : 150 } ,
{ " label " : _ ( " <b>Dealer Name</b> " ) , " fieldname " : " dealer_name " , " fieldtype " : " Data " , " width " : 150 } ,
{ " label " : _ ( " <b>Device</b> " ) , " fieldname " : " device_id " , " fieldtype " : " Data " , " width " : 100 } ,
{ " label " : _ ( " <b>Device</b> " ) , " fieldname " : " device_id " , " fieldtype " : " Data " , " width " : 100 } ,
{ " label " : _ ( " <b>Device Type</b> " ) , " fieldname " : " device_type " , " fieldtype " : " Data " , " width " : 130 } ,
{ " label " : _ ( " <b>Device Type</b> " ) , " fieldname " : " device_type " , " fieldtype " : " Data " , " width " : 130 }
{ " label " : _ ( " <b>Downloaded Vehicle</b> " ) , " fieldname " : " download_vehicle_id " , " fieldtype " : " Data " , " width " : 170 } ,
{ " label " : _ ( " <b>Downloaded Version</b> " ) , " fieldname " : " download_vehicle_current_version " , " fieldtype " : " Data " , " width " : 150 } ,
{ " label " : _ ( " <b>Downloaded Language</b> " ) , " fieldname " : " download_vehicle_language_id " , " fieldtype " : " Data " , " width " : 150 } ,
{ " label " : _ ( " <b>App Version</b> " ) , " fieldname " : " app_version " , " fieldtype " : " Data " , " width " : 150 }
]
]
return columns
return columns