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

4880 – Seeds Script: Create standalone claim descriptions and fact-checks #1956

Merged

Conversation

vasconsaurus
Copy link
Contributor

Description

This creates both standalone claim descriptions and standalone claim descriptions with fact checks. Though only the second is visible in the UI. We also:

  • verify the fact checks with a random status ('undetermined', 'not_applicable', 'in_progress', 'verified' or 'false')
  • add a link to half of the standalone fact checks

References: 4880

How has this been tested?

Created new users and added to an existing user.

Things to pay attention to during code review

I also had to update how we were verifying and publishing the fact-checks that are related to a project media. It was breaking since now we can have claim_descriptions with nil project_media_id.

fact_checks = user.claim_descriptions.where.not(project_media_id: nil).includes(:fact_check).map { |claim| claim.fact_check }.compact!.last(items_total/2)

Checklist

  • I have performed a self-review of my own code
  • I have added unit and feature tests, if the PR implements a new feature or otherwise would benefit from additional testing
  • I have added regression tests, if the PR fixes a bug
  • I have added logging, exception reporting, and custom tracing with any additional information required for debugging
  • I considered secure coding practices when writing this code. Any security concerns are noted above.
  • I have commented my code in hard-to-understand areas, if any
  • I have made needed changes to the README
  • My changes generate no new warnings
  • If I added a third party module, I included a rationale for doing so and followed our current guidelines

- now claim_descriptions can have null project_media, so I changed how
we get the fact_checks we want to publish. So we only get the fact_checks
which claim_descriptions have a project_media.
- re-wrote how I was getting the fact_check with an includes, so we
make less queries
@vasconsaurus vasconsaurus marked this pull request as ready for review July 15, 2024 21:02
Copy link
Contributor

@caiosba caiosba left a comment

Choose a reason for hiding this comment

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

Great work, thanks Manu!

@vasconsaurus vasconsaurus merged commit 734f949 into epic/CV2-4441-articles Jul 16, 2024
2 checks passed
@vasconsaurus vasconsaurus deleted the 4880-create-standalone-claims-fcs-seeds branch July 16, 2024 11:14
caiosba added a commit that referenced this pull request Jul 22, 2024
* [WIP] Sort explainers on GraphQL API

* Adding filters to explainers

* Explainers data model and API updates (#1901)

In order to list explainers on the frontend side, some changes were needed on the backend.

- Title should not be mandatory at the API level but at the model level (and description as well)
- Store tags in the Explainer model and keep them in sync with TagText instances
- Adding filters, counter, sorting and pagination to the TeamType.articles connection

Reference: CV2-4500.

* Updates for fact-check data model and API (#1904)

Some changes for fact-checks data model and API:

* Adding tags
* Filters and sort

Reference: CV2-4145

* CV2-4665: index report information in fact check (#1909)

* CV2-4665: index report information in fact check

* CV2-4665: fix tests

* CV2-4665: migrate fact-check tags and allow filter by report informations(publisher, rating and report status)

* CV2-4665: apply PR comments

* CV2-4665: add more tests

* CV2-4665: filter by report information

* Some changes to articles API and data model (#1933)

Some changes to articles API and data model:

- It should be possible to create `ClaimDescription` without a `ProjectMedia`
- Adding a `team_id` field to `ClaimDescription`
- Expose `ClaimDescription.project_media_id` in GraphQL mutations
- Adding a new many-to-many relationship between explainers and items, through a new join model `ExplainItem`, and respective GraphQL type and mutations
- Expose `FactCheck.rating` in GraphQL mutations
- New GraphQL fields for `ProjectMedia`: `fact_check` and `explainers`
- New filters for `Team.explainers` GraphQL connection: `standalone` and `text`

References: CV2-4441, CV2-4626 and CV2-4627.

* Small refactoring

* Fixing two things reported by frontend team

* List standalone fact-checks

* Fixing search by text for explainers

* Ticket CV2-4889: Expose number of articles for an item in GraphQL (#1949)

* Add fact_check_id field to ProjectMediaType

* Adding field `explainer_items` to `ProjectMediaType`

* Exposing fact-check report_status in GraphQL

* Reverting changes to schema

* Adding unique index to explainer_items

* Adding unique index to explainer_items

* Fixing language validation for fact-check

* Add "imported" field to fact-checks (#1951)

Adding an "imported" field to fact-checks. It's automatically set as "true" for fact-checks created by bots. This PR includes:

- Database migration
- Business logic (set "imported" as "true" for fact-checks created by bots, automatically)
- Unit tests
- GraphQL API, including filter to TeamType.articles
- Rake task to update existing fact-checks

Reference: CV2-4882.

* Fixing test

* CV2-4879: add rake task to set team_id for ClaimDescription (#1954)

* CV2-4901 fact check article list not displaying rating (#1952)

* CV2-4901: Sync status value with fact-check rating

* CV2-4901: apply PR comment

* CV2-4901: fix tests

* Always set claim description team based on project media

* Always set claim description team based on project media

* 4880 – Seeds Script: Create standalone claim descriptions and fact-checks (#1956)

This creates both standalone claim descriptions and standalone claim descriptions with fact checks. Though only the second is visible in the UI. We also:

- verify the fact checks with a random status ('undetermined', 'not_applicable', 'in_progress', 'verified' or 'false')
- add a link to half of the standalone fact checks

Note: I also had to update how we were verifying and publishing the fact-checks that are related to a project media. It was breaking since now we can have claim_descriptions with nil project_media_id. (check-api/db/seeds.rb: line 333)

References: 4880
PR: 1956

* Set initial rating for fact-check

* Fixing test

* Fix

* Return team for fact check mutations

* Return total number of articles (regardless the type)

* Adding missing test

---------

Co-authored-by: Brian Fleming <[email protected]>
Co-authored-by: Sawy <[email protected]>
Co-authored-by: Alexandre Amorim <[email protected]>
Co-authored-by: Manu Vasconcelos <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants