Исправлены критические ошибки
Этот коммит содержится в:
родитель
e6a39b98bd
Коммит
65d48f2826
@ -29,7 +29,7 @@ class Users:
|
||||
async with connection.cursor() as cursor:
|
||||
sql = '''
|
||||
insert into users (
|
||||
telegram_id,
|
||||
telegram_user_id,
|
||||
first_name,
|
||||
last_name,
|
||||
username
|
||||
@ -38,7 +38,7 @@ class Users:
|
||||
%(first_name)s,
|
||||
%(last_name)s,
|
||||
%(username)s
|
||||
) on conflict (telegram_id) do update set
|
||||
) on conflict (telegram_user_id) do update set
|
||||
first_name = excluded.first_name,
|
||||
last_name = excluded.last_name,
|
||||
username = excluded.username
|
||||
@ -116,7 +116,7 @@ class PollOptions:
|
||||
where
|
||||
poll_options.poll_schema_id = %(poll_schema_id)s
|
||||
and poll_options.ordinal is not null;
|
||||
''' if ordinals is not None else '''
|
||||
''' if ordinals is None else '''
|
||||
select
|
||||
poll_options.id,
|
||||
poll_options.name,
|
||||
@ -138,6 +138,7 @@ class PollOptions:
|
||||
return [
|
||||
models.PollOption(
|
||||
id=poll_option_id,
|
||||
poll_schema=poll_schema,
|
||||
name=name,
|
||||
ordinal=ordinal,
|
||||
)
|
||||
@ -159,13 +160,12 @@ class Polls:
|
||||
poll_schemas.id,
|
||||
poll_schemas.name,
|
||||
poll_schemas.question,
|
||||
poll_schemas.options,
|
||||
polls.created_at,
|
||||
polls.is_active
|
||||
polls.is_complete
|
||||
from
|
||||
polls
|
||||
inner join poll_schemas on
|
||||
polls.schema_id = poll_schemas.id;
|
||||
polls.poll_schema_id = poll_schemas.id;
|
||||
'''
|
||||
await cursor.execute(sql)
|
||||
records = await cursor.fetchall()
|
||||
@ -178,12 +178,11 @@ class Polls:
|
||||
id=poll_schema_id,
|
||||
name=name,
|
||||
question=question,
|
||||
options=options,
|
||||
),
|
||||
created_at=created_at,
|
||||
is_active=is_active,
|
||||
is_complete=is_complete,
|
||||
)
|
||||
for poll_id, telegram_message_id, telegram_poll_id, poll_schema_id, name, question, options, created_at, is_active
|
||||
for poll_id, telegram_message_id, telegram_poll_id, poll_schema_id, name, question, created_at, is_complete
|
||||
in records
|
||||
]
|
||||
|
||||
@ -199,7 +198,7 @@ class Polls:
|
||||
insert into polls (
|
||||
telegram_message_id,
|
||||
telegram_poll_id,
|
||||
poll_schema
|
||||
poll_schema_id
|
||||
) values (
|
||||
%(telegram_message_id)s,
|
||||
%(telegram_poll_id)s,
|
||||
@ -207,18 +206,18 @@ class Polls:
|
||||
) returning
|
||||
polls.id,
|
||||
polls.created_at,
|
||||
polls.is_active;
|
||||
polls.is_complete;
|
||||
'''
|
||||
await cursor.execute(
|
||||
sql,
|
||||
{
|
||||
'telegram_message_id': telegram_message_id,
|
||||
'telegram_poll_id': telegram_poll_id,
|
||||
'poll_schema': poll_schema.id,
|
||||
'poll_schema_id': poll_schema.id,
|
||||
},
|
||||
)
|
||||
try:
|
||||
poll_id, created_at, is_active = await cursor.fetchone()
|
||||
poll_id, created_at, is_complete = await cursor.fetchone()
|
||||
except TypeError:
|
||||
raise NotFoundError()
|
||||
return models.Poll(
|
||||
@ -227,7 +226,7 @@ class Polls:
|
||||
telegram_poll_id=telegram_poll_id,
|
||||
poll_schema=poll_schema,
|
||||
created_at=created_at,
|
||||
is_active=is_active,
|
||||
is_complete=is_complete,
|
||||
)
|
||||
|
||||
|
||||
@ -264,6 +263,7 @@ class PollAnswers:
|
||||
for poll_option
|
||||
in poll_options
|
||||
],
|
||||
returning=True,
|
||||
)
|
||||
records = await cursor.fetchall()
|
||||
return [
|
||||
|
@ -1,4 +1,5 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
@ -9,8 +10,8 @@ class User(BaseModel):
|
||||
exclude=True,
|
||||
)
|
||||
first_name: str
|
||||
last_name: str
|
||||
username: str
|
||||
last_name: Optional[str]
|
||||
username: Optional[str]
|
||||
|
||||
|
||||
class PollSchema(BaseModel):
|
||||
@ -23,7 +24,7 @@ class PollOption(BaseModel):
|
||||
id: int
|
||||
poll_schema: PollSchema
|
||||
name: str
|
||||
ordinal: int
|
||||
ordinal: Optional[int]
|
||||
|
||||
|
||||
class Poll(BaseModel):
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user