Skip to content

Commit

Permalink
Merge pull request #36 from Code4GovTech/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
karntrehan authored Jul 18, 2024
2 parents 3dd5819 + 474982f commit 8bba1d1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
8 changes: 5 additions & 3 deletions v2_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ def get_issues_by_owner_id_v2(owner, issue):
url = f"https://github.com/{repo_owner}" if repo_owner else None


dmp_issue_id = SUPABASE_DB.client.table('dmp_issues').select('*').like('issue_url', f'%{url}%').eq('id', issue).execute()
dmp_issue_id = SUPABASE_DB.client.table('dmp_issues').select('*').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
25 changes: 24 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,8 @@ 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': task_list_html.strip()
'content': remove_unmatched_tags(task_list_html)

})
return weekly_updates

Expand Down

0 comments on commit 8bba1d1

Please sign in to comment.