Skip to content

Commit

Permalink
foo-bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Oct 21, 2024
1 parent 33bb4f3 commit ba5d1a1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions api/caching/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ def update_storage_usage_cache(target_id, target_guid, per_page=500000):


def compute_storage_usage_total(target_obj, per_page=500000):
sql = """SELECT count(file_page.size), sum(file_page.size) from (
SELECT version.size AS size
FROM osf_basefileversionsthrough AS obfnv
LEFT JOIN osf_basefilenode AS file ON obfnv.basefilenode_id = file.id
LEFT JOIN osf_fileversion AS version ON obfnv.fileversion_id = version.id
sql = """
SELECT count(size), sum(size) from
(SELECT size FROM osf_basefileversionsthrough AS obfnv
LEFT JOIN osf_basefilenode file ON obfnv.basefilenode_id = file.id
LEFT JOIN osf_fileversion version ON obfnv.fileversion_id = version.id
WHERE file.provider = 'osfstorage'
AND file.deleted_on IS NULL
AND file.target_object_id=%(target_id)s
AND file.target_content_type_id = %(target_content_type_id)s
AND file.target_object_id=%(target_pk)s
AND file.target_content_type_id = %(target_content_type_pk)s
ORDER BY version.id
LIMIT %(per_page)s OFFSET %(offset)s
) file_page
Expand All @@ -142,8 +142,8 @@ def compute_storage_usage_total(target_obj, per_page=500000):
while last_count:
cursor.execute(
sql, {
'target_id': target_obj.pk,
'target_content_type_id': ContentType.objects.get_for_model(target_obj).pk,
'target_pk': target_obj.pk,
'target_content_type_pk': ContentType.objects.get_for_model(target_obj).pk,
'per_page': per_page,
'offset': offset,
},
Expand Down

0 comments on commit ba5d1a1

Please sign in to comment.