roam/daily/2022-04-07.org

93 lines
3.4 KiB
Org Mode
Raw Normal View History

2022-04-12 18:28:42 +00:00
:PROPERTIES:
:ID: 5762836c-ef1f-43f5-9562-3bc38ae411ed
:END:
#+title: 2022-04-07
* Verifying search tag normalization changes
:PROPERTIES:
:header-args:sql: :engine postgresql :cmdline "-U postgres postgres" :dir /docker:postgres: :exports both :cache yes
:END:
- https://jira.aweber.io/browse/ASE-8617
- https://admin.aweber.io/account/index/1018872
- List 5830776
#+caption: Segment definition: "no tags subscribers"
| Tag | is not | wr |
| Tag | is not | cb |
| Tag | is not | cb2 |
| Tag | is not | fsc |
| Tag | is not | flp |
| Tag | is not | lsa |
** Using the old =normalize_tags= implementation
#+begin_src sql :eval never
CREATE OR REPLACE FUNCTION public.normalize_tags(in_tags text[])
RETURNS text[]
LANGUAGE SQL STRICT IMMUTABLE AS $$
SELECT ARRAY_AGG(public.normalize_tag(tag))
FROM UNNEST(in_tags) AS tag;
$$;
SELECT COUNT(t.subscriber_id)
FROM subscriber_tags AS t
JOIN subscribers AS s ON (s.id = t.subscriber_id)
WHERE s.account_id = 1018872 AND s.list_id = 5830776
AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['wr'::text]))
AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['cb'::text]))
AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['cb2'::text]))
AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['fsc'::text]))
AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['flp'::text]))
AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['lsa'::text]));
#+end_src
#+RESULTS[d56d997121fe4f3ff98458e18fba912650d44796]:
| CREATE FUNCTION |
|-----------------|
| count |
| 0 |
** Using the old comparisons
#+begin_src sql :eval never
SELECT COUNT(t.subscriber_id)
FROM subscriber_tags AS t
JOIN subscribers AS s ON (s.id = t.subscriber_id)
WHERE s.account_id = 1018872 AND s.list_id = 5830776
AND NOT(t.tags @> ARRAY['wr'::text])
AND NOT(t.tags @> ARRAY['cb'::text])
AND NOT(t.tags @> ARRAY['cb2'::text])
AND NOT(t.tags @> ARRAY['fsc'::text])
AND NOT(t.tags @> ARRAY['flp'::text])
AND NOT(t.tags @> ARRAY['lsa'::text]);
#+end_src
#+RESULTS[792264b3be7d158bb6bda1124a4e23f4a19ada06]:
| count |
|-------|
| 1016 |
** Using the new =normalize_tags= implementation
#+begin_src sql :eval never
CREATE OR REPLACE FUNCTION public.normalize_tags(in_tags text[])
RETURNS text[]
LANGUAGE SQL STRICT IMMUTABLE AS $$
SELECT COALESCE(ARRAY_AGG(public.normalize_tag(tag)), ARRAY[]::text[])
FROM UNNEST(in_tags) AS tag
WHERE public.normalize_tag(tag) <> '';
$$;
SELECT COUNT(t.subscriber_id)
FROM subscriber_tags AS t
JOIN subscribers AS s ON (s.id = t.subscriber_id)
WHERE s.account_id = 1018872 AND s.list_id = 5830776
AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['wr'::text]))
AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['cb'::text]))
AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['cb2'::text]))
AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['fsc'::text]))
AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['flp'::text]))
AND NOT(public.normalize_tags(t.tags) @> public.normalize_tags(ARRAY['lsa'::text]));
#+end_src
#+RESULTS[ae72571ff73254fc70555db4517f759ddfdfcc8c]:
| CREATE FUNCTION |
|-----------------|
| count |
| 1016 |