Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[back] feat: add entity contexts to unconnected entities API #1873

Merged
merged 5 commits into from
Jan 29, 2024

Conversation

GresilleSiffle
Copy link
Collaborator

@GresilleSiffle GresilleSiffle commented Jan 4, 2024

related issues #1852


Description

This PR adds the support of entity contexts in the unconnected entities API.

Moreover the logic used by the comparisons API and the unconnected entities API has been factorized in PollScopedViewMixin. Now all poll related views can access the entity contexts directly from self.entity_contexts.

to-do

  • update the tests

Checklist

  • I added the related issue(s) id in the related issues section (if any)
    • if not, delete the related issues section
  • I described my changes and my decisions in the PR description
  • I read the development guidelines of the CONTRIBUTING.md
  • The tests pass and have been updated if relevant
  • The code quality check pass

@GresilleSiffle GresilleSiffle added the Backend Back-end code of Tournesol label Jan 4, 2024
@GresilleSiffle GresilleSiffle changed the title 1852 add ent contexts to unconnected entities [back] feat: add entity contexts to unconnected entities API Jan 4, 2024
@GresilleSiffle GresilleSiffle self-assigned this Jan 8, 2024
@GresilleSiffle GresilleSiffle marked this pull request as ready for review January 8, 2024 09:08
@@ -89,7 +89,7 @@ def to_representation(self, instance):
poll = self.context.get("poll")
ent_contexts = self.context.get("entity_contexts")

if poll is not None:
if poll is not None and ent_contexts is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the cases where poll or ent_contexts would be None ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ExportComparisonsView class uses the ComparisonSerializer to write the comparisons of the logged user in a .csv file. In this case the serializer context doesn't contain any entity context.

If we consider that a comparison should not be represented without its related entity contexts, then we may want to remove this condition and ent_contexts is not None. In this case we should also consider adding the entity contexts in the public dataset.

Because they are here to "bias" the comparisons I think it could be a good idea to include those entity contexts in the public dataset.

Copy link
Collaborator Author

@GresilleSiffle GresilleSiffle Jan 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created an issue to address this question #1902

@GresilleSiffle GresilleSiffle merged commit 417fe3d into main Jan 29, 2024
8 checks passed
@GresilleSiffle GresilleSiffle deleted the 1852-add_ent_contexts_to_unconnected_entities branch January 29, 2024 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend Back-end code of Tournesol
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants