@ -166,7 +166,7 @@ def check_all_vehicle_updates1(vehicle_list=None):
@frappe . whitelist ( )
def check_all_vehicle_updates ( vehicle_list = None ) :
# frappe.log_error('request' + str(vehicle_list) )
frappe . log_error ( ' request ' + str ( vehicle_list ) )
rate_res = custom_rate_limit ( limit = 5 , seconds = 15 )
if rate_res != 1 :
return rate_res
@ -262,7 +262,7 @@ def check_all_vehicle_updates(vehicle_list=None):
language = ' {} ' and publish_status = ' Published ' and publish_type = ' {} ' and vehicle_status = ' Active ' and version > ' {} ' and publish_module = ' Automotive System '
order by version ASC ; ''' .format(v_id, lang, publish_type[0][0], current_version), as_dict=1)
frappe . log_error (
' check_ful_inter_else ' + str ( data ) )
' check_ful_inter_else ' + str ( data ) )
publish_dec = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
and publish_status = ' Published ' and publish_type = ' Global ' and vehicle_status = ' Active ' and version = ' {} ' and publish_module = ' Automotive System '
order by version ASC ; ''' .format(v_id, lang, data1[0][ ' version ' ]), as_dict=1)
@ -635,7 +635,7 @@ def check_vehicle_update_error(vehicle_list=None):
FROM ` tabPublish ` where vehicle = ' {} ' and language = ' {} ' and publish_status = ' Published ' and publish_type = ' Global '
and vehicle_status = ' Active ' and publish_module = ' Automotive System '
order by version ASC ; ''' .format(vehicle, l_id), as_dict=1)
frappe . log_error ( ' global_req ' + str ( data1_global ) )
frappe . log_error ( ' global_req ' + str ( data1_global ) )
# 22
data1 = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language,release_description as description FROM `tabPublish`
@ -903,89 +903,6 @@ def check_vehicle_update_error(vehicle_list=None):
return { STATUS : 0 , ERROR : " Check Parameter: vehicle list " }
@frappe . whitelist ( )
def check_all_vehicle_updates ( vehicle_list = None ) :
rate_res = custom_rate_limit ( limit = 5 , seconds = 15 )
if rate_res != 1 :
return rate_res
# if vehicle_list == None:
# return {STATUS: 0, ERROR: "Parameter missing: Vehicle List"}
val = input_validation ( vehicle_list = vehicle_list )
if val != ' ' :
return { STATUS : 0 , ERROR : PARAM_MISSING + val }
if vehicle_list :
try :
vehicle_req_list = [ ]
response = { }
v_list = json . loads ( vehicle_list )
lang = v_list [ ' LanguageID ' ]
iid = v_list [ ' InstallationId ' ]
vehicle_data = v_list [ ' VehicleReqList ' ]
publish_type = frappe . db . sql (
''' SELECT publish_type FROM `tabApp Device` where name= ' {} ' ; ''' . format ( iid ) , as_list = 1 )
if publish_type [ 0 ] [ 0 ] is not None :
if vehicle_data :
for v in vehicle_data :
v_id = v [ ' Vehicle ' ]
current_version = float ( v [ CUR_VERSION ] )
data1_global = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
and publish_status = ' Published ' and publish_type = ' Global ' and vehicle_status = ' Active '
and publish_module = ' Automotive System '
order by version ASC ; ''' .format(v_id, lang), as_dict=1)
data1 = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
and publish_status = ' Published ' and publish_type = ' {} ' and vehicle_status = ' Active '
and publish_module = ' Automotive System '
order by version ASC ; ''' .format(v_id, lang, publish_type[0][0]), as_dict=1)
if data1 [ 0 ] [ ' version ' ] is not None :
if current_version == float ( data1 [ 0 ] [ ' version ' ] ) :
data1 [ 0 ] [ UPDATE_AVAILABLE ] = " false "
vehicle_req_list . append ( data1 )
else :
if current_version < float ( data1_global [ 0 ] [ ' version ' ] ) :
data = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
and publish_status = ' Published ' and publish_type = ' Global ' and vehicle_status = ' Active ' and version > ' {} '
and publish_module = ' Automotive System '
order by version ASC ; ''' .format(v_id, lang, current_version), as_dict=1)
elif current_version == float ( data1_global [ 0 ] [ ' version ' ] ) :
if current_version < float ( data1 [ 0 ] [ ' version ' ] ) :
data = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and
language = ' {} ' and publish_status = ' Published ' and publish_type = ' {} ' and vehicle_status = ' Active ' and version > ' {} '
and publish_module = ' Automotive System '
order by version ASC ; ''' .format(v_id, lang, publish_type[0][0], current_version), as_dict=1)
# return data
data_append = [ ]
try :
for d in data :
d [ UPDATE_AVAILABLE ] = ' true '
d [ CUR_VERSION ] = float (
current_version )
data_append . append ( d )
vehicle_req_list . append ( data_append )
except :
pass
response [ ' LanguageID ' ] = lang
if len ( vehicle_req_list ) != 0 :
response [ ' VehicleReqList ' ] = vehicle_req_list [ 0 ]
return response
else :
return { STATUS : 0 , ERROR : " No Vehicles in criteria " }
else :
return { STATUS : 0 , ERROR : " Invalid Publish Details " }
else :
return { STATUS : 0 , ERROR : " Invalid Publish Details " }
except Exception as e :
return { STATUS : 0 , ERROR : " Failed to fetch updates " }
else :
return { STATUS : 0 , ERROR : " Check argument: vehicle list " }
@frappe . whitelist ( allow_guest = 1 )
def check_vehicle_update ( vehicle_list = None ) :
rate_res = custom_rate_limit ( limit = 5 , seconds = 15 )
@ -1018,7 +935,7 @@ def check_vehicle_update(vehicle_list=None):
data1_global = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and language= ' {} '
and publish_status = ' Published ' and vehicle_status = ' Active ' and publish_module = ' Automotive System '
and publish_type = ' Global ' ;
''' .format(vehicle, l_id,publish_type), as_dict=1)
''' .format(vehicle, l_id, publish_type), as_dict=1)
data1 = frappe . db . sql ( ''' SELECT name,format(max(version),2) as version,vehicle_id,language FROM `tabPublish` where vehicle= ' {} ' and language= ' {} ' and
publish_status = ' Published ' and vehicle_status = ' Active ' and
@ -1114,7 +1031,6 @@ def check_vehicle_update(vehicle_list=None):
vehicle_req_list . append (
{ ERROR : UPDATE_FAILED } )
elif current_version == float ( data1_global [ 0 ] [ ' version ' ] ) :
""" Check For only internal """
@ -1223,7 +1139,7 @@ def check_vehicle_update(vehicle_list=None):
data = frappe . db . sql ( ''' SELECT name as Name,format(version,2) as Version,vehicle_id as Vehicle,language as Language FROM `tabPublish`
where vehicle = ' {} ' and language = ' {} ' and publish_status = ' Published ' and vehicle_status = ' Active '
and publish_module = ' Automotive System '
and version = ( select max ( version ) as version from ` tabPublish ` where publish_module = ' Automotive System ' and publish_type = ' {} ' ) ''' .format(vehicle, l_id,publish_type), as_dict=1)
and version = ( select max ( version ) as version from ` tabPublish ` where publish_module = ' Automotive System ' and publish_type = ' {} ' ) ''' .format(vehicle, l_id, publish_type), as_dict=1)
try :
for d in data :
try :