Skip to content

Paginate public v2 importmetadata and support descendants #6170

Description

@rtibbles

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

Studio's v2/importmetadata ignores max_results and descendants, and always returns the ancestors of one node as a single unpaginated dict. Since v0.19.3, Kolibri requests import metadata in pages and passes descendants for course imports. learningequality/kolibri#15352 makes Kolibri skip unpaginated sources for course imports, so until Studio supports both parameters, Kolibri can't import course metadata from Studio. Studio should paginate when given max_results and include descendants when given descendants, matching Kolibri's endpoint.

Complexity: Medium
Target branch: hotfixes

Context

  • Kolibri's endpoint (import_metadata.py#L18-L205):
    • cursor pagination ordered by lft, with max_results as the page size;
    • a response of {"more": …, "results": {<table>: [...], "schema_version": …}};
    • descendants returns the ancestors plus all descendants, ordered by lft.
  • Studio's current view: import_metadata_view.py#L69-L203

The Change

v2/importmetadata should accept max_results and descendants with the same semantics and response shape as Kolibri's endpoint. Without max_results, it keeps returning the unpaginated dict.

Acceptance Criteria

General

  • With max_results=N, the response is {"more", "results"}, results holds the tables for at most N nodes, and requesting again with more as the query string returns the next page until more is null.
  • With descendants=true, the paged results cover the node, its ancestors and all its descendants, in lft order, with no node repeated.
  • Without max_results, the response is unchanged from today.
  • Kolibri's _get_import_metadata imports a course node's metadata from Studio.

Testing

  • Tests cover pagination with and without descendants, and the unpaginated response.

AI usage

I asked Claude Code to compare Kolibri's and Studio's v2 public content APIs. It found this gap and drafted the sections. I set the scope and target branch, and reviewed each section.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions