1.0.0 #253

Merged
edraft merged 262 commits from 1.0.0 into master 2023-03-27 09:30:50 +02:00
3 changed files with 48 additions and 6 deletions
Showing only changes of commit 36fd3c73b9 - Show all commits

View File

@ -0,0 +1,47 @@
from cpl_query.extension import List
from bot_data.model.client import Client
from bot_graphql.abc.filter_abc import FilterABC
class ClientFilter(FilterABC):
def __init__(self):
FilterABC.__init__(self)
self._id = None
self._discord_id = None
self._name = None
self._server = None
def from_dict(self, values: dict):
if "id" in values:
self._id = int(values["id"])
if "discord_id" in values:
self._id = int(values["discord_id"])
if "name" in values:
self._name = values["name"]
if "server" in values:
from bot_graphql.filter.server_filter import ServerFilter
server = ServerFilter()
server.from_dict(values["server"])
self._server = server
def filter(self, query: List[Client]) -> List[Client]:
if self._id is not None:
query = query.where(lambda x: x.client_id == self._id)
if self._discord_id is not None:
query = query.where(lambda x: x.client_id == self._discord_id)
if self._name is not None:
query = query.where(lambda x: self._name.lower() == x.name.lower() or self._name.lower() in x.name.lower())
if self._server is not None:
servers = self._server.filter(query.select(lambda x: x.server)).select(lambda x: x.server_id)
query = query.where(lambda x: x.server.server_id in servers)
return query

View File

@ -18,10 +18,5 @@ input ClientFilter {
id: ID
discord_id: String
name: String
sent_message_count: Int
received_message_count: Int
deleted_message_count: Int
received_command_count: Int
moved_users_count: Int
server: ServerFilter
}

View File

@ -6,7 +6,7 @@ type Server implements TableQuery {
auto_roles: [AutoRole]
auto_role_count: Int
clients: [Client]
clients(filter: ClientFilter, page: Page, sort: Sort): [Client]
client_count: Int
users(filter: UserFilter): [User]