Commit e27f3db1 authored by Remi Rampin's avatar Remi Rampin

WIP Fix merging tags with common highlights

parent ba1099da
Pipeline #77605389 passed with stage
in 2 minutes and 30 seconds
......@@ -356,12 +356,22 @@ class TagMerge(BaseHandler):
tag_dest is None or tag_dest.project_id != project.id):
self.set_status(404)
return self.send_json({'error': "No such tag"})
# Remove tag from tag_src if it's already in tag_dest
(
self.db.query(database.HighlightTag)
.filter(database.HighlightTag.tag_id == tag_src.id)
.filter("ALSO HAS tag_dest -- SUBQUERY?")
).delete()
# Update tags that are in tag_src to be in tag_dest
self.db.execute(
database.HighlightTag.__table__.update()
.where(database.HighlightTag.tag_id == tag_src.id)
.values(tag_id=tag_dest.id)
)
# Delete tag_src
self.db.delete(tag_src)
cmd = database.Command.tag_merge(
self.current_user,
project.id,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment