Browse Source

Remove single star data

master
venkataakhil 1 year ago
parent
commit
29f28f1fa9
  1. 56
      smart_service/apis/master_api.py

56
smart_service/apis/master_api.py

@ -9,6 +9,7 @@ from frappe.utils import cstr
import datetime
from smart_service.apis.app_user_login import input_validation
import os
import re
current_db_name = frappe.conf.get("db_name")
site_name = cstr(frappe.local.site)
@ -474,13 +475,12 @@ def remove_extra_spaces_in_file_path():
def return_star_data():
data = frappe.db.sql('''
select content_type,content,name,parent,replace(content,'**','abcxyz ') as new_content from tabProcedure_Details ;
select content_type,content,name,parent,replace(content,'*','abcxyz ') as new_content from tabProcedure_Details where content like "%*%";
''', as_dict=1)
return data
def change_star_data():
import re
count = frappe.db.sql('''
select count(*) from tabProcedure_Details where content like '%**%';
''', as_dict=1)
@ -510,7 +510,7 @@ def change_star_data():
except Exception as e:
error_list.append({v['name']: e})
updated_list.append(v)
content_file = base_path + "/files/json_files/content_update.json"
error_file = base_path + "/files/json_files/content_error.json"
@ -525,3 +525,53 @@ def change_star_data():
except:
pass
return content_file
def change_single_star_data():
count = frappe.db.sql('''
select count(*) from tabProcedure_Details where content like "%*%";''', as_dict=1)
print(count)
# updated_list = []
# error_list = []
# data = frappe.db.sql('''
# select parent,step_name,content_type,content,name,replace(content,'*','abcxyz ') as new_content from tabProcedure_Details where content like "%*%";
# ''', as_dict=1)
# for v in data:
# try:
# result = re.split(r"abcxyz ", v['new_content'], flags=0)
# sts = '<ul>'
# if result[0] == '' and len(result) > 2:
# for a in range(1, len(result)):
# sts += '<li>' + result[a] + '</li> '
# sts += '</ul>'
# # print(sts)
# else:
# sts += '<li>' + result[1] + '</li> '
# sts += '</ul>'
# # print(sts)
# frappe.db.sql(
# f'''update tabProcedure_Details set content = "{sts}" where name = '{v['name']}'; ''')
# frappe.db.commit()
# v['new_content'] = sts
# updated_list.append(v)
# except Exception as e:
# error_list.append({v['name']: e})
# content_file = base_path + "/files/json_files/content_single_star_update.json"
# error_file = base_path + "/files/json_files/content_error_single_star.json"
# with open(error_file, 'w') as outfile:
# try:
# outfile.write(json.dumps(error_list))
# except:
# pass
# with open(content_file, 'w') as outfile:
# try:
# outfile.write(json.dumps(updated_list))
# except:
# pass
# return content_file

Loading…
Cancel
Save