Improve filtering, add "move facts"
This commit is contained in:
@ -92,6 +92,22 @@ class Activity(BaseORM):
|
||||
self.category_name = category_name
|
||||
self.facts_count = facts_count
|
||||
|
||||
def move_facts(self, to_activity):
|
||||
cursor = self.db_manager.get_cursor()
|
||||
|
||||
print(f"moving from {self.id} to {to_activity.id}")
|
||||
|
||||
cursor.execute("""
|
||||
UPDATE
|
||||
facts
|
||||
SET
|
||||
activity_id = ?
|
||||
WHERE
|
||||
activity_id = ?
|
||||
""", (to_activity.id, self.id))
|
||||
|
||||
self.conn.commit()
|
||||
|
||||
@staticmethod
|
||||
def list_activities(db_manager, filter_query=None):
|
||||
cursor = db_manager.get_cursor()
|
||||
@ -121,7 +137,7 @@ class Activity(BaseORM):
|
||||
"""
|
||||
|
||||
if filter_query is not None:
|
||||
cursor.execute(sql, ("%{}%".format(filter_query),) * 2 )
|
||||
cursor.execute(sql, ("%{}%".format(filter_query),) * 2)
|
||||
else:
|
||||
cursor.execute(sql)
|
||||
|
||||
|
Reference in New Issue
Block a user