Skip to content

fix: T-153-api-query-filter#168

Open
khalsz wants to merge 10 commits into
developfrom
fix/T-153-api-query-filter
Open

fix: T-153-api-query-filter#168
khalsz wants to merge 10 commits into
developfrom
fix/T-153-api-query-filter

Conversation

@khalsz

@khalsz khalsz commented May 22, 2025

Copy link
Copy Markdown
Collaborator

This fixes the filter bug. and this works perfectly compared to all other methods I have tried before. But removes previous page from api response.

@khalsz khalsz linked an issue May 22, 2025 that may be closed by this pull request
@samueljackson92

samueljackson92 commented May 23, 2025

Copy link
Copy Markdown
Collaborator

It doesn't look like the issue has been fixed. If I query the following

http://localhost:8081/json/shots?fields=shot_id

I get this response:

image

Which

  1. Has removed all the entires from the context
  2. Has loads of entries which are not shot_id in the items returned.

Comment thread tests/api/test_json.py
Comment thread src/api/main.py
@khalsz

khalsz commented Jun 30, 2025

Copy link
Copy Markdown
Collaborator Author

It doesn't look like the issue has been fixed. If I query the following

http://localhost:8081/json/shots?fields=shot_id

I get this response:

image Which
  1. Has removed all the entires from the context
  2. Has loads of entries which are not shot_id in the items returned.

Thank you for mentioning this.

  1. I have fixed the problem of the empty context. Here is the result of the resolution:
    image

  2. Meanwhile, your question regarding loading of other entries. This is expected, because those entries and compulsory to be returned and they carry required args in the build up of the table (an example is context, even though context is not a shot_id field, it was returned because it is required. If those fields are not return for any reason, there will be error.

@khalsz khalsz requested a review from samueljackson92 July 1, 2025 07:25

@samueljackson92 samueljackson92 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sorry, this still does not fix the issue for me.

When I run the query http://localhost:8081/json/shots?fields=shot_id,url

I get the following back:

image

Which clearly includes more fields than just shot_id and url.

Also, a unit test case should be added to cover this issue.

@khalsz khalsz requested a review from samueljackson92 August 12, 2025 11:56
@khalsz

khalsz commented Aug 18, 2025

Copy link
Copy Markdown
Collaborator Author

I left fields @context, @type, title as a required field for all query.

@jameshod5 jameshod5 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Works for me with fields only returning what we are asking for, but maybe the names are a bit confusing

Comment thread src/api/models.py
)


class ShotModel(BaseShotModel, table=True):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe we should rename these classes, I assume BaseModel is what is returned when we use fields. ShotModelFiltered maybe?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

May be we can discuss this. to explain to you better.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

it is not necessary just a filter model. It does more than filter.

Comment thread src/api/models.py Outdated
@khalsz

khalsz commented Oct 9, 2025

Copy link
Copy Markdown
Collaborator Author

After adding the shot filter model. The result of http://localhost:8081/json/shots was Internal Server Error and the error I got on the terminal is:
image
This is because the models created failed to validate with the alias of the fields meanwhile the api gives it result using the alias of the fields.

@NathanCummings

Copy link
Copy Markdown
Member

After adding the shot filter model. The result of http://localhost:8081/json/shots was Internal Server Error and the error I got on the terminal is: image This is because the models created failed to validate with the alias of the fields meanwhile the api gives it result using the alias of the fields.

I'm not seeing the image. I think the markdown needs fixing.

@khalsz

khalsz commented Oct 10, 2025

Copy link
Copy Markdown
Collaborator Author

sorry. Here's the image
image

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.

fields filter not working for REST API

4 participants