Improve documentation of SeenIssuesDB #34

Merged
Jmaa merged 2 commits from jmaa/issue-31-improve-documentation-of-seenissuesdb into main 2025-04-13 16:45:12 +00:00
Showing only changes of commit fc85c982b9 - Show all commits

View File

@ -15,19 +15,19 @@ DEFAULT_DB_PATH = 'output/seen_issues.db'
class SeenIssuesDB: class SeenIssuesDB:
""" """
Database handler for tracking processed issues. Database handler for tracking processed issues.
This class manages a SQLite database that stores hashes of issues that have This class manages a SQLite database that stores hashes of issues that have
already been processed. It provides methods to mark issues as seen and check already been processed. It provides methods to mark issues as seen and check
if an issue has been seen before, helping to prevent duplicate processing. if an issue has been seen before, helping to prevent duplicate processing.
Attributes: Attributes:
conn: SQLite database connection conn: SQLite database connection
""" """
def __init__(self, db_path=DEFAULT_DB_PATH): def __init__(self, db_path=DEFAULT_DB_PATH):
""" """
Initialize the database connection. Initialize the database connection.
Args: Args:
db_path: Path to the SQLite database file. Defaults to 'output/seen_issues.db'. db_path: Path to the SQLite database file. Defaults to 'output/seen_issues.db'.
""" """
@ -37,7 +37,7 @@ class SeenIssuesDB:
def _create_table(self): def _create_table(self):
""" """
Create the seen_issues table if it doesn't exist. Create the seen_issues table if it doesn't exist.
Creates a table with a single column for storing issue hashes. Creates a table with a single column for storing issue hashes.
""" """
with self.conn: with self.conn:
@ -50,10 +50,10 @@ class SeenIssuesDB:
def mark_as_seen(self, issue_text: str): def mark_as_seen(self, issue_text: str):
""" """
Mark an issue as seen in the database. Mark an issue as seen in the database.
Computes a hash of the issue text and stores it in the database. Computes a hash of the issue text and stores it in the database.
If the issue has already been marked as seen, this operation has no effect. If the issue has already been marked as seen, this operation has no effect.
Args: Args:
issue_text: The text content of the issue to mark as seen. issue_text: The text content of the issue to mark as seen.
""" """
@ -67,12 +67,12 @@ class SeenIssuesDB:
def has_seen(self, issue_text: str) -> bool: def has_seen(self, issue_text: str) -> bool:
""" """
Check if an issue has been seen before. Check if an issue has been seen before.
Computes a hash of the issue text and checks if it exists in the database. Computes a hash of the issue text and checks if it exists in the database.
Args: Args:
issue_text: The text content of the issue to check. issue_text: The text content of the issue to check.
Returns: Returns:
True if the issue has been seen before, False otherwise. True if the issue has been seen before, False otherwise.
""" """
@ -86,10 +86,10 @@ class SeenIssuesDB:
def _compute_hash(self, text: str) -> str: def _compute_hash(self, text: str) -> str:
""" """
Compute a SHA-256 hash of the given text. Compute a SHA-256 hash of the given text.
Args: Args:
text: The text to hash. text: The text to hash.
Returns: Returns:
A hexadecimal string representation of the hash. A hexadecimal string representation of the hash.
""" """