swingbit / jira2gitlab

Migrate Jira projects into a Gitlab instance
MIT License
20 stars 11 forks source link

pagination #1

Closed sylaroche closed 2 years ago

sylaroche commented 2 years ago

if there is more than 20 results in a GET from a gitlab API you only get the 20 first results ... you can extend the page up to 100 but after that you have to use the pages to get all results.

sylaroche commented 2 years ago
# Get available Gitlab users
gl_users = []
page = 1
while True:
    rq = requests.get(f'{GITLAB_API}/users?page=' + str(page), 
    headers={'PRIVATE-TOKEN': GITLAB_TOKEN}, verify=VERIFY_SSL_CERTIFICATE)

    gl_users += (rq.json()) 

    if (rq.headers["x-page"] != rq.headers["x-total-pages"]):  
        page = rq.headers["x-next-page"] 
    else:
        break
swingbit commented 2 years ago

Hi @sylaroche , thanks for reporting this.

You are right, I didn't really think about this because my intended use case was to migrate to an almost entirely empty Gitlab deployment. In my case I let the script create all users in Gitlab.

I'll fix it asap.

sylaroche commented 2 years ago

Hi Roberto,

That what i thought, but mine isn't ... I've made some modifications for my usecase, I'll send my final code to you, when the migration is done. You would see what is to keep, and what is for my usecase only ...

Le mar. 19 oct. 2021 à 14:29, Roberto Cornacchia @.***> a écrit :

Hi @sylaroche https://github.com/sylaroche , thanks for your reporting this.

You are right, I didn't really think about this because my intended use case was to migrate to an almost entirely empty Gitlab deployment. In my case I let the script create all users in Gitlab.

I'll fix it asap.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/swingbit/jira2gitlab/issues/1#issuecomment-946672782, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUHYP7M376C67XHBBHCSNC3UHVQC7ANCNFSM5GI6LMCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.