Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

admin - delete a keyword #884

Closed
3 tasks
TanyaStere42 opened this issue Jul 31, 2023 · 2 comments · Fixed by #960
Closed
3 tasks

admin - delete a keyword #884

TanyaStere42 opened this issue Jul 31, 2023 · 2 comments · Fixed by #960
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@TanyaStere42
Copy link
Member

TanyaStere42 commented Jul 31, 2023

Context

admins should be able to clear up the database and remove a keyword, including all instances of it currently in use

user story

DELETE /api/v1/keywords/GUID

  • admin only
  • removes keyword from all annotations
  • deletes keyword from database

resources

Image

@TanyaStere42 TanyaStere42 converted this from a draft issue Jul 31, 2023
@TanyaStere42
Copy link
Member Author

needed for WildMeOrg/codex-frontend#529

@TanyaStere42 TanyaStere42 added this to the Codex Release 2.1 milestone Jul 31, 2023
@TanyaStere42 TanyaStere42 added enhancement New feature or request good first issue Good for newcomers labels Jul 31, 2023
@TanyaStere42 TanyaStere42 removed this from the Codex Release 2.1 milestone Sep 12, 2023
@TanyaStere42 TanyaStere42 removed this from Codex 2.1 Sep 12, 2023
@naknomum
Copy link
Member

the code to do the api with keyword delete already exists, however it does not work as expected

  • right now, when you do DELETE /api/keywords/GUID you get an error, unless the keyword is not being used. this is due to the fact the db removal of the database (rightly) errors, since it is being referenced ("in use")
  • i think the solution might be to enable cascade delete on the join table which combine: Assets and Keywords, as well as the one which combine Annotation and Keywords
  • here is an example of the code to define a cascade delete

i think it would be best to first just create a keyword (aka "tag") on an image (Asset). then do the API to delete it. you should see the error, which would look like below. then modify the table definition to allow the delete, and you should see the error go away and the keyword allowed to be deleted.

ERROR:  update or delete on table "keyword" violates foreign key constraint "fk_annotation_keywords_keyword_guid_keyword" on table "annotation_keywords"
DETAIL:  Key (guid)=(50e98d54-76e0-48c2-8899-53946b7c5b81) is still referenced from table "annotation_keywords".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants