fix(training): show progress while building info summary

This commit is contained in:
admin committed 2026-10-29 20:13:54 +02:00
1 parent 61c66def3f
commit 60f41dd675
3 files changed
+18 -3

No files matched your search

+1 -1
View File
@@ -1 +1 @@
0.1.0+73
0.1.0+74
+8 -2
View File
@@ -636,8 +636,14 @@ async def training_info_command(message: Message, state: FSMContext) -> None:
profile = await asyncio.to_thread(get_tone_of_voice, message.from_user.id)
if profile.strip():
notes = await asyncio.to_thread(get_training_notes, message.from_user.id)
await _refresh_training_summary(message.from_user.id, profile, notes)
summary = await asyncio.to_thread(get_training_summary, message.from_user.id)
status = await OperationStatus.start(
message, "⏳ Собираю краткую выжимку…", kind="training"
)
try:
await _refresh_training_summary(message.from_user.id, profile, notes)
summary = await asyncio.to_thread(get_training_summary, message.from_user.id)
finally:
await status.finish(None)
rich_html = training_info_rich_html(summary)
if not rich_html:
await message.answer(
+9
View File
@@ -1204,6 +1204,15 @@ class TrainingSummaryTests(unittest.IsolatedAsyncioTestCase):
send.assert_awaited_once()
self.assertIn("Канал про автоматизацию", send.await_args.args[1])
async def test_info_command_generates_missing_summary(self) -> None:
user_store.save_tone_of_voice(13, "профиль аккаунта", self.db_path)
with patch.object(bot, "create_training_summary", new=AsyncMock(return_value={"about": "про ИИ"})) as gen, \
patch.object(bot, "send_rich_message", new=AsyncMock()) as send:
await bot.training_info_command(cast(Any, self._message(13)), cast(Any, _StubState("training")))
gen.assert_awaited_once()
send.assert_awaited_once()
self.assertIn("про ИИ", send.await_args.args[1])
async def test_info_command_without_data_explains_training(self) -> None:
with patch.object(bot, "send_rich_message", new=AsyncMock()) as send:
await bot.training_info_command(cast(Any, self._message(12)), cast(Any, _StubState("training")))