Skip to content

Commit

Permalink
refactor: remove if-else control block in do_select_all() method (#1019)
Browse files Browse the repository at this point in the history
* refactor: remove if-else construct in select_all method

* refactor: update messages to use singular tag name

* test: update tests for singular tag names

* build: update poetry.lock for latest version of pillow
  • Loading branch information
weibullguy committed Mar 3, 2022
1 parent 6b14567 commit ac19638
Show file tree
Hide file tree
Showing 135 changed files with 453 additions and 423 deletions.
1 change: 1 addition & 0 deletions .sourcery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ignore:
- data/*
- tests/*
- test_*
- '*_test.py'

refactor:
skip:
Expand Down
122 changes: 116 additions & 6 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/ramstk/models/db/program_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ def do_save_program() -> None:
:return: None
:rtype: None
"""
pub.sendMessage("request_update_all_revisions")
pub.sendMessage("request_update_all_functions")
pub.sendMessage("request_update_all_requirements")
pub.sendMessage("request_update_all_stakeholders")
pub.sendMessage("request_update_all_revision")
pub.sendMessage("request_update_all_function")
pub.sendMessage("request_update_all_requirement")
pub.sendMessage("request_update_all_stakeholder")
pub.sendMessage("request_update_all_hardware")
pub.sendMessage("request_update_all_validation")
35 changes: 8 additions & 27 deletions src/ramstk/models/dbtables/basetable.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class RAMSTKBaseTable:
# Define private scalar class attributes.
_db_id_colname: str = ""
_db_tablename: str = ""
_deprecated: bool = True
_root: int = 0
_select_msg: str = "selected_revision"
_tag: str = ""
Expand Down Expand Up @@ -126,7 +125,7 @@ def __init__(self, **kwargs: Dict[str, Union[float, int, str]]) -> None:
)
pub.subscribe(self.do_set_tree, f"succeed_calculate_{self._tag}")
pub.subscribe(self.do_update, f"request_update_{self._tag}")
pub.subscribe(self.do_update_all, f"request_update_all_{self._tag}s")
pub.subscribe(self.do_update_all, f"request_update_all_{self._tag}")
pub.subscribe(self.do_update_all, "request_save_project")

def do_connect(self, dao: BaseDatabase) -> None:
Expand Down Expand Up @@ -294,25 +293,12 @@ def do_select_all(self, attributes: Dict[str, Union[float, int, str]]) -> None:
"""
self.tree = do_clear_tree(self.tree)

# See ISSUE #1000
if self._deprecated:
try:
self._revision_id = attributes["revision_id"] # type: ignore
except KeyError:
try:
self._revision_id = attributes["site_id"] # type: ignore
except KeyError:
self._revision_id = 0

_keys = [self._lst_id_columns[0]]
_values = [self._revision_id]
else:
_keys = [_key for _key in self._lst_id_columns if _key in attributes]
_values = [
attributes[_key] # type: ignore
for _key in self._lst_id_columns
if _key in attributes
]
_keys = [_key for _key in self._lst_id_columns if _key in attributes]
_values = [
attributes[_key] # type: ignore
for _key in self._lst_id_columns
if _key in attributes
]

for _record in self.dao.do_select_all(
self._record,
Expand All @@ -333,11 +319,6 @@ def do_select_all(self, attributes: Dict[str, Union[float, int, str]]) -> None:
)
self.last_id = self.dao.get_last_id(self._db_tablename, self._db_id_colname)

# See ISSUE #1000
pub.sendMessage(
f"succeed_retrieve_{self._tag}s",
tree=self.tree,
)
pub.sendMessage(
f"succeed_retrieve_all_{self._tag}",
tree=self.tree,
Expand Down Expand Up @@ -468,4 +449,4 @@ def do_update_all(self) -> None:
self.do_update(_node.identifier) # type: ignore

pub.sendMessage("request_set_cursor_active")
pub.sendMessage("succeed_update_all")
pub.sendMessage(f"succeed_update_all_{self._tag}")
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/commondb_category_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class RAMSTKCategoryTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_category_id"
_db_tablename = "ramstk_category"
_deprecated = False
_select_msg = "request_get_category"
_tag = "category"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/commondb_condition_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class RAMSTKConditionTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_condition_id"
_db_tablename = "ramstk_condition"
_deprecated = False
_select_msg = "request_get_condition"
_tag = "condition"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/commondb_failure_mode_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class RAMSTKFailureModeTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_failuremode_id"
_db_tablename = "ramstk_failure_mode"
_deprecated = False
_select_msg = "request_get_failure_mode"
_tag = "failure_mode"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/commondb_group_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class RAMSTKGroupTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_group_id"
_db_tablename = "ramstk_group"
_deprecated = False
_select_msg = "request_get_group"
_tag = "group"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/commondb_hazards_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class RAMSTKHazardsTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_hazard_id"
_db_tablename = "ramstk_hazards"
_deprecated = False
_select_msg = "request_get_hazards"
_tag = "hazards"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/commondb_load_history_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class RAMSTKLoadHistoryTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_history_id"
_db_tablename = "ramstk_load_history"
_deprecated = False
_select_msg = "request_get_load_history"
_tag = "load_history"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/commondb_manufacturer_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class RAMSTKManufacturerTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_manufacturer_id"
_db_tablename = "ramstk_manufacturer"
_deprecated = False
_select_msg = "request_get_manufacturer"
_tag = "manufacturer"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/commondb_measurement_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class RAMSTKMeasurementTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_measurement_id"
_db_tablename = "ramstk_measurement"
_deprecated = False
_select_msg = "request_get_measurement"
_tag = "measurement"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/commondb_method_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class RAMSTKMethodTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_method_id"
_db_tablename = "ramstk_method"
_deprecated = False
_select_msg = "request_get_method"
_tag = "method"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/commondb_model_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class RAMSTKModelTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_model_id"
_db_tablename = "ramstk_model"
_deprecated = False
_select_msg = "request_get_model"
_tag = "model"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/commondb_rpn_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class RAMSTKRPNTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_rpn_id"
_db_tablename = "ramstk_rpn"
_deprecated = False
_select_msg = "request_get_rpn"
_tag = "rpn"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/commondb_stakeholders_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class RAMSTKStakeholdersTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_stakeholders_id"
_db_tablename = "ramstk_stakeholders"
_deprecated = False
_select_msg = "request_get_stakeholders"
_tag = "stakeholders"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/commondb_status_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class RAMSTKStatusTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_status_id"
_db_tablename = "ramstk_status"
_deprecated = False
_select_msg = "request_get_status"
_tag = "status"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/commondb_subcategory_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class RAMSTKSubCategoryTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_subcategory_id"
_db_tablename = "ramstk_subcategory"
_deprecated = False
_select_msg = "request_get_subcategory"
_tag = "subcategory"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/commondb_type_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class RAMSTKTypeTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_type_id"
_db_tablename = "ramstk_type"
_deprecated = False
_select_msg = "request_get_type"
_tag = "type"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/commondb_user_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class RAMSTKUserTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_user_id"
_db_tablename = "ramstk_user"
_deprecated = False
_select_msg = "request_get_user"
_tag = "user"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_action_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class RAMSTKActionTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_action_id"
_db_tablename = "ramstk_action"
_deprecated = False
_select_msg = "selected_revision"
_tag = "action"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_allocation_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class RAMSTKAllocationTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_hardware_id"
_db_tablename = "ramstk_allocation"
_deprecated = False
_select_msg = "selected_revision"
_tag = "allocation"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_cause_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class RAMSTKCauseTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_cause_id"
_db_tablename = "ramstk_cause"
_deprecated = False
_select_msg = "selected_revision"
_tag = "cause"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_control_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class RAMSTKControlTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_control_id"
_db_tablename = "ramstk_control"
_deprecated = False
_select_msg = "selected_revision"
_tag = "control"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class RAMSTKDesignMechanicTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_hardware_id"
_db_tablename = "ramstk_design_mechanic"
_deprecated = False
_select_msg = "selected_revision"
_tag = "design_mechanic"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_environment_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class RAMSTKEnvironmentTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_environment_id"
_db_tablename = "ramstk_environment"
_deprecated = False
_select_msg = "selected_revision"
_tag = "environment"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class RAMSTKFailureDefinitionTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_definition_id"
_db_tablename = "ramstk_failure_definition"
_deprecated = False
_select_msg = "selected_revision"
_tag = "definition"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_function_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class RAMSTKFunctionTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_function_id"
_db_tablename = "ramstk_function"
_deprecated = False
_select_msg = "selected_revision"
_tag = "function"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_hardware_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class RAMSTKHardwareTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_hardware_id"
_db_tablename = "ramstk_hardware"
_deprecated = False
_select_msg = "selected_revision"
_tag = "hardware"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_hazard_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class RAMSTKHazardTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_hazard_id"
_db_tablename = "ramstk_hazard_analysis"
_deprecated = False
_select_msg = "selected_revision"
_tag = "hazard"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_mechanism_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class RAMSTKMechanismTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_mechanism_id"
_db_tablename = "ramstk_mechanism"
_deprecated = False
_select_msg = "selected_revision"
_tag = "mechanism"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_milhdbk217f_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class RAMSTKMILHDBK217FTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_hardware_id"
_db_tablename = "ramstk_mil_hdbk_f"
_deprecated = False
_select_msg = "selected_revision"
_tag = "milhdbk217f"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class RAMSTKMissionPhaseTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_mission_phase_id"
_db_tablename = "ramstk_mission_phase"
_deprecated = False
_select_msg = "selected_revision"
_tag = "mission_phase"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_mission_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class RAMSTKMissionTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_mission_id"
_db_tablename = "ramstk_mission"
_deprecated = False
_select_msg = "selected_revision"
_tag = "mission"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_mode_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class RAMSTKModeTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_mode_id"
_db_tablename = "ramstk_mode"
_deprecated = False
_select_msg = "selected_revision"
_tag = "mode"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_nswc_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class RAMSTKNSWCTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_hardware_id"
_db_tablename = "ramstk_nswc"
_deprecated = False
_select_msg = "selected_revision"
_tag = "nswc"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_opload_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class RAMSTKOpLoadTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_opload_id"
_db_tablename = "ramstk_op_load"
_deprecated = False
_select_msg = "selected_revision"
_tag = "opload"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_opstress_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class RAMSTKOpStressTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_opstress_id"
_db_tablename = "ramstk_op_stress"
_deprecated = False
_select_msg = "selected_revision"
_tag = "opstress"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_program_info_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class RAMSTKProgramInfoTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_revision_id"
_db_tablename = "ramstk_program_info"
_deprecated = False
_select_msg = "request_program_preferences"
_tag = "preference"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class RAMSTKProgramStatusTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_status_id"
_db_tablename = "ramstk_program_status"
_deprecated = False
_select_msg = "selected_revision"
_tag = "program_status"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_reliability_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class RAMSTKReliabilityTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_hardware_id"
_db_tablename = "ramstk_reliability"
_deprecated = False
_select_msg = "selected_revision"
_tag = "reliability"

Expand Down
1 change: 0 additions & 1 deletion src/ramstk/models/dbtables/programdb_requirement_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class RAMSTKRequirementTable(RAMSTKBaseTable):
# Define private scalar class attributes.
_db_id_colname = "fld_requirement_id"
_db_tablename = "ramstk_requirement"
_deprecated = False
_select_msg = "selected_revision"
_tag = "requirement"

Expand Down
Loading

0 comments on commit ac19638

Please sign in to comment.