Skip to content

Commit

Permalink
Merge pull request #34 from Code4GovTech/sasi_dev_v2fix
Browse files Browse the repository at this point in the history
code revert
  • Loading branch information
karntrehan authored Jul 18, 2024
2 parents 00b5cd9 + ef3a6b3 commit 0b292ff
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
6 changes: 4 additions & 2 deletions v2_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ def get_issues_by_owner_id_v2(owner, issue):

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

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

if not response.data:
return jsonify({'error': "No data found"}), 500
print(f"dmp_issue_id....{response}....{dmp_issue_id}")
return jsonify({'error': "No data found in dmp_issue_updates"}), 500

data = response.data

Expand Down
24 changes: 23 additions & 1 deletion v2_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,29 @@ def define_link_data(usernames):
logging.info(f"{e}---define_link_data")
return []

def remove_unmatched_tags(text):
try:
# Remove unmatched closing tags at the beginning of the string
text = re.sub(r'^\s*</[^>]+>\s*', '', text)

# Regex pattern to find matched or unmatched tags
pattern = re.compile(r'(<([^>]+)>.*?</\2>)|(<[^/][^>]*>.*)', re.DOTALL)
matches = pattern.findall(text)

cleaned_text = ''
for match in matches:
if match[0]: # Full matched <tag>...</tag> pairs
cleaned_text += match[0]
elif match[2]: # Unmatched opening <tag> tags
cleaned_text += match[2]

return cleaned_text
except Exception as e:
print(e)
return text




def week_data_formatter(html_content, type):

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

})
return weekly_updates
Expand Down

0 comments on commit 0b292ff

Please sign in to comment.