Skip to content

Commit 0b292ff

Browse files
authored
Merge pull request #34 from Code4GovTech/sasi_dev_v2fix
code revert
2 parents 00b5cd9 + ef3a6b3 commit 0b292ff

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

v2_app.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ def get_issues_by_owner_id_v2(owner, issue):
2727

2828
dmp_issue_id = SUPABASE_DB.client.table('dmp_issues').select('*').like('issue_url', f'%{url}%').eq('id', issue).execute()
2929
if not dmp_issue_id.data:
30-
return jsonify({'error': "No data found"}), 500
30+
print(f"url....{url}....{issue}")
31+
return jsonify({'error': "No data found in dmp_issue"}), 500
3132

3233
dmp_issue_id = dmp_issue_id.data[0]
3334
response = SUPABASE_DB.client.table('dmp_issue_updates').select('*').eq('dmp_id', dmp_issue_id['id']).execute()
3435

3536
if not response.data:
36-
return jsonify({'error': "No data found"}), 500
37+
print(f"dmp_issue_id....{response}....{dmp_issue_id}")
38+
return jsonify({'error': "No data found in dmp_issue_updates"}), 500
3739

3840
data = response.data
3941

v2_utils.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,29 @@ def define_link_data(usernames):
2727
logging.info(f"{e}---define_link_data")
2828
return []
2929

30+
def remove_unmatched_tags(text):
31+
try:
32+
# Remove unmatched closing tags at the beginning of the string
33+
text = re.sub(r'^\s*</[^>]+>\s*', '', text)
34+
35+
# Regex pattern to find matched or unmatched tags
36+
pattern = re.compile(r'(<([^>]+)>.*?</\2>)|(<[^/][^>]*>.*)', re.DOTALL)
37+
matches = pattern.findall(text)
38+
39+
cleaned_text = ''
40+
for match in matches:
41+
if match[0]: # Full matched <tag>...</tag> pairs
42+
cleaned_text += match[0]
43+
elif match[2]: # Unmatched opening <tag> tags
44+
cleaned_text += match[2]
3045

46+
return cleaned_text
47+
except Exception as e:
48+
print(e)
49+
return text
50+
51+
52+
3153

3254
def week_data_formatter(html_content, type):
3355

@@ -46,7 +68,7 @@ def week_data_formatter(html_content, type):
4668
task_list_html = tasks_per_week[i] if i < len(tasks_per_week) else ""
4769
weekly_updates.append({
4870
'week': i + 1,
49-
'content': re.sub(r'<[^>]+>', '',task_list_html).strip()
71+
'content': remove_unmatched_tags(task_list_html)
5072

5173
})
5274
return weekly_updates

0 commit comments

Comments
 (0)