Skip to content

Commit

Permalink
Improve SQL per jdavcs' comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Mar 27, 2024
1 parent 40a2203 commit 77d43ac
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ def calculate_user_disk_usage_statements(user_id, quota_source_map, for_sqlite=F
WHERE NOT purged
AND history_id IN (SELECT id FROM per_user_histories)
)
SELECT COALESCE(SUM(COALESCE(dataset.total_size, dataset.file_size, 0)), 0), dataset.object_store_id
SELECT SUM(COALESCE(dataset.total_size, dataset.file_size, 0)) as usage, dataset.object_store_id
FROM dataset
LEFT OUTER JOIN library_dataset_dataset_association ON dataset.id = library_dataset_dataset_association.dataset_id
WHERE dataset.id IN (SELECT dataset_id FROM per_hist_hdas)
Expand Down Expand Up @@ -1178,7 +1178,11 @@ def attempt_create_private_role(self):
def dictify_objectstore_usage(self) -> List[UserObjectstoreUsage]:
session = object_session(self)
rows = calculate_disk_usage_per_objectstore(session, self.id)
return [UserObjectstoreUsage(object_store_id=r[1], total_disk_usage=r[0]) for r in rows if r[1]]
return [
UserObjectstoreUsage(object_store_id=r.object_store_id, total_disk_usage=r.usage)
for r in rows
if r.object_store_id
]

def dictify_usage(self, object_store=None) -> List[UserQuotaBasicUsage]:
"""Include object_store to include empty/unused usage info."""
Expand Down

0 comments on commit 77d43ac

Please sign in to comment.