data/model/oci/tag.py
def find_repository_with_garbage(limit_to_gc_policy_s):
    """ Returns a repository that has garbage (defined as an expired Tag that is past
        the repo's namespace's expiration window) or None if none.
    """
    expiration_timestamp = get_epoch_timestamp_ms() - (limit_to_gc_policy_s * 1000)

    try:
        candidates = (
            Tag.select(Tag.repository)
            .join(Repository)
            .join(Namespace, on=(Repository.namespace_user == Namespace.id))
            .where(
                ~(Tag.lifetime_end_ms >> None),
                (Tag.lifetime_end_ms <= expiration_timestamp),
                (Namespace.removed_tag_expiration_s == limit_to_gc_policy_s),
            )
            .limit(GC_CANDIDATE_COUNT)
            .distinct()
            .alias("candidates")
        )

        found = (
            Tag.select(candidates.c.repository_id)
            .from_(candidates)
            .order_by(db_random_func())
            .get()
        )

        if found is None:
            return

        return Repository.get(Repository.id == found.repository_id)
    except Tag.DoesNotExist:
        return None
    except Repository.DoesNotExist:
        return None
 Returns a repository that has garbage (defined as an expired Tag that is past
        the repo's namespace's expiration window) or None if none.
    
Returns a repository that has garbage (defined as an expired Tag that is past
the repo's namespace's expiration window) or None if none.
Returns a repository that has garbage ( defined as an expired Tag that is past the repo ' s namespace ' s expiration window ) or None if none .
def find_repository_with_garbage(limit_to_gc_policy_s):
    expiration_timestamp = get_epoch_timestamp_ms() - (limit_to_gc_policy_s * 1000)
    try:
        candidates = (
            Tag.select(Tag.repository)
            .join(Repository)
            .join(Namespace, on=(Repository.namespace_user == Namespace.id))
            .where(
                ~(Tag.lifetime_end_ms >> None),
                (Tag.lifetime_end_ms <= expiration_timestamp),
                (Namespace.removed_tag_expiration_s == limit_to_gc_policy_s),
            )
            .limit(GC_CANDIDATE_COUNT)
            .distinct()
            .alias("candidates")
        )
        found = (
            Tag.select(candidates.c.repository_id)
            .from_(candidates)
            .order_by(db_random_func())
            .get()
        )
        if found is None:
            return
        return Repository.get(Repository.id == found.repository_id)
    except Tag.DoesNotExist:
        return None
    except Repository.DoesNotExist:
        return None
def find_repository_with_garbage ( limit_to_gc_policy_s ) : expiration_timestamp = get_epoch_timestamp_ms ( ) - ( limit_to_gc_policy_s * 1000 ) try : candidates = ( Tag . select ( Tag . repository ) . join ( Repository ) . join ( Namespace , on = ( Repository . namespace_user == Namespace . id ) ) . where ( ~ ( Tag . lifetime_end_ms >> None ) , ( Tag . lifetime_end_ms <= expiration_timestamp ) , ( Namespace . removed_tag_expiration_s == limit_to_gc_policy_s ) , ) . limit ( GC_CANDIDATE_COUNT ) . distinct ( ) . alias ( "candidates" ) ) found = ( Tag . select ( candidates . c . repository_id ) . from_ ( candidates ) . order_by ( db_random_func ( ) ) . get ( ) ) if found is None : return return Repository . get ( Repository . id == found . repository_id ) except Tag . DoesNotExist : return None except Repository . DoesNotExist : return None
Returns a repository that has garbage (defined as an expired Tag that is past
the repo's namespace's expiration window) or None if none.
Returns a repository that has garbage ( defined as an expired Tag that is past the repo ' s namespace ' s expiration window ) or None if none .
""" Returns a repository that has garbage (defined as an expired Tag that is past
        the repo's namespace's expiration window) or None if none.
    """
limit_to_gc_policy_s