From a38f76c7a64ff12fb9affa07cd6f05a91d8f06b6 Mon Sep 17 00:00:00 2001 From: chriswebb09 Date: Fri, 13 Oct 2023 06:30:56 -0400 Subject: [PATCH] removed older data models --- DirectReport/commandline/commandline.py | 6 -- DirectReport/database/jira_storage.py | 71 ------------------- DirectReport/models/entry.py | 3 - DirectReport/models/jira_models/__init__.py | 0 DirectReport/models/jira_models/jira.py | 44 ------------ .../models/jira_models/jira_builder.py | 36 ---------- 6 files changed, 160 deletions(-) delete mode 100644 DirectReport/database/jira_storage.py delete mode 100644 DirectReport/models/jira_models/__init__.py delete mode 100644 DirectReport/models/jira_models/jira.py delete mode 100644 DirectReport/models/jira_models/jira_builder.py diff --git a/DirectReport/commandline/commandline.py b/DirectReport/commandline/commandline.py index 8e27c827..1f2f4ac1 100644 --- a/DirectReport/commandline/commandline.py +++ b/DirectReport/commandline/commandline.py @@ -10,7 +10,6 @@ from DirectReport.models.daily_builder import DailyBuilder from DirectReport.models.note.note_builder import NoteBuilder from DirectReport.models.blocker_models.block_builder import BlockerBuilder -from DirectReport.models.jira_models.jira_builder import JiraBuilder file = Path(__file__).resolve() package_root_directory = file.parents[1] @@ -102,11 +101,6 @@ def new(transformation): if transformation == "blocker_models": blocker = click.prompt('Blocker', type=str) BlockerBuilder.add_new_blocker(blocker, DailyBuilder.get_daily_id()) - if transformation == "jira_models": - daily_id = DailyBuilder.get_daily_id() - jira_ticket = click.prompt('Jira', type=str) - jira_tag = click.prompt('Jira', type=str) - JiraBuilder.add_new_jira(jira_ticket, jira_tag, daily_id) @click.command() diff --git a/DirectReport/database/jira_storage.py b/DirectReport/database/jira_storage.py deleted file mode 100644 index 58f32394..00000000 --- a/DirectReport/database/jira_storage.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env python3 - -import sqlite3 -import uuid -from DirectReport.models.jira_models.jira import Jira - - -class JiraDataStore: - def __init__(self, db_path, conn=None): - """ - Initializes the JiraDataStore object with the given SQLite database file path. - - :param db_path: The SQLite database file path. - """ - self.db_path = db_path - if conn is None: - self.conn = sqlite3.connect(db_path) - else: - self.conn = conn - self.create_table() - - def create_table(self): - """ - Creates the `jira_uuid_table` table in the SQLite database if it doesn't exist. - """ - cursor = self.conn.cursor() - cursor.execute( - ''' - CREATE TABLE IF NOT EXISTS jiras_uuid_table ( - uuid TEXT PRIMARY KEY, - associated_entry_uuid TEXT, - jira_tag TEXT, - jira_entry - ) - ''' - ) - self.conn.commit() - - def add_jira_entry(self, jira_tag, jira_entry, associated_entry_uuid_str, uuid_str=None): - """ - Adds a new Jira entry to the `jira_uuid_table`. - - :param jira_tag: The Jira tag. - :param jira_entry: The Jira entry. - :param associated_entry_uuid_str: The associated entry UUID as a string. - :param uuid_str: The UUID of the Jira entry as a string (optional). - :return: None - """ - if uuid_str is None: - uuid_str = str(uuid.uuid4()) - cursor = self.conn.cursor() - cursor.execute( - ''' - INSERT OR IGNORE INTO jiras_uuid_table (uuid, associated_entry_uuid, jira_tag, jira_entry) VALUES (?, ?, ?, ?) - ''', - (uuid_str, associated_entry_uuid_str, jira_tag, jira_entry), - ) - self.conn.commit() - - def entries_for_associated_uuid(self, associated_uuid): - """ - Retrieves a list of Jira entries associated with the specified UUID. - - :param associated_uuid: The UUID to retrieve Jira entries for. - :return: A list of Jira entries associated with the UUID. - """ - result = self.conn.execute( - "SELECT uuid, associated_entry_uuid, jira_tag, jira_entry FROM jiras_uuid_table WHERE associated_entry_uuid = ?", - (str(associated_uuid),), - ) - return [Jira(*row).to_dict() for row in result.fetchall()] diff --git a/DirectReport/models/entry.py b/DirectReport/models/entry.py index 546aefa3..105d2b1c 100644 --- a/DirectReport/models/entry.py +++ b/DirectReport/models/entry.py @@ -3,7 +3,6 @@ import datetime from DirectReport.models.note.note_builder import NoteBuilder from DirectReport.models.blocker_models.block_builder import BlockerBuilder -from DirectReport.models.jira_models.jira_builder import JiraBuilder class Entry: @@ -37,7 +36,6 @@ def __init__(self, uuid, topic, message, created_at, modified_on, week_uuid): self.week_uuid = week_uuid self.notes = NoteBuilder.get_notes(self.uuid) self.blockers = BlockerBuilder.get_blockers(self.uuid) - self.jiras = JiraBuilder.get_jira(self.uuid) def get_created_at_formatted(self, date_format="%Y-%m-%d %H:%M:%S"): """ @@ -74,7 +72,6 @@ def to_dict(self): "week_uuid": str(self.week_uuid), "notes": self.notes, "blockers": self.blockers, - "jiras": self.jiras, } @classmethod diff --git a/DirectReport/models/jira_models/__init__.py b/DirectReport/models/jira_models/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/DirectReport/models/jira_models/jira.py b/DirectReport/models/jira_models/jira.py deleted file mode 100644 index e5ba5f01..00000000 --- a/DirectReport/models/jira_models/jira.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python3 - - -class Jira: - def __init__(self, uuid, associated_entry_uuid, jira_tag, jira_ticket): - """ - Initializes a new instance of the Jira class. - - :param uuid: The UUID of the Jira. - :param associated_entry_uuid: The UUID of the associated entry. - :param jira_tag: The Jira tag. - :param jira_ticket: The Jira ticket. - """ - self.uuid = uuid - self.associated_entry_uuid = associated_entry_uuid - self.jira_tag = jira_tag - self.jira_ticket = jira_ticket - - def to_dict(self): - """ - Convert the Jira object to a dictionary. - - :return: The Jira object as a dictionary. - :rtype: dict - """ - - return { - "uuid": str(self.uuid), - "associated_entry_uuid": str(self.associated_entry_uuid), - "jira_tag": self.jira_tag, - "jira_ticket": self.jira_ticket, - } - - def __iter__(self): - return self - - def __str__(self): - return "{ " + "".join((' {} : {} '.format(item, self.__dict__[item]) for item in self.__dict__)) + " }" - - def __repr__(self): - return self.__str__() - - def __len__(self): - return len(self.jira_ticket) diff --git a/DirectReport/models/jira_models/jira_builder.py b/DirectReport/models/jira_models/jira_builder.py deleted file mode 100644 index 02c4536c..00000000 --- a/DirectReport/models/jira_models/jira_builder.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python3 - -from DirectReport.database.jira_storage import JiraDataStore - - -class JiraBuilder: - def __init__(self): - pass - - @staticmethod - def add_new_jira(jira_ticket, jira_tag, associated_id): - """ - Adds a new Jira entry to the list. - - :param jira_ticket: The Jira ticket to add. - :param jira_tag: The Jira tag associated with the ticket. - :param associated_id: The ID associated with the Jira entry. - :return: None - """ - - jira = JiraDataStore('SQLite_Python.db') - jira.create_table() - jira.add_jira_entry(jira_tag, jira_ticket, associated_id) - - @staticmethod - def get_jira(associated_id): - """ - Retrieves a list of Jira associated with the specified ID. - - :param associated_id: The ID to retrieve Jira for. - :return: A list of Jira associated with the ID. - """ - - jira = JiraDataStore('SQLite_Python.db') - jira_list = jira.entries_for_associated_uuid(associated_id) - return jira_list