Skip to content

Commit

Permalink
fix duplicate results returned by is_accessible
Browse files Browse the repository at this point in the history
    For some reason the queries are returning duplicates. It cannot be from the code that checks access through events, because even if the `accessible_projects_ids` has duplicates, the result returned should not have duplicates
    ```
    >>> PublishedProject.objects.filter(id__in=[4,4,4])
        <QuerySet [<PublishedProject: COVID-19 Epidemiology and Vaccination Dataset v1.0.0>]>
    ```

    It looks like it might be because of union operation somehow. I am not sure what exactly, but i have hacky fix with .distinct() (Thanks to @ kshalot)

    On this commit, i added .distinct() to remove the duplicates so that method only returns unique projects/datasets
  • Loading branch information
superryeti committed Mar 2, 2023
1 parent b9059db commit a886204
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion physionet-django/project/managers/publishedproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ def accessible_by(self, user):
accessible_projects_ids.append(event_dataset.dataset.id)
query |= Q(id__in=accessible_projects_ids)

return self.filter(query)
return self.filter(query).distinct()

0 comments on commit a886204

Please sign in to comment.