v2 refactor to label-based koans, and add discord

This commit is contained in:
2025-09-04 02:29:48 +10:00
parent fda6847671
commit 89173f1676
10 changed files with 679 additions and 76 deletions

View File

@@ -1,32 +1,31 @@
from data import Registry, RowModel
from data.columns import String, Timestamp, Integer
from data import Registry, RowModel, Table
from data.columns import Bool, Integer, Timestamp, String
from weakref import WeakValueDictionary
class Koan(RowModel):
"""
Schema
======
CREATE TABLE koans(
koanid INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
communityid INTEGER NOT NULL REFERENCES communities ON UPDATE CASCADE ON DELETE CASCADE,
name TEXT NOT NULL,
message TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
_timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
"""
_tablename_ = 'koans'
_cache_ = {}
_cache_ = WeakValueDictionary()
koanid = Integer(primary=True)
communityid = Integer()
name = String()
message = String()
content = String()
deleted_at = Timestamp()
created_by = Integer()
created_at = Timestamp()
_timestamp = Timestamp()
class KoanData(Registry):
VERSION = ('KOANS', 1)
class KoanInfo(Koan):
_tablename_ = 'koans_info'
_readonly_ = True
_cache_ = WeakValueDictionary()
koanlabel = Integer()
is_deleted = Bool()
class KoansData(Registry):
VERSION = ('KOANS', 2)
koans = Koan.table
koans_info = KoanInfo.table