huridocs / uwazi

Uwazi is a web-based, open-source solution for building and sharing document collections
http://www.uwazi.io
MIT License
237 stars 79 forks source link

Activity log: Filter not working #6713

Closed salvalacruz closed 3 months ago

salvalacruz commented 5 months ago

It seems the filter feature in the /settings/activitylog screen does not work:

mfacar commented 5 months ago

@salvalacruz, I tested it in uwazi.demo and checked that the filters are returning data for certain queries. For example filtering by http methods like [POST, DELETE, PUT] or by a date range taking as reference the dates or records without filters. I also experience difficulties getting results because I believe filtering by URLs or keywords is expecting an exact match. Please can you check it? So we can have a better understanding of what the problem is.

salvalacruz commented 5 months ago

Hi @mfacar, I create, edit and delete an entity in template "PERSONA" with title "ENTIDAD PRUEBA": image

If I filter the activity log by user, the result is fine, but:

If I filter by "ENTIDAD PRUEBA", the result is empty (until some days ago, it was posible to search by entity titles): image

If I filter by date range, it does not seems it works: image

Please let me know if you prefer to meet and we try together. Thank you!

serena-huridocs commented 5 months ago

This week's testing group's input: I tried to search by entity name in demo.uwazi.io and it did not work for me as well. Entering entity id to find the targeted actions did not help either.

I suppose the persisting problem with dates will be fixed by this fix: https://github.com/huridocs/uwazi/pull/6667.

salvalacruz commented 4 months ago

Activity log filtering is still NOT able to search by the title of entities.

cc @RafaPolit

RafaPolit commented 4 months ago

The middle input filter is not working as the description lists. Yes, you can input Method, but then anything inside the body like Entity ID, or title, or any other value, would just yield nothing.

fnocetti commented 4 months ago

A quick test shows that the GET request is being sent with every possible parameter set to the search term. Because, particularly, find is set, it is generating this mongo query: https://github.com/huridocs/uwazi/blob/42bb22fff1333679308b1be85bdd3c33274c0224/app/api/activitylog/activitylog.js#L40

Now, because also method is set, and is an array containing only the term, this happens later: https://github.com/huridocs/uwazi/blob/42bb22fff1333679308b1be85bdd3c33274c0224/app/api/activitylog/activitylog.js#L118

That must be generating a query like:

{ $or: [...], method: { $in: [term] } }

which is likely not a valid mongo query (or in the best case it is looking for an $or field to be an array, which should return empty results).

That API definitively needs refactoring, but the fix is that the correct use of that endpoint, given the use case, is to only include the find parameter, plus the time related, pagination, and sort. It looks like it may make the username filter stop working, that would need a backend fix. cc @RafaPolit @mfacar

mfacar commented 4 months ago

There are also some other problems with the search: