WildAid / o-fish-realm

Realm application code and sample data for the Officer's Fishery Information Sharing Hub (O-FISH). The mobile app allows fisheries officers to document and share critical information gathered during a routine vessel inspection. The web app allows agencies to gain insights from the aggregated information.
Apache License 2.0
23 stars 9 forks source link

Agencies page and Officers #189

Closed o-fish-wildaid closed 3 years ago

o-fish-wildaid commented 3 years ago

On the Agencies page (/#/agencies - only available to global and agency admins) the agency officers are shown. However the actual names shown are Captains from boarding records - they should be records from the User collection that match on agency.name.

Screen Shot 2020-10-12 at 10 48 58 AM

("Jack Harknass" is a captain. Every agency has at least one user, so the agencies that show "N/A" are also incorrect).

Dusch4593 commented 3 years ago

May I be assigned to this issue? I'd like to help.

Sheeri commented 3 years ago

Absolutely @Dusch4593 thanks for offering to work on this! I have assigned it to you.

Dusch4593 commented 3 years ago

Is there anywhere in the codebase where I can learn more about searchFacetByAgency? I'm trying to trace back where exactly searchAgencies() is getting its agency data from.

Sheeri commented 3 years ago

Hi @Dusch4593 - yes! That's a Realm function, which can be found in the realm codebase - https://github.com/WildAid/o-fish-realm/blob/main/WildAidDemo/functions/searchFacetByAgency/source.js

Dusch4593 commented 3 years ago

I noticed that inside of WildAid/o-fish-realm/blob/main/WildAidDemo/functions/searchFacetByAgency/source.js, lines 53-59, is where the officers array is being aggregated, there were two things happening that caught my attention:

  // ./searchFacetByAgency/source.js
  var officers = boardingsCollection.aggregate([
  {
    $project: {
      'agency': '$agency',
      'officer': '$captain.name'
    }
  },
  ...

I'm wondering if this may be what's causing the /#/agencies URL to display the incorrect officer data? Considering the snippet above is from a separate repo, is there an easy way to test this out and confirm?

Sheeri commented 3 years ago

Hi @Dusch4593 - there isn't really an easy way to test this to confirm; the realm code is what you'd import when building your own instance - https://wildaid.github.io/build/ - and then you can change it in the Atlas UI.

However, if this is something you're interested in, it's well worth taking the time to build your own (free) instance; because it will open up a world of ways in which you can help (permissions issues, issues that affect the global admin, and other issues that end up being a realm function, like this issue did).

Sheeri commented 3 years ago

I will say that your logic seems sound. I have my own test instance that I could try this on, if I have some spare time :D but that wouldn't be until tomorrow or Friday at the earliest.

Sheeri commented 3 years ago

Hi @Dusch4593 - that is in fact it! I was able to get it to work on the sandbox server.

I changed the captain.name line to:

  'officer': {$concat: ['$reportingOfficer.name.first', ' ', '$reportingOfficer.name.last']}

I would like you to get credit for hacktoberfest, since you did the research. I will move this to the o-fish-realm repository, can you open a PR against that? The file, as you found out, is:

WildAid/o-fish-realm/blob/main/WildAidDemo/functions/searchFacetByAgency/source.js

Dusch4593 commented 3 years ago

Sure thing! Per the official contribution guidelines, is this the link I need to go to?

https://github.com/Dusch4593/o-fish-realm/pull/new/fix_issue_189

The default is for o-fish-web, so I changed that part to o-fish-realm. But I'm getting a 404.

Dusch4593 commented 3 years ago

I pushed the changes you suggested to the source.js file and created a pull request. There are no conflicts with the base branch but it failed the checks. Git/ GitHub workflows are still sort of new to me, but what does it mean when your PR fails all the checks?

Sheeri commented 3 years ago

Hi @Dusch4593 that particular check was to see if this was your first PR on the repo, and if so, say thanks for making your first submission. So in this case, it's not concerning that it failed.