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

Update Opinion model to support versions #4819

Open
grossir opened this issue Dec 13, 2024 · 0 comments
Open

Update Opinion model to support versions #4819

grossir opened this issue Dec 13, 2024 · 0 comments

Comments

@grossir
Copy link
Contributor

grossir commented Dec 13, 2024

From the parent issue

data model changes: there are many ways we could model the opinion "versions". I think that the simplest is adding a field that points to the "main" version

class Opinion(models.Model):
    cluster = models.ForeignKey(
        OpinionCluster,
        help_text="The cluster that the opinion is a part of",
        related_name="sub_opinions",
        on_delete=models.CASCADE,
    )
    ....
    main_version = models.ForeignKey(self, null=True)

This has the advantage of being simple enough, and :

  • You can find the "main" version via a simple query Opinion.objects.filter(main_version__isnull=True)
  • Given the "main" version you can find all it's versions Opinion.objects.filter(main_version=main_version_id)
    these queries should be covered by an index
  • The Opinion model already has all the metadata fields for comparing versions: dates, the uploaded document copy, the original URL, the extracted text
    all the versions would be grouped under the same OpinionCluster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant