diff --git a/smart_service/apis/update_validation.py b/smart_service/apis/update_validation.py index 0ac3cd3..665054c 100644 --- a/smart_service/apis/update_validation.py +++ b/smart_service/apis/update_validation.py @@ -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 @@ -186,7 +186,8 @@ def check_all_vehicle_updates(vehicle_list=None): vehicle_data = v_list['VehicleReqList'] publish_type = frappe.db.sql( '''SELECT publish_type FROM `tabApp Device` where name='{}';'''.format(iid), as_list=1) - + frappe.log_error('publish_type' + str(publish_type)) + frappe.log_error('iid' + str(iid)) if publish_type[0][0] is not None: if vehicle_data: for v in vehicle_data: @@ -195,8 +196,10 @@ def check_all_vehicle_updates(vehicle_list=None): data1_global = 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 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,release_description as description FROM `tabPublish` where vehicle='{}' and language='{}' - and publish_status='Published' and publish_type='{}' and vehicle_status='Active' and publish_module='Automotive System' + data1 = 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='{}' 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 publish_type[0][0] == "Global": @@ -246,6 +249,7 @@ def check_all_vehicle_updates(vehicle_list=None): data = 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='Internal' and vehicle_status='Active' and version > '{}' and publish_module='Automotive System' order by version ASC;'''.format(v_id, lang, current_version), as_dict=1) + # 22.06 frappe.log_error( 'check_ful_inter' + 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='{}' @@ -257,10 +261,15 @@ def check_all_vehicle_updates(vehicle_list=None): data = 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='{}' 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)) 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) # return data + else: + frappe.log_error( + 'check_ful_inter_else') data_append = [] rd = [] try: @@ -923,9 +932,11 @@ def check_all_vehicle_updates(vehicle_list=None): 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: @@ -936,12 +947,14 @@ def check_all_vehicle_updates(vehicle_list=None): 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 = [] @@ -1002,9 +1015,9 @@ def check_vehicle_update(vehicle_list=None): for v in vehicle_data: l_id = v['LanguageID'] current_version = float(v[CUR_VERSION]) - data1_global = frappe.db.sql('''SELECT name,format(version,2) as version,vehicle_id,language FROM `tabPublish` where vehicle='{}' and language='{}' + 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 version = (select max(version) as version from `tabPublish` where publish_module='Automotive System' and publish_type='{}') + and publish_type='Global'; '''.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 @@ -1026,10 +1039,11 @@ def check_vehicle_update(vehicle_list=None): if current_version < (float(data1_global[0]['version'])-1.00): data = frappe.db.sql('''SELECT name as Name,format(version,2) as Version,vehicle_id as Vehicle,language as Language,release_description as description FROM `tabPublish` - where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='Global' and + 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='Global')'''.format(vehicle, l_id, publish_type), as_dict=1) try: for d in data: try: @@ -1064,9 +1078,9 @@ def check_vehicle_update(vehicle_list=None): elif current_version == (float(data1_global[0]['version'])-1.00): data = frappe.db.sql('''SELECT name as Name,format(version,2) as Version,vehicle_id as Vehicle,language as Language,release_description as description FROM `tabPublish` - where vehicle='{}' and language='{}' and publish_status='Published' and publish_type='Global' and vehicle_status='Active' + 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='Global')'''.format(vehicle, l_id, publish_type), as_dict=1) try: for d in data: file_name = None @@ -1099,13 +1113,18 @@ def check_vehicle_update(vehicle_list=None): frappe.log_error('error 4', str(e)) vehicle_req_list.append( {ERROR: UPDATE_FAILED}) - + + elif current_version == float(data1_global[0]['version']): + """ Check For only internal """ + if current_version < float(data1[0]['version']): 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 + 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: @@ -1265,7 +1284,7 @@ def check_vehicle_update(vehicle_list=None): {LANGUAGE: l_id, UPDATE_AVAILABLE: 'false', CUR_VERSION: float(current_version)}) else: 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' + 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) try: