DB Fixes
This commit is contained in:
parent
e363ebf5ca
commit
f685c48614
5 changed files with 9 additions and 8 deletions
|
@ -42,7 +42,7 @@ def load_logged_in_user():
|
|||
g.user = None
|
||||
else:
|
||||
try:
|
||||
user = UserQuery.get(user_id)
|
||||
user = UserQuery.get(id=user_id)
|
||||
g.user = user
|
||||
except UserQuery.NotFound:
|
||||
g.user = None
|
||||
|
|
|
@ -41,7 +41,6 @@ def incoming_platform_message_view(platform, path=None):
|
|||
|
||||
return {}
|
||||
|
||||
|
||||
@app.route("/healthz")
|
||||
def healthz():
|
||||
return {}
|
||||
|
|
|
@ -32,7 +32,7 @@ class Query:
|
|||
Allows retrieving object by multiple columns.
|
||||
Raises `NotFound` error if query return no results.
|
||||
"""
|
||||
row = db[cls.tablename].find_one()
|
||||
row = db[cls.tablename].find_one(**kwargs)
|
||||
if not row:
|
||||
raise cls.NotFound
|
||||
return cls.obj(**row)
|
||||
|
@ -109,14 +109,14 @@ class ChannelQuery(Query):
|
|||
|
||||
@classmethod
|
||||
def get(cls, _id):
|
||||
channel = super().get(_id)
|
||||
channel = super().get(id=_id)
|
||||
plugins = ChannelPluginQuery.get_from_channel_id(_id)
|
||||
channel.plugins = {plugin.plugin_id: plugin for plugin in plugins}
|
||||
return channel
|
||||
|
||||
@classmethod
|
||||
def get_by_platform(cls, platform, platform_channel_id):
|
||||
result = cls.tablename.find_one(
|
||||
result = db[cls.tablename].find_one(
|
||||
platform=platform, platform_channel_id=platform_channel_id
|
||||
)
|
||||
if not result:
|
||||
|
@ -154,8 +154,8 @@ class ChannelPluginQuery(Query):
|
|||
|
||||
@classmethod
|
||||
def get_from_channel_id(cls, channel_id):
|
||||
yield from [cls.obj(**row) for row in cls.tablename.find(channel_id=channel_id)]
|
||||
yield from [cls.obj(**row) for row in db[cls.tablename].find(channel_id=channel_id)]
|
||||
|
||||
@classmethod
|
||||
def delete_by_channel(cls, channel_id):
|
||||
cls.tablename.delete(channel_id=channel_id)
|
||||
cls.delete(channel_id=channel_id)
|
||||
|
|
|
@ -82,7 +82,7 @@ class SlackPlatform(Platform):
|
|||
logger.debug("Parsing message", platform=cls.ID, data=data)
|
||||
return Message(
|
||||
id=data["event"].get("thread_ts", data["event"]["ts"]),
|
||||
author=data["event"]["user"],
|
||||
author=data["event"].get("user"),
|
||||
from_bot="bot_id" in data["event"],
|
||||
date=datetime.fromtimestamp(int(float(data["event"]["event_ts"]))),
|
||||
text=data["event"]["text"],
|
||||
|
|
|
@ -8,6 +8,7 @@ import structlog
|
|||
|
||||
from butterrobot.objects import Message
|
||||
|
||||
|
||||
logger = structlog.get_logger(__name__)
|
||||
|
||||
|
||||
|
@ -63,4 +64,5 @@ def get_available_plugins():
|
|||
module=ep.module_name,
|
||||
)
|
||||
|
||||
logger.info("Plugins loaded", plugins=list(plugins.keys()))
|
||||
return plugins
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue