Reworked Markov storage to reduce database size.
CI / Formatting (push) Failing after 38s
CI / Linting (push) Successful in 8s
CI / Tests (push) Successful in 35s
CI / Type Checking (push) Failing after 12s
CI / Spelling (push) Successful in 7s

This commit is contained in:
2026-06-29 12:29:19 -04:00
parent d23c11cf11
commit 1dd9db9151
5 changed files with 934 additions and 73 deletions
+7 -3
View File
@@ -117,13 +117,17 @@ async def simcord_member_channel(
@pytest.fixture
def start_words_for_channel() -> StartWordsForChannel:
"""Return a reader for persisted Markov start words in one Discord channel."""
"""Return persisted Markov start-word occurrences for one Discord channel."""
async def read(db: Database, channel_id: int) -> list[str]:
async with db._connection.execute(
"SELECT word FROM markov_start_words WHERE channel_id = ? ORDER BY word",
"SELECT word, occurrences"
" FROM markov_start_words"
" WHERE channel_id = ?"
" ORDER BY word",
(channel_id,),
) as cursor:
return [str(row[0]) for row in await cursor.fetchall()]
rows = await cursor.fetchall()
return [str(row[0]) for row in rows for _ in range(int(row[1]))]
return read