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
23 changes: 15 additions & 8 deletions specifyweb/backend/stored_queries/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,24 @@ class QuerySort:
def by_id(sort_id: QUREYFIELD_SORT_T):
return QuerySort.SORT_TYPES[sort_id]


def DefaultQueryFormatterProps():
return ObjectFormatterProps(
format_agent_type=False,
format_picklist=False,
format_types=True,
numeric_catalog_number=True,
format_expr=True
)

class BuildQueryProps(NamedTuple):
recordsetid: int | None = None
replace_nulls: bool = False
formatauditobjs: bool = False
distinct: bool = False
series: bool = False
implicit_or: bool = True
formatter_props: ObjectFormatterProps = ObjectFormatterProps(
format_agent_type = False,
format_picklist = False,
format_types = True,
numeric_catalog_number = True,
format_expr = True,
)
formatter_props: ObjectFormatterProps = DefaultQueryFormatterProps()


def set_group_concat_max_len(connection):
Expand Down Expand Up @@ -789,10 +793,13 @@ def execute(
offset,
recordsetid=None,
formatauditobjs=False,
formatter_props=ObjectFormatterProps(),
formatter_props=None,
):
"Build and execute a query, returning the results as a data structure for json serialization"

if formatter_props is None:
formatter_props = DefaultQueryFormatterProps()

set_group_concat_max_len(session.info["connection"])
query, order_by_exprs = build_query(
session,
Expand Down
8 changes: 4 additions & 4 deletions specifyweb/backend/stored_queries/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
Spauditlog_model = datamodel.get_table('SpAuditLog')

class ObjectFormatterProps(NamedTuple):
format_agent_type: bool = False,
format_picklist: bool = False,
format_types: bool = True,
numeric_catalog_number: bool = True,
format_agent_type: bool = False
format_picklist: bool = False
format_types: bool = True
numeric_catalog_number: bool = True
# format_expr determines if make_expr should call _fieldformat, like in versions before 7.10.2.
# Batch edit expects it to be false to correctly handle some edge cases.
format_expr: bool = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function buildStatsLambdaUrl(base: string | null | undefined): string | null {
if (!hasRoute) {
const stage = 'prod';
const route = 'AggrgatedSp7Stats';
u = `${u.replace(/\/$/, '') }/${stage}/${route}`;
u = `${u.replace(/\/$/, '')}/${stage}/${route}`;
}
return u;
}
Expand All @@ -58,7 +58,10 @@ export const fetchContext = load<SystemInfo>(
if (systemInfo.stats_url !== null) {
let counts: StatsCounts | null = null;
try {
counts = await load<StatsCounts>('/context/stats_counts.json', 'application/json');
counts = await load<StatsCounts>(
'/context/stats_counts.json',
'application/json'
);
} catch {
// If counts fetch fails, proceed without them.
counts = null;
Expand Down Expand Up @@ -102,12 +105,13 @@ export const fetchContext = load<SystemInfo>(

const lambdaUrl = buildStatsLambdaUrl(systemInfo.stats_2_url);
if (lambdaUrl) {
await ping(formatUrl(lambdaUrl, parameters, false), { errorMode: 'silent' })
.catch(softFail);
await ping(formatUrl(lambdaUrl, parameters, false), {
errorMode: 'silent',
}).catch(softFail);
}
}

return systemInfo;
});

export const getSystemInfo = (): SystemInfo => systemInfo;
export const getSystemInfo = (): SystemInfo => systemInfo;