Files
gw-svelte/mail-api/__pycache__/db.cpython-314.pyc
T

106 lines
8.5 KiB
Plaintext
Raw Normal View History

2026-05-18 22:25:43 +12:00
+
Åç
ãó@a0t$Rt^RIHt^RIt^RIt^RIt^RIt^RIH t ^RI
t
]P!R4t
RsR]R&]P !4t]P !4tRsRR ltR
R ltR R
ltRRltRRltRRltRRltR# ] dRt
Lti;i)Postgres-backed key/value persistence for mail-api admin state.
The mail-api historically stored client_profiles / allowed_emails / drafts
as JSON files on a Docker volume. This module lets the same data live in
the shared Goodwalk postgres database so the admin dashboard at
admin.goodwalk.co.nz reads from a real database instead of a per-container
JSON file. JSON files remain as a development/local fallback and as the
seed source for the initial postgres migration.
)Ú annotationsN)ÚAnyz mail-api.dbrÚ_poolFcóV^8„dQhRR/#)éÚreturnÚstr©)Úformats"Ú1C:\Users\mattc\gw-svelte\gw-svelte\mail-api\db.pyÚ __annotate__r !s÷>cór\PPRR4;'gRP4#)Ú DATABASE_URLÚ)ÚosÚenvironÚgetÚstripr r
r Ú database_urlr!s(Ü J‰JN‰N˜>¨2Ó .× 4°"× =r
cóV^8„dQhRR/#©rrÚboolr )r
s"r r r %s÷88r
cóH\\44;'d \RJ#)N)rrÚasyncpgr r
r Ú
is_enabledr%sÜ  Ó × 7¤G°4Ð$7Ð7r
cóV^8„dQhRR/#)rrrr )r
s"r r r )s÷ñ˜ñr
c ƒó"\4'gR#\e\#\;_uu_4GRjxL
\fA\P!\ 4^^^
R7GRjxL
s\ PR4RRR4GRjxL
\#LbL1 \d3p\ PRT4Rp?RRR4GRjxL
R#Rp?ii;iLN +GRjxL
'gi\#;i5i)zFReturn a lazily-initialised asyncpg pool, or None when DB is disabled.N)ÚdsnÚmin_sizeÚmax_sizeÚcommand_timeoutz,Postgres pool ready for admin_kv persistencez9Postgres pool init failed (%s); falling back to JSON only)
rrÚ
_pool_lockrÚ create_poolrÚloggerÚinfoÚ ExceptionÚwarning)Úexcs r Úget_poolr))éô <Š<ÙÜ Ò܈ ßzŽzÜ Š=ð
Ü$ØØØ$&ô ÷ô  Ð €Lññøôô
ÜÐZÐ\_Ô÷zŠzûð
ú÷zz‰zô €Lüs3C?µBC?¹ CÁ%BÁ(BÁ)BÂ C?Â
CÂ C?ÂBÂ CÂ'CÂ=CÃ C?Ã CÃ
C?ÃCÃCÃC?ÃC< Ã$C'Ã%
C< Ã0C< Ã2
C?cóV^8„dQhRR/#)rrÚNoner )r
s"r r r @s÷ñ˜dñr
c
ƒó "\'dR#\4GRjxL
pVfR#\;_uu_4GRjxL
\'dRRR4GRjxL
R#VP4;_uu_4GRjxL
pVP R4GRjxL
RRR4GRjxL
RsRRR4GRjxL
R#LhLGL0L" +GRjxL
'giL9;iL. +GRjxL
'giR#;i5i)Nzê
create table if not exists admin_kv (
key text primary key,
value jsonb not null,
updated_at timestamptz not null default now()
);
T)Ú_schema_ensuredr)Ú _schema_lockÚacquireÚexecute)ÚpoolÚconns r Ú_ensure_schemar3@éçƒÙÜ× €DØ ‚|Ùß|Ž|ß ‹?Ø ÷|‰|ð—<<—>—>”> —,ó÷
ð
÷"—>ðˆ÷|‰|ñ óñ
÷"—>—>>ú÷|||üsØDžB=ŸD»B?¼D¿C'Á
DÁCÁDÁC'Á;C Á<C'Á?C ÂC ÂC Â C'Â$CÂ%C'Â+ DÂ6C%Â7DÂ?DÃDÃC'ÃC ÃC'Ã C"
ÃCÃ
C"
ÃC"
ÃC'Ã%DÃ'D Ã-C0Ã.
D Ã9D Ã; Dcó V^8„dQhRRRR/#)rÚkeyrrz
Any | Noner )r
s"r r r Ws÷ñ˜jñr
cƒóÆ"\4GRjxL
pVfR#\4GRjxL
VP4;_uu_4GRjxL
pVPRV4GRjxL
pV'gRRR4GRjxL
R#VR,p\ V\
\ 34'dTuuRRR4GRjxL
#\ V\\34'dVPR4p\P!V4uuRRR4GRjxL
#ELLfL \dRRR4GRjxL
R#i;i +GRjxL
'giR#;i5i)Nz)select value from admin_kv where key = $1Úvaluezutf-8)
r)r3r/ÚfetchrowÚ
isinstanceÚdictÚlistÚbytesÚ bytearrayÚdecodeÚjsonÚloadsr&)r5r1r2ÚrowÚraws& r Úget_kvrCWéÜ× €DØ ‚|ÙÜ
Ó
×ÐØ|‰|~~Œ~ Ø—MMÐ"MÈsÓS×SˆßØ÷~‰~ð'lˆä cœD¤$˜<× ÷~Š~ô cœE¤9Ð —*‘*˜WÓ%ˆCð Ü—:’:˜c“?÷~Š~ò ñÙÙøôô Ø÷~Š~ð ú÷~~‰~üsñE!DE!¨D© E!Á DÁ
E!Á
EÁ#DÁ$ EÁ0EÁ1 E!Á<DÁ=E!Â&EÂ)
E!Â6DÂ7E!Â<-EÃ*D!Ã?
E!Ä DÄ
E!ÄE!ÄE!ÄEÄE!ÄE!ÄE!Ä! EÄ,EÄ- E!Ä8D;Ä9E!ÅEÅEÅE Å
E
Å
E ÅE Å E!có$V^8„dQhRRRRRR/#)rr5rr7rrrr )r
s"r r r ls!÷ñ #ð¨$ñr
cƒót"\4GRjxL
pVfR#\4GRjxL
\P!V4pVP 4;_uu_4GRjxL
pVP RVV4GRjxL
RRR4GRjxL
R#L€LjL5LL +GRjxL
'giR#;i5i)NFzö
insert into admin_kv (key, value, updated_at)
values ($1, $2::jsonb, now())
on conflict (key) do update
set value = excluded.value,