This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/tools/orphans.py
Brad Ison d3d9cca182 Upgrade Peewee to latest 3.x
This requires a number of small changes in the data model code, as well as additional testing.
2018-07-23 12:43:23 -04:00

15 lines
390 B
Python

from data.database import Image, ImageStorage
from peewee import JOIN, fn
from app import app
orphaned = (ImageStorage
.select()
.where(ImageStorage.uploading == False)
.join(Image, JOIN.LEFT_OUTER)
.group_by(ImageStorage)
.having(fn.Count(Image.id) == 0))
counter = 0
for orphan in orphaned:
counter += 1
print orphan.uuid