taxonworks
taxonworks copied to clipboard
[Bug]: sources reported as "in" are not
Steps to reproduce the bug
1. search sources results show sources that are not in the project as being in the project
...
Screenshot
Expected behavior
sources added to the project at top of source results list
Additional Screenshots
No response
Environment
Production
Sandbox Used
No response
Version
v0.29.5
Browser Used
Chrome
I did not experience this problem, all sources are search for are correctly marked. Please provide a source ID and Project name for testing.
https://sfg.taxonworks.org/tasks/sources/new_source?source_id=107423 in 3i project
@proceps see bug below, handing it back ot you.
- As noted, the "in" is not calculated correctly (there is only one true "in" in this screenshot below)
- The
in
is incorrect as thein_project
parameter does not compare to sessions_current_project_id - The code prioritizes references with (many) citations in any project, not in this project. It should only do this after prioritizing references in this project I think.
if project_id && scope
a = a.left_outer_joins(:citations)
.select('sources.*, COUNT(citations.id) AS use_count, NULLIF(citations.project_id, NULL) as in_project')
.where('citations.project_id = ? OR citations.project_id IS DISTINCT FROM ?', project_id, project_id)
.group('sources.id, citations.project_id')
.order('use_count DESC')
end

Thanks, I check and update it, once I am back.
Pinging you @proceps to try and fix this.