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

Add query to delete statement #93

Merged
merged 8 commits into from
Feb 22, 2024
Merged

Add query to delete statement #93

merged 8 commits into from
Feb 22, 2024

Conversation

NoB0
Copy link
Collaborator

@NoB0 NoB0 commented Jan 31, 2024

Add SPARQL DELETE query. The query also includes the removal of derived preferences.

Part of #64

Copy link

github-actions bot commented Jan 31, 2024

Unit Test Results

61 tests   61 ✔️  9s ⏱️
  1 suites    0 💤
  1 files      0

Results for commit 4164985.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jan 31, 2024

Coverage Report •
FileStmtsMissCoverMissing
pkg_api
   pkg.py1281586%74, 85, 107–117, 133, 202, 269–270, 278–>275, 309–312, 346–347
   utils.py94296%159–>171, 164, 222
tests/pkg_api
   test_pkg.py500100% 
   test_utils.py610100% 
TOTAL12204894% 

Copy link

Current Branch Main Branch
Coverage Badge Coverage Badge

Copy link
Collaborator

@WerLaj WerLaj left a comment

Choose a reason for hiding this comment

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

Some clarification is needed in several places and two tests are missing.

pkg_api/utils.py Outdated
Returns:
SPARQL query.
"""
blank_node_id = "?statement"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't it always the same? Can we make it a global variable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I created a global variable _SPARQL_STATEMENT_VARIABLE for ?statement, please check that it does not impact the readability of the queries.

"""
blank_node_id = "?statement"
statement = _get_statement_representation(pkg_data, blank_node_id)
# Remove statement description from conditions
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need to do that?

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 description is removed because it not possible that it is the same when asking to remove a statement, especially when using natural language. For example, a user might input "Delete my preference towards Tom Cruise" or " Remove the statements related to Tom Cruise" to remove the statement "I like Tom Cruise."

pkg_api/utils.py Show resolved Hide resolved
pkg_api/utils.py Show resolved Hide resolved
pkg_api/utils.py Outdated Show resolved Hide resolved
pkg_api/utils.py Outdated Show resolved Hide resolved

assert utils.get_query_for_remove_statement(
pkg_data_example
) == strip_string(sparql_query)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Tests for get_queries_for_remove_cleanup and for get_query_for_remove_preference are missing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added a test for get_query_for_remove_preference. I am not sure a test is needed for get_queries_for_remove_cleanup because it appears to be already covered and it returns a string without alteration by a variable.

@NoB0 NoB0 requested a review from WerLaj February 20, 2024 12:27
Copy link
Collaborator

@WerLaj WerLaj left a comment

Choose a reason for hiding this comment

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

LGTM

@NoB0 NoB0 merged commit eb361d9 into main Feb 22, 2024
5 checks passed
@NoB0 NoB0 deleted the feature/64-sparql-delete branch February 22, 2024 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants