Fixed naming error #168
This commit is contained in:
parent
84f8690bdf
commit
59fc1e1442
@ -25,8 +25,8 @@ from bot_data.service.seeder_service import SeederService
|
|||||||
from bot_data.service.server_repository_service import ServerRepositoryService
|
from bot_data.service.server_repository_service import ServerRepositoryService
|
||||||
from bot_data.service.statistic_repository_service import StatisticRepositoryService
|
from bot_data.service.statistic_repository_service import StatisticRepositoryService
|
||||||
from bot_data.service.user_joined_server_repository_service import UserJoinedServerRepositoryService
|
from bot_data.service.user_joined_server_repository_service import UserJoinedServerRepositoryService
|
||||||
from bot_data.service.user_joined_voice_channel_repository_service import UserMessageCountPerHourRepositoryService
|
from bot_data.service.user_joined_voice_channel_repository_service import UserJoinedVoiceChannelRepositoryService
|
||||||
from bot_data.service.user_joined_voice_channel_service import UserJoinedVoiceChannelRepositoryService
|
from bot_data.service.user_message_count_per_hour_repository_service import UserMessageCountPerHourRepositoryService
|
||||||
from bot_data.service.user_repository_service import UserRepositoryService
|
from bot_data.service.user_repository_service import UserRepositoryService
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,101 +1,127 @@
|
|||||||
from datetime import datetime
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
from cpl_query.extension import List
|
from cpl_query.extension import List
|
||||||
|
|
||||||
from bot_core.logging.database_logger import DatabaseLogger
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
from bot_data.abc.user_message_count_per_hour_repository_abc import UserMessageCountPerHourRepositoryABC
|
from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC
|
||||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||||
from bot_data.model.user_message_count_per_hour import UserMessageCountPerHour
|
from bot_data.model.user_joined_voice_channel import UserJoinedVoiceChannel
|
||||||
|
|
||||||
|
|
||||||
class UserMessageCountPerHourRepositoryService(UserMessageCountPerHourRepositoryABC):
|
class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryABC):
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
logger: DatabaseLogger,
|
|
||||||
db_context: DatabaseContextABC,
|
|
||||||
users: UserRepositoryABC,
|
|
||||||
):
|
|
||||||
UserMessageCountPerHourRepositoryABC.__init__(self)
|
|
||||||
|
|
||||||
|
def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC, users: UserRepositoryABC):
|
||||||
self._logger = logger
|
self._logger = logger
|
||||||
self._context = db_context
|
self._context = db_context
|
||||||
|
|
||||||
self._users = users
|
self._users = users
|
||||||
|
|
||||||
@staticmethod
|
UserJoinedVoiceChannelRepositoryABC.__init__(self)
|
||||||
def _get_value_from_result(value: any) -> Optional[any]:
|
|
||||||
if isinstance(value, str) and 'NULL' in value:
|
|
||||||
return None
|
|
||||||
|
|
||||||
return value
|
def get_user_joined_voice_channels(self) -> List[UserJoinedVoiceChannel]:
|
||||||
|
joins = List(UserJoinedVoiceChannel)
|
||||||
|
self._logger.trace(__name__, f'Send SQL command: {UserJoinedVoiceChannel.get_select_all_string()}')
|
||||||
|
results = self._context.select(UserJoinedVoiceChannel.get_select_all_string())
|
||||||
|
for result in results:
|
||||||
|
self._logger.trace(__name__, f'Get user-joined-voice-channel with id {result[0]}')
|
||||||
|
joins.append(UserJoinedVoiceChannel(
|
||||||
|
self._users.get_user_by_id(result[1]),
|
||||||
|
result[2],
|
||||||
|
result[3],
|
||||||
|
result[4],
|
||||||
|
result[5],
|
||||||
|
id=result[0]
|
||||||
|
))
|
||||||
|
|
||||||
def _from_result(self, result: tuple) -> UserMessageCountPerHour:
|
return joins
|
||||||
return UserMessageCountPerHour(
|
|
||||||
self._get_value_from_result(result[1]),
|
def get_user_joined_voice_channel_by_id(self, id: int) -> UserJoinedVoiceChannel:
|
||||||
self._get_value_from_result(result[2]),
|
self._logger.trace(__name__, f'Send SQL command: {UserJoinedVoiceChannel.get_select_by_id_string(id)}')
|
||||||
self._get_value_from_result(result[3]),
|
result = self._context.select(UserJoinedVoiceChannel.get_select_by_id_string(id))[0]
|
||||||
self._users.get_user_by_id(self._get_value_from_result(result[4])),
|
return UserJoinedVoiceChannel(
|
||||||
self._get_value_from_result(result[5]),
|
self._users.get_user_by_id(result[1]),
|
||||||
self._get_value_from_result(result[6]),
|
result[2],
|
||||||
id=self._get_value_from_result(result[0])
|
result[3],
|
||||||
|
result[4],
|
||||||
|
result[5],
|
||||||
|
id=result[0]
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_user_message_count_per_hours(self) -> List[UserMessageCountPerHour]:
|
def get_user_joined_voice_channels_by_user_id(self, user_id: int) -> List[UserJoinedVoiceChannel]:
|
||||||
umcphs = List(UserMessageCountPerHour)
|
joins = List(UserJoinedVoiceChannel)
|
||||||
self._logger.trace(__name__, f'Send SQL command: {UserMessageCountPerHour.get_select_all_string()}')
|
self._logger.trace(__name__, f'Send SQL command: {UserJoinedVoiceChannel.get_select_by_user_id_string(user_id)}')
|
||||||
results = self._context.select(UserMessageCountPerHour.get_select_all_string())
|
results = self._context.select(UserJoinedVoiceChannel.get_select_by_user_id_string(user_id))
|
||||||
for result in results:
|
for result in results:
|
||||||
self._logger.trace(__name__, f'Get user message count per hour with id {result[0]}')
|
joins.append(UserJoinedVoiceChannel(
|
||||||
umcphs.append(self._from_result(result))
|
self._users.get_user_by_id(result[1]),
|
||||||
|
result[2],
|
||||||
|
result[3],
|
||||||
|
result[4],
|
||||||
|
result[5],
|
||||||
|
id=result[0]
|
||||||
|
))
|
||||||
|
|
||||||
return umcphs
|
return joins
|
||||||
|
|
||||||
def find_user_message_count_per_hour_by_user_id(self, user_id: int) -> List[Optional[UserMessageCountPerHour]]:
|
def get_active_user_joined_voice_channel_by_user_id(self, user_id: int) -> UserJoinedVoiceChannel:
|
||||||
umcphs = List(UserMessageCountPerHour)
|
self._logger.trace(__name__, f'Send SQL command: {UserJoinedVoiceChannel.get_select_by_user_id_string(user_id)}')
|
||||||
sql = UserMessageCountPerHour.get_select_by_user_id_string(user_id)
|
result = self._context.select(UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id))[0]
|
||||||
self._logger.trace(__name__, f'Send SQL command: {sql}')
|
return UserJoinedVoiceChannel(
|
||||||
results = self._context.select(sql)
|
self._users.get_user_by_id(result[1]),
|
||||||
if results is None or len(results) == 0:
|
result[2],
|
||||||
return umcphs
|
result[3],
|
||||||
|
result[4],
|
||||||
|
result[5],
|
||||||
|
id=result[0]
|
||||||
|
)
|
||||||
|
|
||||||
for result in results:
|
def find_active_user_joined_voice_channel_by_user_id(self, user_id: int) -> Optional[UserJoinedVoiceChannel]:
|
||||||
self._logger.trace(__name__, f'Get user message count per hour with id {result[0]}')
|
self._logger.trace(__name__, f'Send SQL command: {UserJoinedVoiceChannel.get_select_by_user_id_string(user_id)}')
|
||||||
umcphs.append(self._from_result(result))
|
result = self._context.select(UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id))
|
||||||
|
|
||||||
return umcphs
|
|
||||||
|
|
||||||
def get_user_message_count_per_hour_by_user_id_and_date(self, user_id: int, date: datetime) -> \
|
|
||||||
Optional[UserMessageCountPerHour]:
|
|
||||||
sql = UserMessageCountPerHour.get_select_by_user_id_and_date_string(user_id, date)
|
|
||||||
self._logger.trace(__name__, f'Send SQL command: {sql}')
|
|
||||||
result = self._context.select(sql)[0]
|
|
||||||
return self._from_result(result)
|
|
||||||
|
|
||||||
def find_user_message_count_per_hour_by_user_id_and_date(self, user_id: int, date: datetime) -> \
|
|
||||||
Optional[UserMessageCountPerHour]:
|
|
||||||
sql = UserMessageCountPerHour.get_select_by_user_id_and_date_string(user_id, date)
|
|
||||||
self._logger.trace(__name__, f'Send SQL command: {sql}')
|
|
||||||
result = self._context.select(sql)
|
|
||||||
if result is None or len(result) == 0:
|
if result is None or len(result) == 0:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return self._from_result(result[0])
|
result = result[0]
|
||||||
|
|
||||||
def add_user_message_count_per_hour(self, umcph: UserMessageCountPerHour):
|
return UserJoinedVoiceChannel(
|
||||||
self._logger.trace(__name__, f'Send SQL command: {umcph.insert_string}')
|
self._users.get_user_by_id(result[1]),
|
||||||
self._context.cursor.execute(umcph.insert_string)
|
result[2],
|
||||||
|
result[3],
|
||||||
|
result[4],
|
||||||
|
result[5],
|
||||||
|
id=result[0]
|
||||||
|
)
|
||||||
|
|
||||||
def update_user_message_count_per_hour(self, umcph: UserMessageCountPerHour):
|
def find_active_user_joined_voice_channels_by_user_id(self, user_id: int) -> List[Optional[UserJoinedVoiceChannel]]:
|
||||||
self._logger.trace(__name__, f'Send SQL command: {umcph.udpate_string}')
|
self._logger.trace(__name__, f'Send SQL command: {UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id)}')
|
||||||
self._context.cursor.execute(umcph.udpate_string)
|
result = List(UserJoinedVoiceChannel)
|
||||||
|
db_results = self._context.select(UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id))
|
||||||
|
|
||||||
def delete_user_message_count_per_hour(self, umcph: UserMessageCountPerHour):
|
for db_result in db_results:
|
||||||
self._logger.trace(__name__, f'Send SQL command: {umcph.delete_string}')
|
result.append(UserJoinedVoiceChannel(
|
||||||
self._context.cursor.execute(umcph.delete_string)
|
self._users.get_user_by_id(db_result[1]),
|
||||||
|
db_result[2],
|
||||||
|
db_result[3],
|
||||||
|
db_result[4],
|
||||||
|
db_result[5],
|
||||||
|
id=db_result[0]
|
||||||
|
))
|
||||||
|
|
||||||
def delete_user_message_count_per_hour_by_user_id(self, user_id: int):
|
return result
|
||||||
sql = UserMessageCountPerHour.delete_by_user_id_string(user_id)
|
|
||||||
self._logger.trace(__name__, f'Send SQL command: {sql}')
|
def add_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel):
|
||||||
self._context.cursor.execute(sql)
|
self._logger.trace(__name__, f'Send SQL command: {user_joined_voice_channel.insert_string}')
|
||||||
|
self._context.cursor.execute(user_joined_voice_channel.insert_string)
|
||||||
|
|
||||||
|
def update_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel):
|
||||||
|
self._logger.trace(__name__, f'Send SQL command: {user_joined_voice_channel.udpate_string}')
|
||||||
|
self._context.cursor.execute(user_joined_voice_channel.udpate_string)
|
||||||
|
|
||||||
|
def delete_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel):
|
||||||
|
self._logger.trace(__name__, f'Send SQL command: {user_joined_voice_channel.delete_string}')
|
||||||
|
self._context.cursor.execute(user_joined_voice_channel.delete_string)
|
||||||
|
|
||||||
|
def delete_user_joined_voice_channel_by_user_id(self, user_id: int):
|
||||||
|
self._logger.trace(__name__, f'Send SQL command: {UserJoinedVoiceChannel.delete_by_user_id_string}')
|
||||||
|
self._context.cursor.execute(UserJoinedVoiceChannel.delete_by_user_id_string(user_id))
|
||||||
|
@ -1,127 +0,0 @@
|
|||||||
from typing import Optional
|
|
||||||
|
|
||||||
from cpl_core.database.context import DatabaseContextABC
|
|
||||||
from cpl_query.extension import List
|
|
||||||
|
|
||||||
from bot_core.logging.database_logger import DatabaseLogger
|
|
||||||
from bot_data.abc.user_joined_voice_channel_repository_abc import UserJoinedVoiceChannelRepositoryABC
|
|
||||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
|
||||||
from bot_data.model.user_joined_voice_channel import UserJoinedVoiceChannel
|
|
||||||
|
|
||||||
|
|
||||||
class UserJoinedVoiceChannelRepositoryService(UserJoinedVoiceChannelRepositoryABC):
|
|
||||||
|
|
||||||
def __init__(self, logger: DatabaseLogger, db_context: DatabaseContextABC, users: UserRepositoryABC):
|
|
||||||
self._logger = logger
|
|
||||||
self._context = db_context
|
|
||||||
|
|
||||||
self._users = users
|
|
||||||
|
|
||||||
UserJoinedVoiceChannelRepositoryABC.__init__(self)
|
|
||||||
|
|
||||||
def get_user_joined_voice_channels(self) -> List[UserJoinedVoiceChannel]:
|
|
||||||
joins = List(UserJoinedVoiceChannel)
|
|
||||||
self._logger.trace(__name__, f'Send SQL command: {UserJoinedVoiceChannel.get_select_all_string()}')
|
|
||||||
results = self._context.select(UserJoinedVoiceChannel.get_select_all_string())
|
|
||||||
for result in results:
|
|
||||||
self._logger.trace(__name__, f'Get user-joined-voice-channel with id {result[0]}')
|
|
||||||
joins.append(UserJoinedVoiceChannel(
|
|
||||||
self._users.get_user_by_id(result[1]),
|
|
||||||
result[2],
|
|
||||||
result[3],
|
|
||||||
result[4],
|
|
||||||
result[5],
|
|
||||||
id=result[0]
|
|
||||||
))
|
|
||||||
|
|
||||||
return joins
|
|
||||||
|
|
||||||
def get_user_joined_voice_channel_by_id(self, id: int) -> UserJoinedVoiceChannel:
|
|
||||||
self._logger.trace(__name__, f'Send SQL command: {UserJoinedVoiceChannel.get_select_by_id_string(id)}')
|
|
||||||
result = self._context.select(UserJoinedVoiceChannel.get_select_by_id_string(id))[0]
|
|
||||||
return UserJoinedVoiceChannel(
|
|
||||||
self._users.get_user_by_id(result[1]),
|
|
||||||
result[2],
|
|
||||||
result[3],
|
|
||||||
result[4],
|
|
||||||
result[5],
|
|
||||||
id=result[0]
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_user_joined_voice_channels_by_user_id(self, user_id: int) -> List[UserJoinedVoiceChannel]:
|
|
||||||
joins = List(UserJoinedVoiceChannel)
|
|
||||||
self._logger.trace(__name__, f'Send SQL command: {UserJoinedVoiceChannel.get_select_by_user_id_string(user_id)}')
|
|
||||||
results = self._context.select(UserJoinedVoiceChannel.get_select_by_user_id_string(user_id))
|
|
||||||
for result in results:
|
|
||||||
joins.append(UserJoinedVoiceChannel(
|
|
||||||
self._users.get_user_by_id(result[1]),
|
|
||||||
result[2],
|
|
||||||
result[3],
|
|
||||||
result[4],
|
|
||||||
result[5],
|
|
||||||
id=result[0]
|
|
||||||
))
|
|
||||||
|
|
||||||
return joins
|
|
||||||
|
|
||||||
def get_active_user_joined_voice_channel_by_user_id(self, user_id: int) -> UserJoinedVoiceChannel:
|
|
||||||
self._logger.trace(__name__, f'Send SQL command: {UserJoinedVoiceChannel.get_select_by_user_id_string(user_id)}')
|
|
||||||
result = self._context.select(UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id))[0]
|
|
||||||
return UserJoinedVoiceChannel(
|
|
||||||
self._users.get_user_by_id(result[1]),
|
|
||||||
result[2],
|
|
||||||
result[3],
|
|
||||||
result[4],
|
|
||||||
result[5],
|
|
||||||
id=result[0]
|
|
||||||
)
|
|
||||||
|
|
||||||
def find_active_user_joined_voice_channel_by_user_id(self, user_id: int) -> Optional[UserJoinedVoiceChannel]:
|
|
||||||
self._logger.trace(__name__, f'Send SQL command: {UserJoinedVoiceChannel.get_select_by_user_id_string(user_id)}')
|
|
||||||
result = self._context.select(UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id))
|
|
||||||
if result is None or len(result) == 0:
|
|
||||||
return None
|
|
||||||
|
|
||||||
result = result[0]
|
|
||||||
|
|
||||||
return UserJoinedVoiceChannel(
|
|
||||||
self._users.get_user_by_id(result[1]),
|
|
||||||
result[2],
|
|
||||||
result[3],
|
|
||||||
result[4],
|
|
||||||
result[5],
|
|
||||||
id=result[0]
|
|
||||||
)
|
|
||||||
|
|
||||||
def find_active_user_joined_voice_channels_by_user_id(self, user_id: int) -> List[Optional[UserJoinedVoiceChannel]]:
|
|
||||||
self._logger.trace(__name__, f'Send SQL command: {UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id)}')
|
|
||||||
result = List(UserJoinedVoiceChannel)
|
|
||||||
db_results = self._context.select(UserJoinedVoiceChannel.get_select_active_by_user_id_string(user_id))
|
|
||||||
|
|
||||||
for db_result in db_results:
|
|
||||||
result.append(UserJoinedVoiceChannel(
|
|
||||||
self._users.get_user_by_id(db_result[1]),
|
|
||||||
db_result[2],
|
|
||||||
db_result[3],
|
|
||||||
db_result[4],
|
|
||||||
db_result[5],
|
|
||||||
id=db_result[0]
|
|
||||||
))
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def add_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel):
|
|
||||||
self._logger.trace(__name__, f'Send SQL command: {user_joined_voice_channel.insert_string}')
|
|
||||||
self._context.cursor.execute(user_joined_voice_channel.insert_string)
|
|
||||||
|
|
||||||
def update_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel):
|
|
||||||
self._logger.trace(__name__, f'Send SQL command: {user_joined_voice_channel.udpate_string}')
|
|
||||||
self._context.cursor.execute(user_joined_voice_channel.udpate_string)
|
|
||||||
|
|
||||||
def delete_user_joined_voice_channel(self, user_joined_voice_channel: UserJoinedVoiceChannel):
|
|
||||||
self._logger.trace(__name__, f'Send SQL command: {user_joined_voice_channel.delete_string}')
|
|
||||||
self._context.cursor.execute(user_joined_voice_channel.delete_string)
|
|
||||||
|
|
||||||
def delete_user_joined_voice_channel_by_user_id(self, user_id: int):
|
|
||||||
self._logger.trace(__name__, f'Send SQL command: {UserJoinedVoiceChannel.delete_by_user_id_string}')
|
|
||||||
self._context.cursor.execute(UserJoinedVoiceChannel.delete_by_user_id_string(user_id))
|
|
@ -0,0 +1,101 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from cpl_core.database.context import DatabaseContextABC
|
||||||
|
from cpl_query.extension import List
|
||||||
|
|
||||||
|
from bot_core.logging.database_logger import DatabaseLogger
|
||||||
|
from bot_data.abc.user_message_count_per_hour_repository_abc import UserMessageCountPerHourRepositoryABC
|
||||||
|
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||||
|
from bot_data.model.user_message_count_per_hour import UserMessageCountPerHour
|
||||||
|
|
||||||
|
|
||||||
|
class UserMessageCountPerHourRepositoryService(UserMessageCountPerHourRepositoryABC):
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
logger: DatabaseLogger,
|
||||||
|
db_context: DatabaseContextABC,
|
||||||
|
users: UserRepositoryABC,
|
||||||
|
):
|
||||||
|
UserMessageCountPerHourRepositoryABC.__init__(self)
|
||||||
|
|
||||||
|
self._logger = logger
|
||||||
|
self._context = db_context
|
||||||
|
self._users = users
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _get_value_from_result(value: any) -> Optional[any]:
|
||||||
|
if isinstance(value, str) and 'NULL' in value:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return value
|
||||||
|
|
||||||
|
def _from_result(self, result: tuple) -> UserMessageCountPerHour:
|
||||||
|
return UserMessageCountPerHour(
|
||||||
|
self._get_value_from_result(result[1]),
|
||||||
|
self._get_value_from_result(result[2]),
|
||||||
|
self._get_value_from_result(result[3]),
|
||||||
|
self._users.get_user_by_id(self._get_value_from_result(result[4])),
|
||||||
|
self._get_value_from_result(result[5]),
|
||||||
|
self._get_value_from_result(result[6]),
|
||||||
|
id=self._get_value_from_result(result[0])
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_user_message_count_per_hours(self) -> List[UserMessageCountPerHour]:
|
||||||
|
umcphs = List(UserMessageCountPerHour)
|
||||||
|
self._logger.trace(__name__, f'Send SQL command: {UserMessageCountPerHour.get_select_all_string()}')
|
||||||
|
results = self._context.select(UserMessageCountPerHour.get_select_all_string())
|
||||||
|
for result in results:
|
||||||
|
self._logger.trace(__name__, f'Get user message count per hour with id {result[0]}')
|
||||||
|
umcphs.append(self._from_result(result))
|
||||||
|
|
||||||
|
return umcphs
|
||||||
|
|
||||||
|
def find_user_message_count_per_hour_by_user_id(self, user_id: int) -> List[Optional[UserMessageCountPerHour]]:
|
||||||
|
umcphs = List(UserMessageCountPerHour)
|
||||||
|
sql = UserMessageCountPerHour.get_select_by_user_id_string(user_id)
|
||||||
|
self._logger.trace(__name__, f'Send SQL command: {sql}')
|
||||||
|
results = self._context.select(sql)
|
||||||
|
if results is None or len(results) == 0:
|
||||||
|
return umcphs
|
||||||
|
|
||||||
|
for result in results:
|
||||||
|
self._logger.trace(__name__, f'Get user message count per hour with id {result[0]}')
|
||||||
|
umcphs.append(self._from_result(result))
|
||||||
|
|
||||||
|
return umcphs
|
||||||
|
|
||||||
|
def get_user_message_count_per_hour_by_user_id_and_date(self, user_id: int, date: datetime) -> \
|
||||||
|
UserMessageCountPerHour:
|
||||||
|
sql = UserMessageCountPerHour.get_select_by_user_id_and_date_string(user_id, date)
|
||||||
|
self._logger.trace(__name__, f'Send SQL command: {sql}')
|
||||||
|
result = self._context.select(sql)[0]
|
||||||
|
return self._from_result(result)
|
||||||
|
|
||||||
|
def find_user_message_count_per_hour_by_user_id_and_date(self, user_id: int, date: datetime) -> \
|
||||||
|
Optional[UserMessageCountPerHour]:
|
||||||
|
sql = UserMessageCountPerHour.get_select_by_user_id_and_date_string(user_id, date)
|
||||||
|
self._logger.trace(__name__, f'Send SQL command: {sql}')
|
||||||
|
result = self._context.select(sql)
|
||||||
|
if result is None or len(result) == 0:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return self._from_result(result[0])
|
||||||
|
|
||||||
|
def add_user_message_count_per_hour(self, umcph: UserMessageCountPerHour):
|
||||||
|
self._logger.trace(__name__, f'Send SQL command: {umcph.insert_string}')
|
||||||
|
self._context.cursor.execute(umcph.insert_string)
|
||||||
|
|
||||||
|
def update_user_message_count_per_hour(self, umcph: UserMessageCountPerHour):
|
||||||
|
self._logger.trace(__name__, f'Send SQL command: {umcph.udpate_string}')
|
||||||
|
self._context.cursor.execute(umcph.udpate_string)
|
||||||
|
|
||||||
|
def delete_user_message_count_per_hour(self, umcph: UserMessageCountPerHour):
|
||||||
|
self._logger.trace(__name__, f'Send SQL command: {umcph.delete_string}')
|
||||||
|
self._context.cursor.execute(umcph.delete_string)
|
||||||
|
|
||||||
|
def delete_user_message_count_per_hour_by_user_id(self, user_id: int):
|
||||||
|
sql = UserMessageCountPerHour.delete_by_user_id_string(user_id)
|
||||||
|
self._logger.trace(__name__, f'Send SQL command: {sql}')
|
||||||
|
self._context.cursor.execute(sql)
|
Loading…
Reference in New Issue
Block a user