taxonworks icon indicating copy to clipboard operation
taxonworks copied to clipboard

[Bug]: sources reported as "in" are not

Open mccullermi opened this issue 2 years ago • 4 comments

Steps to reproduce the bug

1. search sources results show sources that are not in the project as being in the project

...

Screenshot

image

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

mccullermi avatar Oct 12 '22 17:10 mccullermi

I did not experience this problem, all sources are search for are correctly marked. Please provide a source ID and Project name for testing.

proceps avatar Oct 12 '22 21:10 proceps

https://sfg.taxonworks.org/tasks/sources/new_source?source_id=107423 in 3i project

proceps avatar Oct 17 '22 07:10 proceps

@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 the in_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
Screen Shot 2022-10-24 at 4 29 04 PM

mjy avatar Oct 24 '22 21:10 mjy

Thanks, I check and update it, once I am back.

proceps avatar Oct 25 '22 06:10 proceps

Pinging you @proceps to try and fix this.

mjy avatar Dec 06 '22 18:12 mjy