goharbor / harbor

An open source trusted cloud native registry project that stores, signs, and scans content.
https://goharbor.io
Apache License 2.0
23.95k stars 4.74k forks source link

Cannot Sort Projects by repo_count or owner_name #18329

Open CannonLock opened 1 year ago

CannonLock commented 1 year ago

If you are reporting a problem, please make sure the following information are provided:

Expected behavior and actual behavior: I expect that when I use the API and add repo_count or owner_name to the sort parameter the results will be sorted on this parameter.

Steps to reproduce the problem:

Using your own demo site api.

import requests

def get_sorted_values(key):
    j = requests.get(f"https://demo.goharbor.io/api/v2.0/projects?page=1&page_size=100&sort={key}&with_detail=true").json()

    return [x[key] for x in j]

keys = ['repo_count','owner_name','chart_count','creation_time','name','owner_id','project_id','update_time']

for key in keys:
    print(key, get_sorted_values(key))

# repo_count [1, 0, 0, 3, 3, 1, 1]
# owner_name ['admin', 'gxr', 'admin', 'srini', 'srini', 'hoachvbnd', 'admin']
# chart_count [0, 0, 0, 0, 0, 0, 0]
# creation_time ['2023-03-09T05:00:36.132Z', '2023-03-09T06:03:49.190Z', '2023-03-09T07:24:36.972Z', '2023-03-09T08:06:22.627Z', '2023-03-09T13:57:47.875Z', '2023-03-09T14:50:57.258Z', '2023-03-09T15:42:38.237Z']
# name ['demo', 'gxr', 'library', 'operator12', 'operator7', 'test_harhor', 'zk-test']
# owner_id [1, 1, 1, 3, 3, 5, 14]
# project_id [1, 3, 7, 8, 12, 13, 14]
# update_time ['2023-03-09T05:00:36.132Z', '2023-03-09T06:03:49.190Z', '2023-03-09T07:24:36.972Z', '2023-03-09T08:06:22.627Z', '2023-03-09T13:57:47.875Z', '2023-03-09T14:50:57.258Z', '2023-03-09T15:42:38.237Z']

Versions: Please specify the versions of following systems.

CannonLock commented 1 year ago

Digging deeper this looks to be effecting keys on other endpoints as well. For instance artifact_count on the /projects/*/repositories endpoint.

EraKin575 commented 2 months ago

@CannonLock is this issue still relevant? I want to work on this issue