Closed o-fish-wildaid closed 3 years ago
May I be assigned to this issue? I'd like to help.
Absolutely @Dusch4593 thanks for offering to work on this! I have assigned it to you.
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.
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
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:
officer
key with a value of $captain.name
. It's not supposed to be the captain names, right? // ./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?
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).
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.
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
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.
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?
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.
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.
("Jack Harknass" is a captain. Every agency has at least one user, so the agencies that show "N/A" are also incorrect).