Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sort parameter to getFlagSnapshots API #549

Merged
merged 1 commit into from
Oct 15, 2023

Conversation

jamessalvatore
Copy link
Contributor

Description

Add a sort parameter with values ASC and DESC to the getFlagSnapshots API.

Motivation and Context

This change allows API users to receive snapshots in ascending order if they wish to, rather than always receiving results in descending order (the current behavior).

How Has This Been Tested?

Tested locally that the change is backwards compatible, such that snapshots are received in descending order when the query parameter is not specified:

curl http://localhost:18000/api/v1/flags/1/snapshots\?limit\=2

[
  {
    "flag": {
      "dataRecordsEnabled": false,
      "description": "test",
      "enabled": false,
      "id": 1,
      "key": "kxjfenfcgu4xdcyq1",
      "segments": [],
      "tags": [],
      "updatedAt": "2023-10-06T16:10:55.490-04:00",
      "variants": []
    },
    "id": 5,
    "updatedAt": "2023-10-06T20:10:55Z"
  },
  {
    "flag": {
      "dataRecordsEnabled": false,
      "description": "test",
      "enabled": false,
      "id": 1,
      "key": "kxjfenfcgu4xdcyq1",
      "segments": [],
      "tags": [],
      "updatedAt": "2023-10-06T16:10:55.080-04:00",
      "variants": []
    },
    "id": 4,
    "updatedAt": "2023-10-06T20:10:55Z"
  }
]

Tested locally that snapshots are received in ascending order when specified:

curl http://localhost:18000/api/v1/flags/1/snapshots\?limit\=2\&sort\=ASC

[
  {
    "flag": {
      "dataRecordsEnabled": false,
      "description": "test",
      "enabled": false,
      "id": 1,
      "key": "kxjfenfcgu4xdcyq1",
      "segments": [],
      "tags": [],
      "updatedAt": "2023-10-06T16:10:50.781-04:00",
      "variants": []
    },
    "id": 1,
    "updatedAt": "2023-10-06T20:10:50Z"
  },
  {
    "flag": {
      "dataRecordsEnabled": false,
      "description": "test",
      "enabled": false,
      "id": 1,
      "key": "kxjfenfcgu4xdcyq1",
      "segments": [],
      "tags": [],
      "updatedAt": "2023-10-06T16:10:54.208-04:00",
      "variants": []
    },
    "id": 2,
    "updatedAt": "2023-10-06T20:10:54Z"
  }
]

Tested locally that snapshots are received in descending order when specified:

curl http://localhost:18000/api/v1/flags/1/snapshots\?limit\=2\&sort\=DESC

[
  {
    "flag": {
      "dataRecordsEnabled": false,
      "description": "test",
      "enabled": false,
      "id": 1,
      "key": "kxjfenfcgu4xdcyq1",
      "segments": [],
      "tags": [],
      "updatedAt": "2023-10-06T16:10:55.490-04:00",
      "variants": []
    },
    "id": 5,
    "updatedAt": "2023-10-06T20:10:55Z"
  },
  {
    "flag": {
      "dataRecordsEnabled": false,
      "description": "test",
      "enabled": false,
      "id": 1,
      "key": "kxjfenfcgu4xdcyq1",
      "segments": [],
      "tags": [],
      "updatedAt": "2023-10-06T16:10:55.080-04:00",
      "variants": []
    },
    "id": 4,
    "updatedAt": "2023-10-06T20:10:55Z"
  }
]

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@ghost
Copy link

ghost commented Oct 6, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

Copy link
Contributor

@nothing0012 nothing0012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the PR

@nothing0012 nothing0012 merged commit b143c3a into openflagr:main Oct 15, 2023
9 checks passed
@jamessalvatore
Copy link
Contributor Author

Hi @nothing0012 , thanks for merging this PR.

Would it be possible to create a new release that includes these changes? Thanks very much!

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