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

moderation: add 'verified' field to records #1399

Merged
merged 2 commits into from
Aug 15, 2023

Conversation

alejandromumo
Copy link
Member

@alejandromumo alejandromumo commented Aug 7, 2023

return False
is_verified = (
owner.resolve().verified_at is not None
) # TODO property is_verified in user
Copy link
Member Author

@alejandromumo alejandromumo Aug 7, 2023

Choose a reason for hiding this comment

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

WIP: Ideally, we want a computed property "is_verified" on the user

However, the owner.resolve() returns a User (model) instance. Therefore, verified is not a property we should be adding to the model. Perhaps we can resolve the user's API class instead?

Shelved it for now, unless there's a strong reason to do it now.

@alejandromumo alejandromumo changed the title Add record verified moderation: add 'verified' field to records Aug 8, 2023
@@ -126,6 +133,16 @@ class RDMSearchOptions(SearchOptions, SearchOptionsMixin):
"access_status": facets.access_status,
}

# TODO we could do SearchOptions.params_interpreters_cls
Copy link
Member Author

Choose a reason for hiding this comment

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

Since I wanted to replace SortParam by VerifiedRecordsSortParam, I rewrote the params interpreters list.

I don't like this because:

  • If we change the record's default list, it won't be picked up by RDM records (this happens with other record types, e..g communities, but I feel rdm records is special)

However, I did not like using SearchOptions.params_interpreters_cls because it would execute apply for both SortParam and VerifiedRecordsSortParam

Copy link
Contributor

Choose a reason for hiding this comment

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

We have a similar problem with service components: if you change them via config, you might break functionalities.
At some point, we discussed that we should have a kind of "private" components, and to override them is not simply via a config var, but via a method that will explicitly list them somehow, a guard to warn you: Hey, do you know what you are doing? We didn't do it yet.

In components, we have a comment # Order of components are important!: you might want to add something similar, we another sentence.

@alejandromumo alejandromumo force-pushed the add_record_verified branch 2 times, most recently from 24f188b to b5086fe Compare August 8, 2023 15:19
@alejandromumo alejandromumo force-pushed the add_record_verified branch 4 times, most recently from 9b96f5b to e9383c1 Compare August 9, 2023 16:31
Copy link
Member Author

Choose a reason for hiding this comment

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

question: I am not entirely sure about adding the mapping to drafts as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

The is_verified is a calculated system field, which will not be part of the record saved in the db. Or am I wrong? You might don't need to add it to the various db schemas. It is probably necessary for OpenSearch mappings.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed it won't be saved in the DB.
However, it is currently being indexed also for drafts. Otherwise, other tests fail for drafts.

I think it is not necessary to have the field in drafts, I need to check how to only add it for the records on indexing.

Copy link
Member Author

Choose a reason for hiding this comment

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

I had a closer look.

is_verified is a field on the parent, which is a common field for both records and drafts.

I don't see a problem with having is_verified on the draft since it won't be used (at least for now).

WDYT @ntarocco

Copy link
Contributor

@ntarocco ntarocco left a comment

Choose a reason for hiding this comment

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

Nice! Good job!

Copy link
Contributor

Choose a reason for hiding this comment

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

The is_verified is a calculated system field, which will not be part of the record saved in the db. Or am I wrong? You might don't need to add it to the various db schemas. It is probably necessary for OpenSearch mappings.

@@ -126,6 +133,16 @@ class RDMSearchOptions(SearchOptions, SearchOptionsMixin):
"access_status": facets.access_status,
}

# TODO we could do SearchOptions.params_interpreters_cls
Copy link
Contributor

Choose a reason for hiding this comment

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

We have a similar problem with service components: if you change them via config, you might break functionalities.
At some point, we discussed that we should have a kind of "private" components, and to override them is not simply via a config var, but via a method that will explicitly list them somehow, a guard to warn you: Hey, do you know what you are doing? We didn't do it yet.

In components, we have a comment # Order of components are important!: you might want to add something similar, we another sentence.

invenio_rdm_records/services/config.py Outdated Show resolved Hide resolved
tests/services/test_rdm_service.py Show resolved Hide resolved
@ntarocco ntarocco merged commit ee04b1b into inveniosoftware:master Aug 15, 2023
4 checks passed
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.

[USER MODERATION] - 3rd deliverable - sort records by 'verified'
2 participants