Auto saved by Logseq

This commit is contained in:
Matthias Eckert 2024-04-16 13:28:53 +02:00
parent 86e17bae30
commit 58cc50dbd8

View File

@ -84,5 +84,148 @@
#+END_QUOTE
- ``` SQL
UPDATE ent_customerproduct SET ucid = c.ucid FROM ent_customer c WHERE c.pid=ent_customerproduct.pid AND c.cid=ent_customerproduct.cid AND ent_customerproduct.ucid IS NULL;
ALTER TABLE tmp_ent_productpage_updated OWNER TO productstore;
ALTER TABLE tmp_booking_speed_sc OWNER TO productstore;
ALTER TABLE tmp_booking_speed_pp OWNER TO productstore;
ALTER TABLE tmp_ignoring_customer_ids OWNER TO productstore;
ALTER TABLE tmp_assigned_cp_ids OWNER TO productstore;
ALTER TABLE tmp_assigning_customer_ids OWNER TO productstore;
CREATE TABLE "bkcp_ent_productpage" (like "ent_productpage");
INSERT INTO "bkcp_ent_productpage"
SELECT * FROM ent_productpage;
DROP TABLE IF EXISTS tmp_ent_productpage;
CREATE TABLE "tmp_ent_productpage" (like "ent_productpage");
INSERT INTO "tmp_ent_productpage" (
"uuid", "creation_date", "modification_date", "creator_id", "last_modifier_id", "name", "url", "url_normalized", "former_urls", "crawl_date", "language", "country", "breadcrumb", "brand", "image_url", "current_price", "number_of_replies", "number_of_reviews", "asin", "asin_normalized", "gtin", "gtin_normalized", "ean13", "ean13_normalized", "sku", "sku_normalized", "vib", "vib_normalized", "modelnumber", "modelnumber_normalized", "shopcategory_id", "shop_id", "shop_internal_id", "meta_info")
SELECT "uuid", "creation_date", "modification_date", "creator_id", "last_modifier_id", "name", "url", "url_normalized", "former_urls", "crawl_date", "language", "country", "breadcrumb", "brand", "image_url", "current_price", "number_of_replies", "number_of_reviews", "asin", "asin_normalized", "gtin", "gtin_normalized", "ean13", "ean13_normalized", "sku", "sku_normalized", "vib", "vib_normalized", "modelnumber", "modelnumber_normalized", "shopcategory_id", "shop_id", "shop_internal_id", "meta_info" FROM ent_productpage;
INSERT INTO "tmp_ent_productpage"
SELECT * FROM ent_productpage;
UPDATE tmp_ent_productpage SET booking_customer_ids = NULL, ignoring_customer_ids = NULL, assigned_cp_ids = NULL, assigning_customer_ids = NULL WHERE booking_customer_ids IS NULL OR ignoring_customer_ids IS NULL OR assigned_cp_ids IS NULL OR assigning_customer_ids IS NULL;
UPDATE tmp_ent_productpage SET booking_customer_ids = NULL, ignoring_customer_ids = NULL, assigned_cp_ids = NULL, assigning_customer_ids = NULL WHERE booking_customer_ids IS NULL OR ignoring_customer_ids IS NULL OR assigned_cp_ids IS NULL OR assigning_customer_ids IS NULL;
CREATE TABLE "tmp_ent_productpage_updated" (like "ent_productpage");
INSERT INTO tmp_ent_productpage_updated
SELECT p."uuid", "creation_date", "modification_date", "creator_id", "last_modifier_id", "name", "url", "url_normalized", "former_urls", "crawl_date", "language", "country", "breadcrumb", "brand", "image_url", "current_price", "number_of_replies", "number_of_reviews", "asin", "asin_normalized", "gtin", "gtin_normalized", "ean13", "ean13_normalized", "sku", "sku_normalized", "vib", "vib_normalized", "modelnumber", "modelnumber_normalized", "shopcategory_id", "shop_id", "shop_internal_id", "meta_info",
(ssc.speed || spp.speed || p.booking_customer_ids) AS booking_customer_ids,
acp.speed, acid.speed, ici.speed
FROM ent_productpage p LEFT JOIN tmp_booking_speed_sc ssc ON p.uuid=ssc.uuid LEFT JOIN tmp_booking_speed_pp spp ON p.uuid=spp.uuid LEFT JOIN tmp_assigned_cp_ids acp ON p.uuid=acp.uuid LEFT JOIN tmp_assigning_customer_ids acid ON p.uuid=acid.uuid LEFT JOIN tmp_ignoring_customer_ids ici ON p.uuid=ici.uuid;
TRUNCATE ent_productpage
INSERT INTO ent_productpage
SELECT p."uuid", "creation_date", "modification_date", "creator_id", "last_modifier_id", "name", "url", "url_normalized", "former_urls", "crawl_date", "language", "country", "breadcrumb", "brand", "image_url", "current_price", "number_of_replies", "number_of_reviews", "asin", "asin_normalized", "gtin", "gtin_normalized", "ean13", "ean13_normalized", "sku", "sku_normalized", "vib", "vib_normalized", "modelnumber", "modelnumber_normalized", "shopcategory_id", "shop_id", "shop_internal_id", "meta_info",
CASE WHEN ssc.speed IS NULL AND spp.speed IS NULL THEN NULL
ELSE (COALESCE(ssc.speed,'') || COALESCE(spp.speed,'')) END AS booking_customer_ids,
acp.speed, acid.speed, ici.speed
FROM bckp_ent_productpage_parallel p LEFT JOIN tmp_booking_speed_sc ssc ON p.uuid=ssc.uuid LEFT JOIN tmp_booking_speed_pp spp ON p.uuid=spp.uuid LEFT JOIN tmp_assigned_cp_ids acp ON p.uuid=acp.uuid LEFT JOIN tmp_assigning_customer_ids acid ON p.uuid=acid.uuid LEFT JOIN tmp_ignoring_customer_ids ici ON p.uuid=ici.uuid;
-- create booking speed temp table
DROP TABLE IF EXISTS tmp_booking_speed_sc;
CREATE TABLE tmp_booking_speed_sc AS
SELECT hstore_sum(a.speed) AS speed , a.uuid FROM (
SELECT i.source_uuid AS uuid, hstore(ARRAY[('sc_'||c.ucid)], ARRAY[b.target_uuid:: TEXT]) AS speed
FROM ent_customer c, rel_hasbooked b, rel_isfrom i
WHERE c.uuid=b.source_uuid AND b.target_uuid=i.target_uuid
) a GROUP BY a.uuid;
CREATE INDEX IF NOT EXISTS pp_uuid_idx1 ON tmp_booking_speed_sc(uuid);
UPDATE tmp_ent_productpage p
SET booking_customer_ids = COALESCE(booking_customer_ids, '') || s.speed
FROM
tmp_booking_speed_sc s
WHERE s.uuid = p.uuid;
DROP TABLE IF EXISTS tmp_booking_speed_sc;
-- new RelationType(EDGE_LABEL_HAS_DIRECTLY_BOOKED, C, PP)
DROP TABLE IF EXISTS tmp_booking_speed_pp;
CREATE TABLE tmp_booking_speed_pp AS
SELECT hstore_sum(a.speed) AS speed, a.uuid FROM (
SELECT b.target_uuid AS uuid, hstore(ARRAY[('d_'||c.ucid)], ARRAY[c.ucid::TEXT]) AS speed
FROM ent_customer c, rel_hasdirectlybooked b
WHERE c.uuid=b.source_uuid
) a GROUP BY a.uuid;
CREATE INDEX IF NOT EXISTS pp_uuid_idx2 ON tmp_booking_speed_pp(uuid);
UPDATE tmp_ent_productpage p
SET booking_customer_ids = COALESCE(booking_customer_ids, '') || s.speed
FROM
tmp_booking_speed_pp s
WHERE s.uuid = p.uuid;
DROP TABLE IF EXISTS tmp_booking_speed_pp;
-- new RelationType(EDGE_LABEL_IRRELEVANT, C, PP)
DROP TABLE IF EXISTS tmp_ignoring_customer_ids;
CREATE TABLE tmp_ignoring_customer_ids AS
SELECT hstore_sum(a.speed) AS speed , a.uuid FROM (
SELECT i.target_uuid AS uuid, hstore(ARRAY[c.ucid:: TEXT], ARRAY[c.ucid:: TEXT]) AS speed
FROM ent_customer c, rel_isirrelevant i
WHERE c.uuid=i.source_uuid
) a GROUP BY a.uuid;
CREATE INDEX IF NOT EXISTS pp_uuid_idx3 ON tmp_ignoring_customer_ids(uuid);
UPDATE tmp_ent_productpage p
SET ignoring_customer_ids = COALESCE(ignoring_customer_ids, '') || s.speed
FROM
tmp_ignoring_customer_ids s
WHERE s.uuid = p.uuid;
DROP TABLE IF EXISTS tmp_ignoring_customer_ids;
-- new RelationType(EDGE_LABEL_CONTAINS, CP, PP)
DROP TABLE IF EXISTS tmp_assigned_cp_ids;
CREATE TABLE tmp_assigned_cp_ids AS
SELECT hstore_sum(a.speed) AS speed , a.uuid FROM (
SELECT i.target_uuid AS uuid, hstore(ARRAY[c.uuid:: TEXT], ARRAY[c.ucid:: TEXT]) AS speed
FROM ent_customerproduct c, rel_contains i
WHERE c.uuid=i.source_uuid
) a GROUP BY a.uuid;
CREATE INDEX IF NOT EXISTS pp_uuid_idx4 ON tmp_assigned_cp_ids(uuid);
UPDATE tmp_ent_productpage p
SET assigned_cp_ids = COALESCE(assigned_cp_ids, '') || s.speed
FROM
tmp_assigned_cp_ids s
WHERE s.uuid = p.uuid;
DROP TABLE IF EXISTS tmp_assigned_cp_ids;
-- new RelationType(EDGE_LABEL_CONTAINS, CP, PP)
DROP TABLE IF EXISTS tmp_assigning_customer_ids;
CREATE TABLE tmp_assigning_customer_ids AS
SELECT hstore_sum(a.speed) AS speed , a.uuid FROM (
SELECT i.target_uuid AS uuid, hstore(ARRAY[c.ucid:: TEXT], ARRAY[c.uuid:: TEXT]) AS speed
FROM ent_customerproduct c, rel_contains i
WHERE c.uuid=i.source_uuid
) a GROUP BY a.uuid;
CREATE INDEX IF NOT EXISTS pp_uuid_idx5 ON tmp_assigning_customer_ids(uuid);
UPDATE tmp_ent_productpage p
SET assigning_customer_ids = COALESCE(assigning_customer_ids, '') || s.speed
FROM
tmp_assigning_customer_ids s
WHERE s.uuid = p.uuid;
DROP TABLE IF EXISTS tmp_assigning_customer_ids;
```
- #+BEGIN_QUOTE
Save translations
pg_dump -a translationservice > translations2.sql
pv -e translations.sql | psql translationservice
#+END_QUOTE #+END_QUOTE
- -