This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
forked from MDGrey33/Nur
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
316 additions
and
513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import requests | ||
import logging | ||
|
||
|
||
def post_request(url, payload, headers=None, data_type=None): | ||
""" | ||
Post a request to a given URL. | ||
:param data_type: Type of payload data. | ||
:param url: The URL to post to. | ||
:param payload: The payload to send. | ||
:param headers: The headers to send. | ||
:return: The response from the server. | ||
""" | ||
if headers is None: | ||
headers = {"Content-Type": "application/json"} | ||
try: | ||
response = requests.post(url, json=payload, headers=headers) | ||
response.raise_for_status() | ||
logging.info(f"INFO: {data_type} request submitted to {url}") | ||
except requests.exceptions.HTTPError as e: | ||
logging.error(f"ERROR: An HTTP error with {data_type} request occurred: {e}") | ||
except Exception as e: | ||
logging.error(f"ERROR: An error with {data_type} request occurred: {e}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,22 @@ | ||
from sqlalchemy.exc import SQLAlchemyError | ||
from models.bookmarked_conversation import BookmarkedConversation | ||
from datetime import datetime, timezone | ||
|
||
|
||
class BookmarkedConversationManager: | ||
def __init__(self, db_session): | ||
self.db_session = db_session | ||
def __init__(self, session): | ||
self.session = session | ||
|
||
def add_bookmarked_conversation(self, title, body, thread_id): | ||
with self.db_session as session: | ||
BookmarkedConversation().create_or_update(session, | ||
title=title, | ||
body=body, | ||
thread_id=thread_id) | ||
BookmarkedConversation().create_or_update(self.session, | ||
title=title, | ||
body=body, | ||
thread_id=thread_id) | ||
|
||
def update_posted_on_confluence(self, thread_id): | ||
with self.db_session as session: | ||
BookmarkedConversation().create_or_update(session, | ||
thread_id=thread_id, | ||
posted_on_confluence=datetime.now(timezone.utc)) | ||
BookmarkedConversation().create_or_update(self.session, | ||
thread_id=thread_id, | ||
posted_on_confluence=datetime.now(timezone.utc)) | ||
print(f"Updated conversation with thread ID {thread_id} with timestamp") | ||
|
||
def get_unposted_conversations(self): | ||
try: | ||
with self.db_session as session: | ||
return session.query(BookmarkedConversation).filter_by(posted_on_confluence=None).all() | ||
except SQLAlchemyError as e: | ||
print(f"Error getting unposted conversations: {e}") | ||
return None | ||
return self.session.query(BookmarkedConversation).filter_by(posted_on_confluence=None).all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.