manageiq-api icon indicating copy to clipboard operation
manageiq-api copied to clipboard

Notifications GET request returns wrong "count"

Open fhlavac opened this issue 5 years ago • 3 comments

When request sent to /api/notifications?expand=resources&attributes=details&sort_by=id&sort_order=desc&limit=100 then in a reply (picture below) received count: 11468 image

I would expect that this value is the total notifications count of the current user but it isn't. In this case, the number of total user's notifications is 200. To get the number of total user's notifications I have to send another request. The current value of "count" is quite useless, maybe it is a bug. Would it be possible to replace it with the total number of current user's notifications?

@martinpovolny

fhlavac avatar Jan 21 '20 15:01 fhlavac

Investigation notes:

In app/controllers/api/base_controller/renderer.rb collection_search applies custom "search_condition" via a call to notifications_search_conditions.

However in app/controllers/api/base_controller.rb in index a call to Api::QueryCounts.new is done with NotificationRecipient.count. That ignores any custom search condition.

So this is probably going to be broken everywhere where *_search_condition is used:

app/controllers/api/automation_requests_controller.rb
app/controllers/api/groups_controller.rb
app/controllers/api/notifications_controller.rb
app/controllers/api/provision_requests_controller.rb
app/controllers/api/reports_controller.rb
app/controllers/api/requests_controller.rb
app/controllers/api/results_controller.rb
app/controllers/api/service_orders_controller.rb
app/controllers/api/service_requests_controller.rb
app/controllers/api/tenant_groups_controller.rb

Really, I see the same issue with groups.

martinpovolny avatar Jan 29 '20 16:01 martinpovolny

This issue has been automatically marked as stale because it has not been updated for at least 3 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the traige process documentation.

miq-bot avatar Jun 11 '20 22:06 miq-bot

@lpichler Can you take a look at this one?

gtanzillo avatar Aug 31 '20 20:08 gtanzillo