fix lint - type mismatch (#2117)
* fix lint * empty commit to trigger ci flow
This commit is contained in:
parent
7835365c92
commit
7ebaf2914c
2 changed files with 14 additions and 5 deletions
|
|
@ -16,7 +16,7 @@ from collections import OrderedDict, namedtuple
|
||||||
from http.cookies import SimpleCookie
|
from http.cookies import SimpleCookie
|
||||||
|
|
||||||
ParsedArgs = namedtuple(
|
ParsedArgs = namedtuple(
|
||||||
"ParsedContext",
|
"ParsedArgs",
|
||||||
[
|
[
|
||||||
"command",
|
"command",
|
||||||
"url",
|
"url",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import TYPE_CHECKING, Optional, Union
|
from typing import TYPE_CHECKING, Optional, Union, List
|
||||||
|
|
||||||
import duckdb
|
import duckdb
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
@ -109,12 +109,21 @@ class MonitorService(Service):
|
||||||
|
|
||||||
return self.exec_query(query)
|
return self.exec_query(query)
|
||||||
|
|
||||||
def delete_messages(self, message_ids: list[int]):
|
def delete_messages(self, message_ids: Union[List[int], str]):
|
||||||
query = f"DELETE FROM messages WHERE index IN ({','.join(map(str, message_ids))})"
|
if isinstance(message_ids, list):
|
||||||
|
# If message_ids is a list, join the string representations of the integers
|
||||||
|
ids_str = ','.join(map(str, message_ids))
|
||||||
|
elif isinstance(message_ids, str):
|
||||||
|
# If message_ids is already a string, use it directly
|
||||||
|
ids_str = message_ids
|
||||||
|
else:
|
||||||
|
raise ValueError("message_ids must be a list of integers or a string")
|
||||||
|
|
||||||
|
query = f"DELETE FROM messages WHERE index IN ({ids_str})"
|
||||||
|
|
||||||
return self.exec_query(query)
|
return self.exec_query(query)
|
||||||
|
|
||||||
def update_message(self, message_id: int, **kwargs):
|
def update_message(self, message_id: str, **kwargs):
|
||||||
query = (
|
query = (
|
||||||
f"""UPDATE messages SET {', '.join(f"{k} = '{v}'" for k, v in kwargs.items())} WHERE index = {message_id}"""
|
f"""UPDATE messages SET {', '.join(f"{k} = '{v}'" for k, v in kwargs.items())} WHERE index = {message_id}"""
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue