189 lines
6.8 KiB
Org Mode
189 lines
6.8 KiB
Org Mode
|
:PROPERTIES:
|
|||
|
:ID: fce5a567-37a4-414e-bb50-5ffb35d6b43b
|
|||
|
:END:
|
|||
|
#+title: 2022-05-11
|
|||
|
* Normalizing stored tag data
|
|||
|
:PROPERTIES:
|
|||
|
:header-args:sql: :eval never
|
|||
|
:header-args:http: :eval never
|
|||
|
:END:
|
|||
|
|
|||
|
Preparing to run data updates for [[id:d06d3ab4-c2d0-47c3-aae1-4395567fc3d2][Tag Normalization]].
|
|||
|
|
|||
|
** Backing up existing data
|
|||
|
*** Subscriber Tags
|
|||
|
# #+header: :dbhost app.service.staging.consul :dbport 6000 :database app
|
|||
|
# #+header: :dbpassword (password-store-get "Work/aweber/aweber.io/correlr")
|
|||
|
#+header: :var account=778
|
|||
|
#+begin_src sql :engine postgresql
|
|||
|
SELECT s.*, t.* --
|
|||
|
FROM public.subscriber_tags AS t
|
|||
|
JOIN list.subscribers AS s ON (s.id = t.subscriber_id)
|
|||
|
WHERE s.account_id = $account
|
|||
|
LIMIT 3
|
|||
|
#+end_src
|
|||
|
|
|||
|
#+RESULTS:
|
|||
|
| id | list_id | account_id | lead_id | leads_table | subscriber_id | version | tags |
|
|||
|
|------------+---------+------------+---------+-------------+---------------+---------+--------------|
|
|||
|
| 1224565879 | 3854 | 778 | 4496733 | leads4 | 1224565879 | 1 | {deleteme} |
|
|||
|
| 1224565867 | 3854 | 778 | 4496722 | leads4 | 1224565867 | 1 | {deletetest} |
|
|||
|
| 1224515286 | 3854 | 778 | 4472377 | leads4 | 1224515286 | 2 | {} |
|
|||
|
*** Segments
|
|||
|
# #+header: :dbhost (my/consul-kv "services/cp/applications/control-panel/search_master/hostname" "staging")
|
|||
|
# #+header: :dbuser (my/consul-kv "services/cp/applications/control-panel/search_master/username" "staging")
|
|||
|
# #+header: :database (my/consul-kv "services/cp/applications/control-panel/search_master/dbname" "staging")
|
|||
|
# #+header: :dbpassword (my/consul-kv "services/cp/applications/control-panel/search_master/password" "staging")
|
|||
|
#+header: :var account=778
|
|||
|
#+begin_src sql :engine postgresql
|
|||
|
SELECT c.*
|
|||
|
FROM lead_views AS v
|
|||
|
JOIN lead_view_criteria as c ON (c.lead_view_id = v.id)
|
|||
|
WHERE v.a_id = $account
|
|||
|
#+end_src
|
|||
|
|
|||
|
#+RESULTS:
|
|||
|
| id | search_box_id | lead_view_id | criteria |
|
|||
|
|-------+---------------+--------------+-------------------------------------------|
|
|||
|
| 40446 | 659 | 54648 | "barfarts" |
|
|||
|
| 40447 | 660 | 54649 | "barfarts" |
|
|||
|
| 40448 | 659 | 54650 | scott miller |
|
|||
|
| 40449 | 660 | 54651 | scott miller |
|
|||
|
| 40450 | 659 | 54652 | scott miller |
|
|||
|
| 40451 | 660 | 54653 | scott miller |
|
|||
|
| 26538 | 11 | 42564 | Scott |
|
|||
|
| 26329 | 177 | 42351 | 1243650 |
|
|||
|
| 40462 | 666 | 54660 | {"normalized tag"} |
|
|||
|
| 40463 | 666 | 54661 | {"normalized' tag"} |
|
|||
|
| 40464 | 667 | 54662 | {"normalized tag","normalized' tag"} |
|
|||
|
*** Rulesets
|
|||
|
** Choosing accounts to run against
|
|||
|
#+begin_src sql :eval never
|
|||
|
SELECT distinct account_id, count(subscriber_id) |