Skip to content

Commit

Permalink
Ensure contents_active return 0 instead of None
Browse files Browse the repository at this point in the history
When there is no content.
  • Loading branch information
davelopez committed Mar 19, 2024
1 parent 3085b6e commit b7f3c66
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
9 changes: 3 additions & 6 deletions client/src/api/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6531,21 +6531,18 @@ export interface components {
/**
* Active
* @description Number of active datasets.
* @default 0
*/
active?: number | null;
active: number;
/**
* Deleted
* @description Number of deleted datasets.
* @default 0
*/
deleted?: number | null;
deleted: number;
/**
* Hidden
* @description Number of hidden datasets.
* @default 0
*/
hidden?: number | null;
hidden: number;
};
/** HistoryContentBulkOperationPayload */
HistoryContentBulkOperationPayload: {
Expand Down
6 changes: 3 additions & 3 deletions lib/galaxy/managers/history_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ def active_counts(self, history):
hdca_select = self._active_counts_statement(model.HistoryDatasetCollectionAssociation, history.id)
subquery = hda_select.union_all(hdca_select).subquery()
statement = select(
cast(func.sum(subquery.c.deleted), Integer).label("deleted"),
cast(func.sum(subquery.c.hidden), Integer).label("hidden"),
cast(func.sum(subquery.c.active), Integer).label("active"),
cast(func.coalesce(func.sum(subquery.c.deleted), 0), Integer).label("deleted"),
cast(func.coalesce(func.sum(subquery.c.hidden), 0), Integer).label("hidden"),
cast(func.coalesce(func.sum(subquery.c.active), 0), Integer).label("active"),
)
returned = self.app.model.context.execute(statement).one()
return dict(returned._mapping)
Expand Down
12 changes: 6 additions & 6 deletions lib/galaxy/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,18 +1254,18 @@ class HistorySummary(HistoryBase, WithModelClass):
class HistoryActiveContentCounts(Model):
"""Contains the number of active, deleted or hidden items in a History."""

active: Optional[int] = Field(
default=0,
active: int = Field(
...,
title="Active",
description="Number of active datasets.",
)
hidden: Optional[int] = Field(
default=0,
hidden: int = Field(
...,
title="Hidden",
description="Number of hidden datasets.",
)
deleted: Optional[int] = Field(
default=0,
deleted: int = Field(
...,
title="Deleted",
description="Number of deleted datasets.",
)
Expand Down

0 comments on commit b7f3c66

Please sign in to comment.