Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hivemind
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
hivemind
Commits
61fd57ef
Commit
61fd57ef
authored
11 months ago
by
Marcin
Committed by
Marcin
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
during post edition delete only already added tags id
parent
8abdd6e6
No related branches found
No related tags found
2 merge requests
!827
Merge develop changes to master
,
!681
during post edition delete only already added and going to remove tags id
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hive/db/sql_scripts/hive_post_operations.sql
+11
-5
11 additions, 5 deletions
hive/db/sql_scripts/hive_post_operations.sql
with
11 additions
and
5 deletions
hive/db/sql_scripts/hive_post_operations.sql
+
11
−
5
View file @
61fd57ef
...
...
@@ -255,18 +255,24 @@ BEGIN
block_num
=
_block_num
RETURNING
(
xmax
=
0
)
as
is_new_post
,
hp
.
id
,
hp
.
author_id
,
hp
.
permlink_id
,
_parent_permlink
as
post_category
,
hp
.
parent_id
,
hp
.
community_id
,
hp
.
is_valid
,
hp
.
is_muted
,
hp
.
depth
)
-- WITH inserted_post
,
tagsid_and_posts
AS
MATERIALIZED
(
SELECT
prepare_tags
FROM
hivemind_app
.
prepare_tags
(
ARRAY_APPEND
(
_metadata_tags
,
_parent_permlink
)
)
)
-- WITH tagsid_and_posts
,
deleted_post_tags
AS
MATERIALIZED
(
DELETE
FROM
hivemind_app
.
hive_post_tags
hpt
USING
inserted_post
as
ip
WHERE
NOT
ip
.
is_new_post
AND
hpt
.
post_id
=
ip
.
id
RETURNING
*
DELETE
FROM
hivemind_app
.
hive_post_tags
hp
USING
hivemind_app
.
hive_post_tags
as
hpt
JOIN
inserted_post
as
ip
ON
hpt
.
post_id
=
ip
.
id
AND
NOT
ip
.
is_new_post
LEFT
JOIN
tagsid_and_posts
as
tap
ON
tap
.
prepare_tags
=
hpt
.
tag_id
WHERE
hpt
.
post_id
=
hp
.
post_id
AND
tap
.
prepare_tags
IS
NULL
RETURNING
hpt
.
post_id
)
-- WITH deleted_post_tags
,
inserts_to_posts_and_tags
AS
MATERIALIZED
(
INSERT
INTO
hivemind_app
.
hive_post_tags
(
post_id
,
tag_id
)
SELECT
ip
.
id
,
tags
.
prepare_tags
FROM
inserted_post
as
ip
LEFT
JOIN
deleted_post_tags
as
dpt
ON
dpt
.
post_id
=
0
-- there is no post 0, this is only to force execute the deleted_post_tags CTE
JOIN
(
SELECT
prepare_tags
FROM
hivemind_app
.
prepare_tags
(
ARRAY_APPEND
(
_metadata_tags
,
_parent_permlink
)
)
)
as
tags
ON
TRUE
JOIN
tagsid_and_posts
as
tags
ON
TRUE
ON
CONFLICT
DO
NOTHING
)
SELECT
ip
.
is_new_post
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment