This commit is contained in:
Correl Roush 2022-05-27 17:34:47 -04:00
parent 8501bb255f
commit fedd4369b1
13 changed files with 548 additions and 0 deletions

View File

@ -0,0 +1,4 @@
:PROPERTIES:
:ID: 80e2ff2d-fd2f-4a14-91d7-855159de4f6e
:END:
#+title: Riichi Mahjong

10
20220518114208-mjai.org Normal file
View File

@ -0,0 +1,10 @@
:PROPERTIES:
:ID: 4af45a5a-db3b-4d49-82c7-3671f62d3283
:ROAM_REFS: https://gimite.net/pukiwiki/index.php?Mjai%20%E9%BA%BB%E9%9B%80AI%E5%AF%BE%E6%88%A6%E3%82%B5%E3%83%BC%E3%83%90
:END:
#+title: MJAI
A JSON file format for describing a [[id:80e2ff2d-fd2f-4a14-91d7-855159de4f6e][Riichi Mahjong]] game event log.
- Reference implementation :: https://github.com/gimite/mjai
- [[id:8b2cbf9b-ffcb-4282-81ab-200a2f819b07][Mortal]] implementation :: https://github.com/Equim-chan/Mortal/blob/1dcbc8193159ddfef0db3b25af30d716d9ae6e8e/libriichi/src/mjai.rs

View File

@ -0,0 +1,4 @@
:PROPERTIES:
:ID: 1ff6586e-2dba-41a2-a887-753cc5ac27c9
:END:
#+title: Recipient Service

BIN
daily/2022-05-11.org Normal file

Binary file not shown.

142
daily/2022-05-17.org Normal file
View File

@ -0,0 +1,142 @@
:PROPERTIES:
:ID: 5ac31f6f-3da3-4d5a-b107-be3fa09dc710
:END:
#+title: 2022-05-17
* Comparing text fields numerically
:PROPERTIES:
:header-args:sql: :engine postgresql :dbhost app.service.staging.consul :dbport 6000 :database app :dbpassword (password-store-get "Work/aweber/aweber.io/correlr") :eval no-export
:END:
Supporting numeric comparisons in [[id:dd113e53-6144-4cb2-a4aa-da3dc2e3e6ea][AppDB]] on [[id:af84ed59-96a4-4f9c-b34c-b79178ad20cb][PostgreSQL]] 9.
#+begin_src sql
SELECT email
, datum1
, ROW(COALESCE(trim(substring(datum1, E'^[^0-9]+')), ''), COALESCE(substring(datum1, E'([0-9]+(\\.[0-9]+)?)')::float,0), datum1) AS orderable
FROM leads4
WHERE unit_id = 3854 AND datum1 IS NOT NULL
AND ROW(COALESCE(trim(substring(datum1, E'^[^0-9]+')), ''), COALESCE(substring(datum1, E'([0-9]+(\\.[0-9]+)?)')::float,0), datum1) > ROW(COALESCE(trim(substring('50', E'^[^0-9]+')), ''), COALESCE(substring('50', E'([0-9]+(\\.[0-9]+)?)')::float,0), '50')
ORDER BY orderable
#+end_src
#+RESULTS:
| email | datum1 | orderable |
|-------------------------+--------------+-------------------------|
| correlr@aweber.com | 69 | ("",69,69) |
| correlr+0031@aweber.net | 73.50 | ("",73.5,73.50) |
| scottm@aweber.net | 101 | ("",101,101) |
| correlr+0033@aweber.net | 215 555 1234 | ("",215,"215 555 1234") |
| correlr+0040@aweber.net | 215 555 9372 | ("",215,"215 555 9372") |
| correlr+005@aweber.net | 215-555-7777 | ("",215,215-555-7777) |
| correlr+0028@aweber.net | 404 | ("",404,404) |
| correlr+0032@aweber.net | 404 Apple | ("",404,"404 Apple") |
| correlr+0029@aweber.net | 711 | ("",711,711) |
| correlr+0037@aweber.net | $ 112.65 | ($,112.65,"$ 112.65") |
| correlr+0034@aweber.net | $112.65 | ($,112.65,$112.65) |
| -----@aweber.com | A 100 | (A,100,"A 100") |
| correlr+004@aweber.net | ED-209 | (ED-,209,ED-209) |
#+begin_src sql :eval never
CREATE OR REPLACE FUNCTION public.collate_numerically(value text)
RETURNS RECORD
LANGUAGE SQL STRICT IMMUTABLE AS $$
SELECT ROW(COALESCE(trim(substring($1, E'^[^0-9]+')), ''),
COALESCE(substring($1, E'([0-9]+(\\.[0-9]+)?)')::float,0),
$1);
$$;
#+end_src
#+begin_src sql
SELECT email
, datum1
, CASE
WHEN datum1 IS NULL THEN ''
WHEN datum1 ~ E'^[0-9\.]+$'
THEN lpad(lower(datum1), 30, '0')
ELSE rpad(lower(datum1), 30, '0')
END AS orderable
FROM leads4
WHERE unit_id = 3854 AND datum1 IS NOT NULL
ORDER BY orderable
#+end_src
#+RESULTS:
| email | datum1 | orderable |
|------------------------------+--------------+--------------------------------|
| correlr+0037@aweber.net | $ 112.65 | $ 112.650000000000000000000000 |
| correlr+0034@aweber.net | $112.65 | $112.6500000000000000000000000 |
| correlr+notags003@aweber.net | | 000000000000000000000000000000 |
| correlr+003@aweber.net | | 000000000000000000000000000000 |
| correlr+002@aweber.net | | 000000000000000000000000000000 |
| correlr+001@aweber.net | | 000000000000000000000000000000 |
| correlr+0041@aweber.net | | 000000000000000000000000000000 |
| correlr+0027@aweber.net | | 000000000000000000000000000000 |
| correlr+0026@aweber.net | | 000000000000000000000000000000 |
| correlr+0021@aweber.net | | 000000000000000000000000000000 |
| correl+bad03@gmail.com | | 000000000000000000000000000000 |
| correlr@aweber.com | 69 | 000000000000000000000000000069 |
| scottm@aweber.net | 101 | 000000000000000000000000000101 |
| correlr+0028@aweber.net | 404 | 000000000000000000000000000404 |
| correlr+0029@aweber.net | 711 | 000000000000000000000000000711 |
| correlr+0031@aweber.net | 73.50 | 000000000000000000000000073.50 |
| correlr+0033@aweber.net | 215 555 1234 | 215 555 1234000000000000000000 |
| correlr+0040@aweber.net | 215 555 9372 | 215 555 9372000000000000000000 |
| correlr+005@aweber.net | 215-555-7777 | 215-555-7777000000000000000000 |
| correlr+0032@aweber.net | 404 Apple | 404 apple000000000000000000000 |
| -----@aweber.com | A 100 | a 1000000000000000000000000000 |
| correlr+004@aweber.net | ED-209 | ed-209000000000000000000000000 |
#+begin_src sql :engine postgresql
SELECT email, datum1 FROM leads4
WHERE unit_id = 3854 AND datum1 IS NOT NULL
ORDER BY datum1
#+end_src
#+RESULTS:
| email | datum1 |
|------------------------------+--------|
| correlr+notags003@aweber.net | |
| correlr+0028@aweber.net | |
| correlr+0027@aweber.net | |
| correlr+0026@aweber.net | |
| correlr+0021@aweber.net | |
| correl+bad03@gmail.com | |
| correlr+005@aweber.net | |
| correlr+003@aweber.net | |
| correlr+002@aweber.net | |
| correlr+001@aweber.net | |
| correlr+0041@aweber.net | |
| correlr+0040@aweber.net | |
| correlr+0034@aweber.net | |
| correlr+0033@aweber.net | |
| correlr+0032@aweber.net | |
| scottm@aweber.net | 101 |
| correlr@aweber.com | 69 |
| correlr+0029@aweber.net | 711 |
| -----@aweber.com | A 100 |
| correlr+004@aweber.net | ED-209 |
#+begin_src sql
SELECT email
, datum1
, ROW(COALESCE(substring(datum1, E'[^0-9]+'), ''), COALESCE(substring(datum1, E'[0-9]+')::int,0), datum1) AS orderable
FROM leads4
WHERE unit_id = 13971
AND ROW(COALESCE(substring('1548862518', E'[^0-9]+'), ''), COALESCE(substring('1548862518', E'[0-9]+')::int,0), '1548862518')
>
ROW(COALESCE(substring(datum1, E'[^0-9]+'), ''), COALESCE(substring(datum1, E'[0-9]+')::int,0), datum1)
ORDER BY orderable;
#+end_src
#+RESULTS:
| email | datum1 | orderable |
|--------------------------------------+--------+-----------|
| moana.rock.diuwasly@mailosaur.io | | ("",0,"") |
| 1548862167.suf.lsb8bll2@mailosaur.io | | ("",0,) |
| 1548862018.suf.lsb8bll2@mailosaur.io | | ("",0,) |
| 1548861949.suf.lsb8bll2@mailosaur.io | | ("",0,) |
| 1548861848.suf.lsb8bll2@mailosaur.io | | ("",0,) |
| 1548862325.suf.lsb8bll2@mailosaur.io | | ("",0,) |
| bob.smith.diuwasly@mailosaur.io | | ("",0,) |
| iharh+8df668454@aweber.net | | ("",0,) |
| 1548861786.suf.lsb8bll2@mailosaur.io | | ("",0,) |
| iharh+56651@aweber.net | 3 | ("",3,3) |

70
daily/2022-05-18.org Normal file
View File

@ -0,0 +1,70 @@
:PROPERTIES:
:ID: 0695048f-6974-4a55-be6c-75de2dcdecec
:END:
#+title: 2022-05-18
* [[id:d06d3ab4-c2d0-47c3-aae1-4395567fc3d2][Normalizing tags]] in production
:PROPERTIES:
:header-args:sql: :engine postgresql :cmdline "-U postgres postgres" :dir /docker:postgres: :exports both :cache yes :eval no-export
:END:
#+CAPTION: Create a table to track normalized accounts
#+begin_src sql
DROP TABLE IF EXISTS accounts;
CREATE TABLE accounts AS
SELECT account_id, COUNT(tag) AS total, FALSE AS normalized
FROM invalid_tags
GROUP BY account_id;
#+end_src
#+RESULTS[ee123c16042ab3a3381135fd50e2e474a126af94]:
| DROP TABLE |
|-------------|
| SELECT 3220 |
#+CAPTION: Find the least affected accounts first
#+begin_src sql
SELECT COUNT(*)
FROM accounts
WHERE NOT normalized AND total < 100
#+end_src
#+RESULTS[b0aec0d7b3e1a161356aec4a1d23b1b1fe3d82c5]:
| count |
|-------|
| 2241 |
#+CAPTION: Find the least affected accounts first
#+NAME: first-run-accounts
#+begin_src sql :results silent
SELECT account_id
FROM accounts
WHERE NOT normalized AND total = 1
#+end_src
#+begin_src emacs-lisp :var accounts=first-run-accounts :results file :eval no-export
(let ((filename "~/git/normalize_account_tags/production/01-single-tag-accounts"))
(with-temp-file filename
(insert (s-join "\n" (-map #'first accounts))))
filename)
#+end_src
#+RESULTS:
[[file:~/git/normalize_account_tags/production/01-single-tag-accounts]]
#+begin_example
########################################
### COMPLETED 473/473 (0 remaining)
### ELAPSED: 02:21:49
### ESTIMATED REMAINING: 00:00:00
########################################
#+end_example
#+begin_src sql
UPDATE accounts
SET normalized = TRUE
WHERE NOT normalized AND total = 1
#+end_src
#+RESULTS[f9106d0f56ea4455273bfaa63a4b4576d8a30f7f]:
| UPDATE 474 |
|------------|

59
daily/2022-05-20.org Normal file
View File

@ -0,0 +1,59 @@
:PROPERTIES:
:ID: c1a4dc1f-abdd-4ee7-891d-6441af049642
:END:
#+title: 2022-05-20
* [[id:d06d3ab4-c2d0-47c3-aae1-4395567fc3d2][Normalizing tags]] in production
:PROPERTIES:
:header-args:sql: :engine postgresql :cmdline "-U postgres postgres" :dir /docker:postgres: :exports both :cache yes :eval no-export
:END:
#+CAPTION: Find the next set of least affected accounts
#+begin_src sql
SELECT COUNT(*)
FROM accounts
WHERE NOT normalized AND total <= 10
#+end_src
#+RESULTS[95dd01f1826657f1d72cf437dd5c045cf78c997c]:
| count |
|-------|
| 759 |
#+CAPTION: Find the next set of least affected accounts
#+NAME: 02-less-than-equal-to-ten
#+begin_src sql :results silent
SELECT account_id
FROM accounts
WHERE NOT normalized AND total <= 10
#+end_src
#+begin_src emacs-lisp :var accounts=02-less-than-equal-to-ten :results file :eval no-export
(let ((filename "~/git/normalize_account_tags/production/02-less-than-equal-to-ten"))
(with-temp-file filename
(insert (s-join "\n" (-map #'car accounts))))
filename)
#+end_src
#+RESULTS:
[[file:~/git/normalize_account_tags/production/02-less-than-equal-to-ten]]
#+begin_src sql
UPDATE accounts SET normalized = TRUE
WHERE NOT normalized AND total <= 10
#+end_src
#+RESULTS[758c043c5bfacfb10f6a17c306ca76536b92abee]:
| UPDATE 759 |
|------------|
* Sync up on [[id:1ff6586e-2dba-41a2-a887-753cc5ac27c9][Recipient Service]] updates
- Andrew is still working on tests for the updated =GET= endpoints due to
unrelated sprockets amqp ioloop issues.
- Subscriber sync change needs to be done next to check for existence of the
recipient record rather than the subscriber record, as the latter will now
always exist.
* Senior engineering meet up
- Create a ticket to add an api-suspenders style queuing system in the [[id:1ff6586e-2dba-41a2-a887-753cc5ac27c9][Recipient Service]]'s
subscriber creation implementation using redis for storage.

37
daily/2022-05-23.org Normal file
View File

@ -0,0 +1,37 @@
:PROPERTIES:
:ID: b2a4956b-0fcb-4809-b191-e29eb086367f
:END:
#+title: 2022-05-23
* [[id:d06d3ab4-c2d0-47c3-aae1-4395567fc3d2][Normalizing tags]] in production
:PROPERTIES:
:header-args:sql: :engine postgresql :cmdline "-U postgres postgres" :dir /docker:postgres: :exports both :cache yes :eval no-export
:END:
#+CAPTION: Find the next set of least affected accounts
#+begin_src sql
SELECT COUNT(*)
FROM accounts
WHERE NOT normalized AND total <= 50
#+end_src
#+RESULTS[3b91f19494773258001c8f81134f9b930f7a5898]:
| count |
|-------|
| 708 |
#+CAPTION: Find the next set of least affected accounts
#+NAME: 03-less-than-equal-to-fifty
#+begin_src sql :results silent
SELECT account_id
FROM accounts
WHERE NOT normalized AND total <= 50
#+end_src
#+begin_src emacs-lisp :var accounts=03-less-than-equal-to-fifty :results file :eval no-export
(let ((filename "~/git/normalize_account_tags/production/03-less-than-equal-to-fifty"))
(with-temp-file filename
(insert (s-join "\n" (-map #'car accounts))))
filename)
#+end_src
#+RESULTS:
[[file:~/git/normalize_account_tags/production/03-less-than-equal-to-fifty]]

66
daily/2022-05-24.org Normal file
View File

@ -0,0 +1,66 @@
:PROPERTIES:
:ID: 3c57d654-309e-4297-a8f6-e14809e512db
:END:
#+title: 2022-05-24
* [[id:d06d3ab4-c2d0-47c3-aae1-4395567fc3d2][Normalizing tags]] in production
:PROPERTIES:
:header-args:sql: :engine postgresql :cmdline "-U postgres postgres" :dir /docker:postgres: :exports both :cache yes :eval no-export
:END:
** Completing yesterday's set
#+CAPTION: Find the next set of least affected accounts
#+begin_src sql
SELECT COUNT(*)
FROM accounts
WHERE NOT normalized AND total <= 50
#+end_src
#+RESULTS[3b91f19494773258001c8f81134f9b930f7a5898]:
| count |
|-------|
| 385 |
#+CAPTION: Find the next set of least affected accounts
#+NAME: 04-less-than-equal-to-fifty
#+begin_src sql :results silent
SELECT account_id
FROM accounts
WHERE NOT normalized AND total <= 50
#+end_src
#+begin_src emacs-lisp :var accounts=04-less-than-equal-to-fifty :results file :eval no-export
(let ((filename "~/git/normalize_account_tags/production/04-less-than-equal-to-fifty"))
(with-temp-file filename
(insert (s-join "\n" (-map #'car accounts))))
filename)
#+end_src
#+RESULTS:
[[file:~/git/normalize_account_tags/production/04-less-than-equal-to-fifty]]
** Next set
#+CAPTION: Find the next set of least affected accounts
#+begin_src sql
SELECT COUNT(*)
FROM accounts
WHERE NOT normalized AND total <= 100
#+end_src
#+RESULTS[ef2cfc019cfa507c8e70a11e2c51488945751704]:
| count |
|-------|
| 306 |
#+CAPTION: Find the next set of least affected accounts
#+NAME: 05-less-than-equal-to-one-hundred
#+begin_src sql :results silent
SELECT account_id
FROM accounts
WHERE NOT normalized AND total <= 100
#+end_src
#+begin_src emacs-lisp :var accounts=05-less-than-equal-to-one-hundred :results file :eval no-export
(let ((filename "~/git/normalize_account_tags/production/05-less-than-equal-to-one-hundred"))
(with-temp-file filename
(insert (s-join "\n" (-map #'car accounts))))
filename)
#+end_src

37
daily/2022-05-25.org Normal file
View File

@ -0,0 +1,37 @@
:PROPERTIES:
:ID: eaa8559b-5e23-4922-98c3-4574b63c40f9
:END:
#+title: 2022-05-25
* [[id:d06d3ab4-c2d0-47c3-aae1-4395567fc3d2][Normalizing tags]] in production
:PROPERTIES:
:header-args:sql: :engine postgresql :cmdline "-U postgres postgres" :dir /docker:postgres: :exports both :cache yes :eval no-export
:END:
#+CAPTION: Find the next set of least affected accounts
#+begin_src sql
SELECT COUNT(*)
FROM accounts
WHERE NOT normalized AND total <= 500
#+end_src
#+RESULTS[4e2afc6030287036e6f8e35197d2286a91d155b1]:
| count |
|-------|
| 586 |
#+CAPTION: Find the next set of least affected accounts
#+NAME: 06-less-than-equal-to-five-hundred
#+begin_src sql :results silent
SELECT account_id
FROM accounts
WHERE NOT normalized AND total <= 500
#+end_src
#+begin_src emacs-lisp :var accounts=06-less-than-equal-to-five-hundred :results file :eval no-export
(let ((filename "~/git/normalize_account_tags/production/06-less-than-equal-to-five-hundred"))
(with-temp-file filename
(insert (s-join "\n" (-map #'car accounts))))
filename)
#+end_src
#+RESULTS:
[[file:~/git/normalize_account_tags/production/06-less-than-equal-to-five-hundred]]

73
daily/2022-05-26.org Normal file
View File

@ -0,0 +1,73 @@
:PROPERTIES:
:ID: f5d02f07-3585-49b1-a2e1-5867edf94680
:END:
#+title: 2022-05-26
* [[id:d06d3ab4-c2d0-47c3-aae1-4395567fc3d2][Normalizing tags]] in production
:PROPERTIES:
:header-args:sql: :engine postgresql :cmdline "-U postgres postgres" :dir /docker:postgres: :exports both :cache yes :eval no-export
:END:
** First pass
#+CAPTION: Find the next set of least affected accounts
#+begin_src sql
SELECT COUNT(*)
FROM accounts
WHERE NOT normalized AND total <= 500
#+end_src
#+RESULTS[4e2afc6030287036e6f8e35197d2286a91d155b1]:
| count |
|-------|
| 371 |
#+CAPTION: Find the next set of least affected accounts
#+NAME: 07-less-than-equal-to-five-hundred
#+begin_src sql :results silent
SELECT account_id
FROM accounts
WHERE NOT normalized AND total <= 500
#+end_src
#+begin_src emacs-lisp :var accounts=07-less-than-equal-to-five-hundred :results file :eval no-export
(let ((filename "~/git/normalize_account_tags/production/07-less-than-equal-to-five-hundred"))
(with-temp-file filename
(insert (s-join "\n" (-map #'car accounts))))
filename)
#+end_src
#+RESULTS:
[[file:~/git/normalize_account_tags/production/07-less-than-equal-to-five-hundred]]
** Encountered mapping errors
There were a significant number of 503 errors being raised by mapping that
affected the run. Only accounts that were normalized successfully were marked as
complete. Mapping was restarted in production, clearing up the errors.
** Resuming
#+CAPTION: Find the next set of least affected accounts
#+begin_src sql
SELECT COUNT(*)
FROM accounts
WHERE NOT normalized AND total <= 500
#+end_src
#+RESULTS[4e2afc6030287036e6f8e35197d2286a91d155b1]:
| count |
|-------|
| 152 |
#+CAPTION: Find the next set of least affected accounts
#+NAME: 08-less-than-equal-to-five-hundred
#+begin_src sql :results silent
SELECT account_id
FROM accounts
WHERE NOT normalized AND total <= 500
#+end_src
#+begin_src emacs-lisp :var accounts=08-less-than-equal-to-five-hundred :results file :eval no-export
(let ((filename "~/git/normalize_account_tags/production/08-less-than-equal-to-five-hundred"))
(with-temp-file filename
(insert (s-join "\n" (-map #'car accounts))))
filename)
#+end_src
#+RESULTS:
[[file:~/git/normalize_account_tags/production/08-less-than-equal-to-five-hundred]]

38
daily/2022-05-27.org Normal file
View File

@ -0,0 +1,38 @@
:PROPERTIES:
:ID: ada428ac-6937-4790-83a8-d67852a9de33
:END:
#+title: 2022-05-27
* [[id:d06d3ab4-c2d0-47c3-aae1-4395567fc3d2][Normalizing tags]] in production
:PROPERTIES:
:header-args:sql: :engine postgresql :cmdline "-U postgres postgres" :dir /docker:postgres: :exports both :cache yes :eval no-export
:END:
#+CAPTION: Find the next set of least affected accounts
#+begin_src sql
SELECT COUNT(*)
FROM accounts
WHERE NOT normalized AND total <= 1000
#+end_src
#+RESULTS[efaf69d6d049d7a136ec43b141a98833c0f2931e]:
| count |
|-------|
| 301 |
#+CAPTION: Find the next set of least affected accounts
#+NAME: 09-less-than-equal-to-one-thousand
#+begin_src sql :results silent
SELECT account_id
FROM accounts
WHERE NOT normalized AND total <= 1000
#+end_src
#+begin_src emacs-lisp :var accounts=09-less-than-equal-to-one-thousand :results file :eval no-export
(let ((filename "~/git/normalize_account_tags/production/09-less-than-equal-to-one-thousand"))
(with-temp-file filename
(insert (s-join "\n" (-map #'car accounts))))
filename)
#+end_src
#+RESULTS:
[[file:~/git/normalize_account_tags/production/09-less-than-equal-to-one-thousand]]

View File

@ -0,0 +1,8 @@
:PROPERTIES:
:ID: 8b2cbf9b-ffcb-4282-81ab-200a2f819b07
:ROAM_REFS: https://mortal.ekyu.moe/index.html
:END:
#+title: Mortal
An artificial intelligence for playing [[id:80e2ff2d-fd2f-4a14-91d7-855159de4f6e][Riichi Mahjong]]. Takes MJAI (JSON) as
input for game logs.