Skip to content

Commit f810214

Browse files
author
ci bot
committed
Merge branch 'aarthy/fix-queries' into 'enterprise'
QA fixes See merge request dkinternal/testgen/dataops-testgen!289
2 parents 04a03bd + 6649939 commit f810214

File tree

8 files changed

+15
-16
lines changed

8 files changed

+15
-16
lines changed

testgen/commands/run_generate_tests.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
from testgen.commands.queries.generate_tests_query import CDeriveTestsSQL
55
from testgen.common import execute_db_queries, fetch_dict_from_db, get_test_generation_params, set_target_db_params
66
from testgen.common.mixpanel_service import MixpanelService
7+
from testgen.common.models import with_database_session
78
from testgen.common.models.connection import Connection
89

910
LOG = logging.getLogger("testgen")
1011

1112

13+
@with_database_session
1214
def run_test_gen_queries(table_group_id: str, test_suite: str, generation_set: str | None = None):
1315
if table_group_id is None:
1416
raise ValueError("Table Group ID was not specified")

testgen/commands/run_profiling_bridge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def run_profiling_in_background(table_group_id):
216216
background_thread.start()
217217
else:
218218
LOG.info(msg)
219-
script = ["testgen", "run-profile", "-tg", table_group_id]
219+
script = ["testgen", "run-profile", "-tg", str(table_group_id)]
220220
subprocess.Popen(script) # NOQA S603
221221

222222

testgen/common/database/flavor/redshift_flavor_service.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,3 @@ def get_connection_string_head(self):
1515
def get_connection_string_from_fields(self):
1616
# STANDARD FORMAT: strConnect = 'flavor://username:password@host:port/database'
1717
return f"{self.flavor}://{self.username}:{quote_plus(self.password)}@{self.host}:{self.port}/{self.dbname}"
18-
19-
def get_pre_connection_queries(self):
20-
return [
21-
("SET SEARCH_PATH = :schema", {"schema": self.dbschema}),
22-
]

testgen/common/models/profiling_run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def get_minimal(cls, run_id: str | UUID) -> ProfilingRunMinimal | None:
9999
select(cls._minimal_columns).join(TableGroup, cls.table_groups_id == TableGroup.id).where(cls.id == run_id)
100100
)
101101
result = get_current_session().execute(query).first()
102-
return ProfilingRunMinimal(**result)
102+
return ProfilingRunMinimal(**result) if result else None
103103

104104
@classmethod
105105
def get_latest_run(cls, project_code: str) -> LatestProfilingRun | None:

testgen/common/models/project.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Project(Entity):
3838

3939
@classmethod
4040
@st.cache_data(show_spinner=False)
41-
def get_summary(cls, project_code: str) -> ProjectSummary:
41+
def get_summary(cls, project_code: str) -> ProjectSummary | None:
4242
query = """
4343
SELECT
4444
(
@@ -81,7 +81,7 @@ def get_summary(cls, project_code: str) -> ProjectSummary:
8181

8282
db_session = get_current_session()
8383
result = db_session.execute(text(query), {"project_code": project_code}).first()
84-
return ProjectSummary(**result, project_code=project_code)
84+
return ProjectSummary(**result, project_code=project_code) if result else None
8585

8686
@classmethod
8787
def is_in_use(cls, ids: list[str]) -> bool:

testgen/common/models/test_run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def get_minimal(cls, run_id: str | UUID) -> TestRunMinimal | None:
100100

101101
query = select(cls._minimal_columns).join(TestSuite).where(cls.id == run_id)
102102
result = get_current_session().execute(query).first()
103-
return TestRunMinimal(**result)
103+
return TestRunMinimal(**result) if result else None
104104

105105
@classmethod
106106
def get_latest_run(cls, project_code: str) -> LatestTestRun | None:

testgen/ui/components/frontend/js/display_utils.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ function formatDuration(/** @type string */ duration) {
3030
return formatted.trim() || '< 1s';
3131
}
3232

33-
function formatNumber(/** @type number | string */ number, /** @type number */ precision = 3) {
33+
function formatNumber(/** @type number | string */ number, /** @type number */ decimals = 3) {
3434
if (!['number', 'string'].includes(typeof number) || isNaN(number)) {
3535
return '--';
3636
}
37-
return parseFloat(Number(number).toPrecision(precision)).toLocaleString();
37+
// toFixed - rounds to specified number of decimal places
38+
// toLocaleString - adds commas as necessary
39+
return parseFloat(Number(number).toFixed(decimals)).toLocaleString();
3840
}
3941

4042
function capitalize(/** @type string */ text) {

testgen/ui/queries/source_data_queries.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def _get_lookup_data(
192192
table_group_id: str,
193193
anomaly_id: str,
194194
error_type: Literal["Profile Anomaly", "Test Results"],
195-
) -> LookupData:
195+
) -> LookupData | None:
196196
result = fetch_one_from_db(
197197
"""
198198
SELECT
@@ -214,12 +214,12 @@ def _get_lookup_data(
214214
"anomaly_id": anomaly_id,
215215
},
216216
)
217-
return LookupData(**result)
217+
return LookupData(**result) if result else None
218218

219219

220220
def _get_lookup_data_custom(
221221
test_definition_id: str,
222-
) -> LookupData:
222+
) -> LookupData | None:
223223
result = fetch_one_from_db(
224224
"""
225225
SELECT
@@ -229,4 +229,4 @@ def _get_lookup_data_custom(
229229
""",
230230
{"test_definition_id": test_definition_id},
231231
)
232-
return LookupData(**result)
232+
return LookupData(**result) if result else None

0 commit comments

Comments
 (0)