Skip to content

Commit

Permalink
0.0.491
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansglazunov committed Sep 11, 2024
1 parent 6aade78 commit 5f2b9ae
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 75 deletions.
15 changes: 9 additions & 6 deletions migrations/1622421760258-selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ export const up = async () => {
cache_include."selector_include_id" as "selector_include_id",
cache_include."selector_filter_bool_exp_id" as "query_id"
FROM
${MP_TABLE_NAME} as mp_include,
${CACHE} as cache_include
${MP_TABLE_NAME} as mp_include
JOIN
${CACHE} cache_include
ON
mp_include."path_item_id" = cache_include."link_id"
AND mp_include."group_id" = cache_include."tree_id"
WHERE
cache_include."selector_include_id" != 0 AND
mp_include."path_item_id" = cache_include."link_id" AND
mp_include."group_id" = cache_include."tree_id" ${/*AND
cache_include."selector_include_id" != 0
${/*AND
NOT EXISTS (
SELECT mp_exclude."id"
FROM
Expand All @@ -55,7 +58,7 @@ export const up = async () => {
mp_exclude."item_id" = mp_include."item_id" AND
mp_exclude."group_id" = cache_exclude."tree_id"
)
)*/''};
)*/''}
`);
await api.sql(sql`
CREATE OR REPLACE FUNCTION bool_exp_execute(target_link_id bigint, bool_exp_link_id bigint, user_id bigint) RETURNS BOOL AS $trigger$ DECLARE
Expand Down
84 changes: 16 additions & 68 deletions migrations/1622421760259-can.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,74 +32,22 @@ export const up = async () => {
CREATE VIEW ${CAN_TABLE_NAME} AS
SELECT DISTINCT ca."rule_id" as "rule_id", mpo_include."item_id" as "object_id", mps_include."item_id" as "subject_id", mpa_include."item_id" as "action_id"
FROM
${CACHE} as ca,
${MP} as mpa_include,
${CACHE} as co,
${MP} as mpo_include,
${CACHE} as cs,
${MP} as mps_include
WHERE (
ca."rule_id" != 0 AND
co."rule_id" != 0 AND
cs."rule_id" != 0 AND
ca."rule_id" = co."rule_id" AND
ca."rule_id" = cs."rule_id" AND
ca."rule_action_id" != 0 AND
ca."selector_include_id" != 0 AND
mpa_include."path_item_id" = ca."link_id" AND
mpa_include."group_id" = ca."tree_id" AND
${/*NOT EXISTS (
SELECT mpa_exclude."id"
FROM
${CACHE} as cache_exclude,
${MP} as mpa_exclude
WHERE (
cache_exclude."selector_exclude_id" != 0 AND
cache_exclude."selector_id" = ca."selector_id" AND
mpa_exclude."path_item_id" = cache_exclude."link_id" AND
mpa_exclude."item_id" = mpa_include."item_id" AND
mpa_exclude."group_id" = cache_exclude."tree_id"
)
) AND*/''}
co."rule_object_id" != 0 AND
co."selector_include_id" != 0 AND
mpo_include."path_item_id" = co."link_id" AND
mpo_include."group_id" = co."tree_id" AND
${/*NOT EXISTS (
SELECT mpo_exclude."id"
FROM
${CACHE} as cache_exclude,
${MP} as mpo_exclude
WHERE (
cache_exclude."selector_exclude_id" != 0 AND
cache_exclude."selector_id" = co."selector_id" AND
mpo_exclude."path_item_id" = cache_exclude."link_id" AND
mpo_exclude."item_id" = mpo_include."item_id" AND
mpo_exclude."group_id" = cache_exclude."tree_id"
)
) AND*/''}
cs."rule_subject_id" != 0 AND
cs."selector_include_id" != 0 AND
mps_include."path_item_id" = cs."link_id" AND
mps_include."group_id" = cs."tree_id"
${/*NOT EXISTS (
SELECT mps_exclude."id"
FROM
${CACHE} as cache_exclude,
${MP} as mps_exclude
WHERE (
cache_exclude."selector_exclude_id" != 0 AND
cache_exclude."selector_id" = cs."selector_id" AND
mps_exclude."path_item_id" = cache_exclude."link_id" AND
mps_exclude."item_id" = mps_include."item_id" AND
mps_exclude."group_id" = cache_exclude."tree_id"
)
)*/''}
);
${CACHE} co
JOIN
${MP} mpo_include ON mpo_include.path_item_id = co.link_id
AND mpo_include.group_id = co.tree_id
JOIN
${CACHE} ca ON ca.rule_id = co.rule_id
JOIN
${MP} mpa_include ON mpa_include.path_item_id = ca.link_id
AND mpa_include.group_id = ca.tree_id
JOIN
${CACHE} cs ON ca.rule_id = cs.rule_id
JOIN
${MP} mps_include ON mps_include.path_item_id = cs.link_id
AND mps_include.group_id = cs.tree_id
WHERE
ca."rule_id" != 0
`);
await api.query({
type: 'track_table',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deep-foundation/deeplinks",
"version": "0.0.490",
"version": "0.0.491",
"license": "Unlicense",
"type": "module",
"scripts": {
Expand Down

0 comments on commit 5f2b9ae

Please sign in to comment.