Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Merge requests
  • !8545

Closed
Created Jan 06, 2015 by Administrator@rootOwner
  • Report abuse
Report abuse

Fix authorized_projects pagination

  • Overview 6
  • Commits 1
  • Changes 1

Created by: brugidou

The Gitlab API uses pagination when you try to get the project list for a user using the @current_user.authorized_projects method as a scope.

This method does not reliably order projects (it's non-deterministic). This leads to missing or duplicate projects in the pagination.

Example:

gitlabhq_production=# SELECT  "projects".id, projects.name,
namespaces.name
FROM "projects" INNER JOIN "namespaces" ON
"namespaces"."id" = "projects"."namespace_id" WHERE "projects"."id" IN
(33, 5, 18, 20, 30, 17, 32, 22, 6, 31, 95, 19, 91, 90, 33, 11, 13)
ORDER BY namespaces.name ASC
limit 4 offset 0;

 id |    name     |   name
----+-------------+----------
 31 | Test        | AnnaTest
 90 | Hadoop Test | AnnaTest
 20 | Eva Test    | AnnaTest
  6 | Adam        | AnnaTest
(4 rows)

gitlabhq_production=# SELECT  "projects".id, projects.name,
namespaces.name
FROM "projects" INNER JOIN "namespaces" ON
"namespaces"."id" = "projects"."namespace_id" WHERE "projects"."id" IN
(33, 5, 18, 20, 30, 17, 32, 22, 6, 31, 95, 19, 91, 90, 33, 11, 13)
ORDER BY namespaces.name ASC
limit 2 offset 0;

 id |    name     |   name
----+-------------+----------
  6 | Adam | AnnaTest
 31 | Test | AnnaTest
(2 rows)

gitlabhq_production=# SELECT  "projects".id, projects.name,
namespaces.name
FROM "projects" INNER JOIN "namespaces" ON
"namespaces"."id" = "projects"."namespace_id" WHERE "projects"."id" IN
(33, 5, 18, 20, 30, 17, 32, 22, 6, 31, 95, 19, 91, 90, 33, 11, 13)
ORDER BY namespaces.name ASC
limit 2 offset 2;

 id |    name     |   name
----+-------------+----------
 20 | Eva Test | AnnaTest
  6 | Adam     | AnnaTest
(2 rows)
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: github/fork/criteo-forks/fix_projects_pagination