Compare commits

..

6 Commits

Author SHA1 Message Date
cc520caef5 Merge branch 'master' into dev
Some checks reported errors
continuous-integration/drone/push Build was killed
# Conflicts:
#	drone.yaml
2025-09-26 21:29:27 +03:00
51eebcc165 fix env
All checks were successful
continuous-integration/drone/push Build is passing
2025-09-26 21:20:31 +03:00
ffe5e2e938 update orders list message sending 2025-09-26 21:20:29 +03:00
77a00d7623 clear and fix database modul 2025-09-26 21:19:30 +03:00
369bd7a6e1 Revert "clear database_engine imports"
Some checks reported errors
continuous-integration/drone/push Build was killed
This reverts commit de9c0e6724.
2025-09-26 20:53:36 +03:00
8604774741 fix imports
Some checks failed
continuous-integration/drone/push Build is failing
update search_by_item and show_order
2025-09-26 20:43:02 +03:00
5 changed files with 8 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ from aiogram.fsm.state import State, StatesGroup
class SearchForm(StatesGroup): class SearchForm(StatesGroup):
search_option = State() search_option = State()
data_to_search = State() data_to_search = State()
sent_messages = State()
search_result = State() search_result = State()

View File

@@ -1,8 +1,8 @@
import os import os
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine, session
DATABASE_URL = (f"postgresql+asyncpg://{os.getenv('DB_USER')}:{os.getenv('DB_PASSWORD')}@" DATABASE_URL = (f"postgresql+asyncpg://{os.getenv('DB_USER')}:{os.getenv('DB_PASSWORD')}@"
f"{os.getenv('DB_HOST')}/{os.getenv('DATABASE')}") f"{os.getenv('DB_HOST')}/{os.getenv('DATABASE')}")
engine = create_async_engine(DATABASE_URL, echo=True) engine = create_async_engine(DATABASE_URL, echo=True)
async_session_ = async_sessionmaker(bind=engine, expire_on_commit=False) async_session_ = async_sessionmaker(bind=engine, expire_on_commit=False)

View File

@@ -132,14 +132,6 @@ async def search_by_item(message: Message, state: FSMContext):
async def show_order(callback: CallbackQuery, state: FSMContext, bot: Bot): async def show_order(callback: CallbackQuery, state: FSMContext, bot: Bot):
order_id = int(re.search(r"(\d+)", callback.data).group()) order_id = int(re.search(r"(\d+)", callback.data).group())
try:
async with async_session_() as local_session:
result = await local_session.execute(select(Order).filter(Order.id == order_id))
order = result.scalars().first()
except Exception as err:
logger.warning(err)
order = next(filter(lambda item: order_id == item.id, await state.get_value("search_result")), None) order = next(filter(lambda item: order_id == item.id, await state.get_value("search_result")), None)
if order: if order:
@@ -154,7 +146,7 @@ async def show_order(callback: CallbackQuery, state: FSMContext, bot: Bot):
(f"{clbk}_{order.id}", text) for clbk, text in order_operation_base.items())) (f"{clbk}_{order.id}", text) for clbk, text in order_operation_base.items()))
) )
for message in SearchForm.sent_messages: for message in await state.get_value("sent_messages"):
await bot.delete_message(chat_id=callback.message.chat.id, message_id=message.message_id) await bot.delete_message(chat_id=callback.message.chat.id, message_id=message.message_id)
await state.clear() await state.clear()

View File

@@ -1,12 +1,14 @@
import os import os
import asyncio import asyncio
from dotenv import load_dotenv from dotenv import load_dotenv
load_dotenv(".env")
from aiogram import Dispatcher, Bot from aiogram import Dispatcher, Bot
from handlers import * from handlers import *
from keyboards import set_main_menu from keyboards import set_main_menu
from middlewares import SessionMiddleware from middlewares import SessionMiddleware
load_dotenv(".env")
bot = Bot(token=os.getenv("TOKEN")) bot = Bot(token=os.getenv("TOKEN"))

View File

@@ -42,8 +42,7 @@ steps:
commands: commands:
- docker stop myapp || true - docker stop myapp || true
- docker rm myapp || true - docker rm myapp || true
- docker run --name=myapp --network=prod_net -v /srv/prod/telegram_bot/photos:/app/photos/ \ - docker run --name=myapp --network=prod_net -v /srv/prod/telegram_bot/photos:/app/photos/ -v /srv/prod/telegram_bot/.env:/app/.env:ro myapp:${DRONE_COMMIT_BRANCH}
-v /srv/prod/telegram_bot/.env:/app/.env:ro myapp:${DRONE_COMMIT_BRANCH}
volumes: volumes: