Skip to content

Commit 922ab94

Browse files
committed
Debug statistics record problem.
1 parent cce8d1b commit 922ab94

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/mavedb/routers/statistics.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ def _record_from_field_and_model(
260260
model_created_by_field = getattr(queried_model, "created_by_id")
261261
model_published_data_field = getattr(queried_model, "published_date")
262262
if field is RecordFields.createdBy:
263+
print("111")
263264
query = (
264265
select(User.username, func.count(User.id))
265266
.join(queried_model, model_created_by_field == User.id)
@@ -269,6 +270,7 @@ def _record_from_field_and_model(
269270

270271
return db.execute(query).all()
271272
else:
273+
print("2222")
272274
# All assc table identifiers which are linked to a published model.
273275
queried_assc_table = association_tables[model][field]
274276
published_score_sets_statement = (
@@ -332,6 +334,11 @@ def record_object_statistics(
332334
Model names and fields should be members of the Enum classes defined above. Providing an invalid model name or
333335
model field will yield a 422 Unprocessable Entity error with details about valid enum values.
334336
"""
337+
# Validation to ensure 'keywords' is only used with 'experiment'.
338+
if model == RecordNames.scoreSet and field == RecordFields.keywords:
339+
raise HTTPException(status_code=422,
340+
detail="The 'keywords' field can only be used with the 'experiment' model.")
341+
335342
count_data = _record_from_field_and_model(db, model, field)
336343

337344
return {field_val: count for field_val, count in count_data if field_val is not None}

0 commit comments

Comments
 (0)