Skip to content

Conversation

Sunandadadi
Copy link
Contributor

@Sunandadadi Sunandadadi commented Jul 7, 2023

Superuser logs are sorted on datetime field. The next page token contains the value of the start_index of the datetime field for the next page. datetime column on the LogEntry table is not unique, so in some cases, multiple entries can have the same datetime field.
For example, logs have a page limit of 20 entries. If 25 entries have the same datetime - d1, the start_index of the next page is again d1. With the current logic, the same query is run for the next page too. This PR addresses such issues and adds an offset in such cases where (the first 20 entries of page 1 and 1 or more entries of page 2 have the same datetime).

@Sunandadadi Sunandadadi changed the title Pagination: Fixing paginate for /api/v1/superuser/logs API Draft: Pagination: Fixing paginate for /api/v1/superuser/logs API Jul 7, 2023
@Sunandadadi Sunandadadi changed the title Draft: Pagination: Fixing paginate for /api/v1/superuser/logs API Pagination: Fixing paginate for /api/v1/superuser/logs API Jul 10, 2023
"start_index": start_index,
"page_number": page_number + 1 if page_number else 1,
"is_datetime": is_datetime,
"use_offset": use_offset,
Copy link
Member

Choose a reason for hiding this comment

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

Do you really need use_offset, or just to set offset_val?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice, I can just use offset_val

"""
results = list(query)
page_token = None
offset_val = 0
Copy link
Member

Choose a reason for hiding this comment

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

This is already defined as a default parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, removed.

Copy link
Member

@kleesc kleesc left a comment

Choose a reason for hiding this comment

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

LGTM

@Sunandadadi Sunandadadi merged commit f56382e into quay:master Jul 11, 2023
@Sunandadadi Sunandadadi changed the title Pagination: Fixing paginate for /api/v1/superuser/logs API Pagination: Fixing paginate for /api/v1/superuser/logs API (PROJQUAY-5360) Jul 11, 2023
@Sunandadadi
Copy link
Contributor Author

/cherrypick redhat-3.8

@openshift-cherrypick-robot

@Sunandadadi: new pull request created: #2010

In response to this:

/cherrypick redhat-3.8

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@Sunandadadi
Copy link
Contributor Author

/cherrypick redhat-3.9

@openshift-cherrypick-robot

@Sunandadadi: new pull request created: #2011

In response to this:

/cherrypick redhat-3.9

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@Sunandadadi Sunandadadi deleted the PROJQUAY-5360 branch July 11, 2023 18:00
raja-0940 pushed a commit to raja-0940/quay that referenced this pull request Aug 10, 2023
* Pagination: Fixing paginate for /api/v1/superuser/logs API

* using offset to fetch next page items

* adding datetime parsing

* using black to format code

* removing use_offset

* Removing redundant declaration
raja-0940 pushed a commit to raja-0940/quay that referenced this pull request Aug 10, 2023
* Pagination: Fixing paginate for /api/v1/superuser/logs API

* using offset to fetch next page items

* adding datetime parsing

* using black to format code

* removing use_offset

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants