WildAid / o-fish-web

Web application for the Officer's Fishery Information Sharing Hub (O-FISH). The web app allows agencies to gain insights from the aggregated information gathered during a routine vessel inspection (submitted via the web app).
Apache License 2.0
31 stars 41 forks source link

Filters should be case-insensitive #263

Open o-fish-wildaid opened 3 years ago

o-fish-wildaid commented 3 years ago

In general filters should be case-insensitive. I went to the Boarding Records menu and clicked Vessels and then added a filter for a vessel name. But the vessel did not show up after filtering - because I did not capitalize properly. That filter should be case-insensitive; and if there's a way to make sure other filters are case-insensitive too that would be great.

tsturtz commented 3 years ago

I would like to work on this issue

tsturtz commented 3 years ago

There don't seem to be any vessels in the sandbox instance. I'd prefer to use that instance for dev so I'm pausing on this for now.

Sheeri commented 3 years ago

Hi @tsturtz, thanks for offering to work on this! I have assigned it to you. I have also added 2 boardings to your agency, let me know if you can't see them. (they're the same vessel).

tsturtz commented 3 years ago

Hey! Thanks. Unfortunately I'm not going to be able to complete this one. It's quite a bit more involved than I expected and I'm expecting my second baby in just a few days so I don't have the time.

Having said that, I was able to replicate the issue by using the top search filter bar (though I initially thought you were talking about the search field in the blue "filter" dropdown on the right which actually does nothing currently). I traced through the code here in vessels.component.js and discovered that it calls a stitch service that calls a mongo db function. Found the repo (o-fish-realm) for the functions and I think the issue lies somewhere around here... https://github.com/WildAid/o-fish-realm/blob/main/WildAidDemo/functions/searchFacetByVesselsNEW/source.js#L104-L107. All that really needs to be done is to call .toLowerCase() on both the search query and the vessel.name.

Thanks, good luck! I'm going to unassign myself now.

deveshchatuphale7 commented 3 years ago

Hi, I would like to work on this issue

Sheeri commented 3 years ago

Hi @tsturtz - thanks for letting us know promptly and unassigning yourself. And we super appreciate sharing your research with us! It means a lot that you didn't just ghost us :D

Sheeri commented 3 years ago

Hello @deveshchatuphale7, thanks for offering to work on this! I have assigned it to you.

Sheeri commented 3 years ago

@deveshchatuphale7 from the research that tsturtz did, it would seem that this is a Realm issue, which falls under the "needs own instance" label now - it requires you to build your own instance (free, but takes time). And it should be moved to the Realm repo, not this one.

Now that you know all that, is this still something you want to work on? It's totally OK if you don't, there are other issues that can be worked on.

deveshchatuphale7 commented 3 years ago

Sure @Sheeri , I would like to work other issues first to get familiar, would like to pick this issue later on, if remains unassigned

ayushjainrksh commented 3 years ago

@Sheeri I tried to solve this problem by fixing the Realm function responsible for querying the database with the filter. I'm getting this error that says caseSensitive is not allowed in this atlas tier. I also, get the same error if I try to use any other query such as regex.

A simple solution would be to simply use the find function on the document and return the result. I'm not sure if that would be the ideal case though. The aggregation pipeline only supports the $match query which results in the exact matches only.

I also tried using $text inside the $match (so I can do a case insensitive search) but it requires me to create an index. When I do boardingCollection.createIndex(), I get an error that createIndex() is not a function.

Which approach do you think works here?

Screenshot from 2020-10-30 00-17-56

Sheeri commented 3 years ago

@ayushjainrksh Wow, that's very interesting! we'll have to look into that.

If you'd like to get credit for the work you did researching this, please submit a PR against this ticket - anything, you can add a line to the README - we won't merge it in, but we will mark it as hacktoberfest-accepted so you get credit!

ayushjainrksh commented 3 years ago

@Sheeri Thanks for the appreciation. Let me know if I can help in any way. Don't want to bother you with a spammy PR though :)

Sheeri commented 3 years ago

I will let you know!