Skip to content

endpoints for upcoming, current and all policies of a type#1214

Merged
deer-wmde merged 12 commits into
mainfrom
api_T432714
Jul 24, 2026
Merged

endpoints for upcoming, current and all policies of a type#1214
deer-wmde merged 12 commits into
mainfrom
api_T432714

Conversation

@deer-wmde

@deer-wmde deer-wmde commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

adds routes

/v1/policies/{policy_type}/current
/v1/policies/{policy_type}/upcoming
/v1/policies/{policy_type}

Two observations:

1. api route order matters
this one works:

    $router->get('v1/policies/current', ['uses' => 'PoliciesController@getCurrentPolicies']);
    $router->get('v1/policies/{policy_type}', ['uses' => 'PoliciesController@getPoliciesByType']);

this one doesnt: v1/policies/{policy_type} swallows the later ones:

    $router->get('v1/policies/{policy_type}', ['uses' => 'PoliciesController@getPoliciesByType']);
    $router->get('v1/policies/current', ['uses' => 'PoliciesController@getCurrentPolicies']);

2. Explicit nulling of active_from
Due to our PolicyFactory implementation we need to set active_from to null if we want it to be not filled.
this works:

        Policy::factory()->create([
            'policy_type' => 'terms-of-use',
            'active_from' => null,
        ]);

this fills with 'active_from' => now()

        Policy::factory()->create([
            'policy_type' => 'terms-of-use',
        ]);

https://phabricator.wikimedia.org/T432714

@deer-wmde
deer-wmde marked this pull request as ready for review July 24, 2026 10:11
@deer-wmde
deer-wmde merged commit fbc21c0 into main Jul 24, 2026
4 checks passed
@deer-wmde
deer-wmde deleted the api_T432714 branch July 24, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants