Add the patch that will need to be applied to datanommer

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
Pierre-Yves Chibon 2021-02-17 15:53:27 +01:00
parent aadc463239
commit 55163615c7

View file

@ -121,3 +121,48 @@ Open questions
It looks like the timescaledb folks are involved enough in postgresql itself that It looks like the timescaledb folks are involved enough in postgresql itself that
we think things will work, but we have not had on-hands experience with it. we think things will work, but we have not had on-hands experience with it.
Patch
-----
Here is the patch that needs to be applied to ``datanommer/models/__init__.py``
to get it working with timescaledb's adjusted postgresql model.
::
diff --git a/datanommer.models/datanommer/models/__init__.py b/datanommer.models/datanommer/models/__init__.py
index ada58fa..7780433 100644
--- a/datanommer.models/datanommer/models/__init__.py
+++ b/datanommer.models/datanommer/models/__init__.py
@@ -192,11 +192,11 @@ def add(envelope):
# These two blocks would normally be a simple "obj.users.append(user)" kind
# of statement, but here we drop down out of sqlalchemy's ORM and into the
# sql abstraction in order to gain a little performance boost.
- values = [{'username': username, 'msg': obj.id} for username in usernames]
+ values = [{'username': username, 'msg': obj.id, 'timestamp': timestamp} for username in usernames]
if values:
session.execute(user_assoc_table.insert(), values)
- values = [{'package': package, 'msg': obj.id} for package in packages]
+ values = [{'package': package, 'msg': obj.id, 'timestamp': timestamp} for package in packages]
if values:
session.execute(pack_assoc_table.insert(), values)
@@ -279,14 +279,17 @@ class BaseMessage(object):
source_version=self.source_version,
)
+
user_assoc_table = Table('user_messages', DeclarativeBase.metadata,
Column('username', UnicodeText, ForeignKey('user.name')),
- Column('msg', Integer, ForeignKey('messages.id'))
+ Column('msg', Integer, ForeignKey('messages.id')),
+ Column('timestamp', Integer, ForeignKey('messages.timestamp')),
)
pack_assoc_table = Table('package_messages', DeclarativeBase.metadata,
Column('package', UnicodeText, ForeignKey('package.name')),
Column('msg', Integer, ForeignKey('messages.id'))
+ Column('timestamp', Integer, ForeignKey('messages.timestamp')),
)