Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ dmypy.json
*.db

# Configuration
/config/config.json
src/FINALES2/config/config.json

# User related files
/user_management/files_user_management
3 changes: 0 additions & 3 deletions src/FINALES2/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from FINALES2.logging.logger import loggerConfig

logger = loggerConfig().get_logger()
10 changes: 8 additions & 2 deletions src/FINALES2/cli/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,20 @@ def cli_retrieve():

@click.option(
"--input-name",
required=False,
# required=False,
# default=None,
# show_default=True,
prompt="Provide input the name of the tenant to retrieve the uuid for",
type=str,
is_flag=False,
flag_value="None",
default="None",
help=("Possible way to filter the name of a tenant to retrieve the uuid."),
)
@cli_retrieve.command("tenant-uuid")
def db_retrieve_tenant_specification(input_name=None):
"Retrieve uuid of all tenants, or just the one with an above specified name"

if input_name == "None":
input_name = None
server_manager = ServerManager(database_context=get_db)
server_manager.retrieve_tenant_uuid(input_name)
2 changes: 1 addition & 1 deletion src/FINALES2/cli/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from FINALES2.user_management import user_manager
from FINALES2.user_management.classes_user_manager import User

from . import logger
from ..logging import logger


@click.group("server")
Expand Down
4 changes: 4 additions & 0 deletions src/FINALES2/db/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from .base_class import Base
from .tables.is_active_log_quantities import IsActiveLogQuantity
from .tables.is_active_log_tenants import IsActiveLogTenant
from .tables.link_quantity_request import LinkQuantityRequest
from .tables.link_quantity_result import LinkQuantityResult
from .tables.quantities import Quantity
Expand All @@ -18,4 +20,6 @@
"LinkQuantityResult",
"StatusLogRequest",
"StatusLogResult",
"IsActiveLogTenant",
"IsActiveLogQuantity",
]
42 changes: 42 additions & 0 deletions src/FINALES2/db/tables/is_active_log_quantities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from sqlalchemy import TIMESTAMP, Boolean, Column, ForeignKey, String
from sqlalchemy.sql import func
from sqlalchemy_utils import UUIDType

from FINALES2.db.base_class import Base


class IsActiveLogQuantity(Base):
"""
Class defining the logging of the is_active of specific quantities in the quantity
table with the following columns:
uuid (UUIDType (32)): uuid of the entry
quantity_uuid (UUIDType (32)): uuid of the quantity with the associated
is_active type
is_active (Boolean): 1 - row is active when added. Row will remain active
with 1, but an update on the same quantity will be a new
row (newer load_time).
When a row with is_active=0 is added, it will mean the
type is not active, until a new is_active=1 with newer
load_time is added.
is_active_change_message
load_time (Datetime): Timestamp for when the row is added
"""

uuid = Column(
UUIDType(binary=False),
primary_key=True,
nullable=False,
)
quantity_uuid = Column(
UUIDType(binary=False),
ForeignKey("quantity.uuid"),
nullable=False,
)
is_active = Column(Boolean(), default=True)
is_active_change_message = Column(
String,
nullable=True,
)
load_time = Column(
TIMESTAMP, server_default=func.now(), onupdate=func.current_timestamp()
)
38 changes: 38 additions & 0 deletions src/FINALES2/db/tables/is_active_log_tenants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from sqlalchemy import TIMESTAMP, Boolean, Column, ForeignKey, String
from sqlalchemy.sql import func
from sqlalchemy_utils import UUIDType

from FINALES2.db.base_class import Base


class IsActiveLogTenant(Base):
"""
Class defining the logging of the is_active of specific quantities in the quantity
table with the following columns:
uuid (UUIDType (32)): uuid of the entry
quantity_uuid (UUIDType (32)): uuid of the quantity with the associated
is_active type
is_active Boolean (Boolean): status if the tenant is currently active
is_active_change_message (String): Message associated with change. Can be left
Comment thread
MonikaVo marked this conversation as resolved.
blank
load_time (Datetime): Timestamp for when the row is added
"""

uuid = Column(
UUIDType(binary=False),
primary_key=True,
nullable=False,
)
tenant_uuid = Column(
UUIDType(binary=False),
ForeignKey("tenant.uuid"),
nullable=False,
)
is_active = Column(Boolean(), default=True)
is_active_change_message = Column(
String,
nullable=True,
)
load_time = Column(
TIMESTAMP, server_default=func.now(), onupdate=func.current_timestamp()
)
9 changes: 1 addition & 8 deletions src/FINALES2/db/tables/quantities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sqlalchemy import TIMESTAMP, Boolean, Column, String
from sqlalchemy import TIMESTAMP, Column, String
from sqlalchemy.sql import func
from sqlalchemy_utils import UUIDType

Expand All @@ -13,12 +13,6 @@ class Quantity(Base):
method (String): Type of method within the quantity
specification (String): Json string with the specifications of the measuremnet
type
is_active (Boolean): 1 - row is active when added. Row will remain active
with 1, but an update on the same quantity will be a new
row (newer load_time).
When a row with is_active=0 is added, it will mean the
type is not active, until a new is_active=1 with newer
load_time is added.
load_time (Datetime): Timestamp for when the row is added
"""

Expand All @@ -40,7 +34,6 @@ class Quantity(Base):
String,
nullable=False,
)
is_active = Column(Boolean(), default=True)
load_time = Column(
TIMESTAMP, server_default=func.now(), onupdate=func.current_timestamp()
)
2 changes: 0 additions & 2 deletions src/FINALES2/db/tables/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class Request(Base):
requesting_recieved_timestamp (Boolean): Timestamp for when the request was
recieved
bugdet (String): Budget associated with the request...
status (String): String representing the current status of the entry
load_time (Datetime): Timestamp for when the row is added
"""

Expand All @@ -32,7 +31,6 @@ class Request(Base):
)
requesting_recieved_timestamp = Column(DateTime, nullable=False)
budget = Column(String, nullable=True)
status = Column(String, nullable=False)
load_time = Column(
TIMESTAMP, server_default=func.now(), onupdate=func.current_timestamp()
)
2 changes: 0 additions & 2 deletions src/FINALES2/db/tables/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class Result(Base):
posting_tenant_uuid CHAR: uuid of the tenant posting the result
posting_recieved_timestamp: Timestamp of the when the posting was recieved
cost VARCHAR: Cost associated with the result...
status (String): String representing the current status of the entry
load_time(DateTime): Timestamp for when the row is added
"""

Expand All @@ -40,7 +39,6 @@ class Result(Base):
)

cost = Column(String, nullable=True)
status = Column(String, nullable=False)
posting_recieved_timestamp = Column(
DateTime,
nullable=False,
Expand Down
4 changes: 1 addition & 3 deletions src/FINALES2/db/tables/tenants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sqlalchemy import TIMESTAMP, Boolean, Column, String
from sqlalchemy import TIMESTAMP, Column, String
from sqlalchemy.sql import func
from sqlalchemy_utils import UUIDType

Expand All @@ -12,7 +12,6 @@ class Tenant(Base):
name VARCHAR: name of tenant
limitations VARCHAR: limitations of the tenant within each method
contact_person VARCHAR: contact person of the tenant
is_active Boolean: status if the tenant is currently active
load_time (Datetime): Timestamp for when the row is added

"""
Expand All @@ -30,7 +29,6 @@ class Tenant(Base):
String,
nullable=False,
)
is_active = Column(Boolean(), default=True)
load_time = Column(
TIMESTAMP, server_default=func.now(), onupdate=func.current_timestamp()
)
3 changes: 0 additions & 3 deletions src/FINALES2/engine/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from FINALES2.logging.logger import loggerConfig

logger = loggerConfig().get_logger()
Loading