mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-13 00:32:58 -07:00
Log newsletter start time and end time in database
This commit is contained in:
parent
dbe3b492fd
commit
eee759d0d0
2 changed files with 20 additions and 3 deletions
|
@ -648,7 +648,7 @@ def dbcheck():
|
||||||
'CREATE TABLE IF NOT EXISTS newsletter_log (id INTEGER PRIMARY KEY AUTOINCREMENT, timestamp INTEGER, '
|
'CREATE TABLE IF NOT EXISTS newsletter_log (id INTEGER PRIMARY KEY AUTOINCREMENT, timestamp INTEGER, '
|
||||||
'newsletter_id INTEGER, agent_id INTEGER, agent_name TEXT, notify_action TEXT, '
|
'newsletter_id INTEGER, agent_id INTEGER, agent_name TEXT, notify_action TEXT, '
|
||||||
'subject_text TEXT, body_text TEXT, message_text TEXT, start_date TEXT, end_date TEXT, '
|
'subject_text TEXT, body_text TEXT, message_text TEXT, start_date TEXT, end_date TEXT, '
|
||||||
'uuid TEXT UNIQUE, success INTEGER DEFAULT 0)'
|
'start_time INTEGER, end_time INTEGER, uuid TEXT UNIQUE, success INTEGER DEFAULT 0)'
|
||||||
)
|
)
|
||||||
|
|
||||||
# recently_added table :: This table keeps record of recently added items
|
# recently_added table :: This table keeps record of recently added items
|
||||||
|
@ -1477,6 +1477,18 @@ def dbcheck():
|
||||||
'UPDATE notify_log SET success = 1'
|
'UPDATE notify_log SET success = 1'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Upgrade newsletter_log table from earlier versions
|
||||||
|
try:
|
||||||
|
c_db.execute('SELECT start_time FROM newsletter_log')
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
logger.debug(u"Altering database. Updating database table newsletter_log.")
|
||||||
|
c_db.execute(
|
||||||
|
'ALTER TABLE newsletter_log ADD COLUMN start_time INTEGER'
|
||||||
|
)
|
||||||
|
c_db.execute(
|
||||||
|
'ALTER TABLE newsletter_log ADD COLUMN end_time INTEGER'
|
||||||
|
)
|
||||||
|
|
||||||
# Upgrade library_sections table from earlier versions (remove UNIQUE constraint on section_id)
|
# Upgrade library_sections table from earlier versions (remove UNIQUE constraint on section_id)
|
||||||
try:
|
try:
|
||||||
result = c_db.execute('SELECT SQL FROM sqlite_master WHERE type="table" AND name="library_sections"').fetchone()
|
result = c_db.execute('SELECT SQL FROM sqlite_master WHERE type="table" AND name="library_sections"').fetchone()
|
||||||
|
|
|
@ -102,6 +102,8 @@ def notify(newsletter_id=None, notify_action=None, **kwargs):
|
||||||
message=newsletter_agent.message_formatted,
|
message=newsletter_agent.message_formatted,
|
||||||
start_date=newsletter_agent.start_date.format('YYYY-MM-DD'),
|
start_date=newsletter_agent.start_date.format('YYYY-MM-DD'),
|
||||||
end_date=newsletter_agent.end_date.format('YYYY-MM-DD'),
|
end_date=newsletter_agent.end_date.format('YYYY-MM-DD'),
|
||||||
|
start_time=newsletter_agent.start_time,
|
||||||
|
end_time=newsletter_agent.end_time,
|
||||||
newsletter_uuid=newsletter_agent.uuid)
|
newsletter_uuid=newsletter_agent.uuid)
|
||||||
|
|
||||||
# Send the notification
|
# Send the notification
|
||||||
|
@ -112,7 +114,8 @@ def notify(newsletter_id=None, notify_action=None, **kwargs):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def set_notify_state(newsletter, notify_action, subject, body, message, start_date, end_date, newsletter_uuid):
|
def set_notify_state(newsletter, notify_action, subject, body, message,
|
||||||
|
start_date, end_date, start_time, end_time, newsletter_uuid):
|
||||||
|
|
||||||
if newsletter and notify_action:
|
if newsletter and notify_action:
|
||||||
db = database.MonitorDatabase()
|
db = database.MonitorDatabase()
|
||||||
|
@ -128,7 +131,9 @@ def set_notify_state(newsletter, notify_action, subject, body, message, start_da
|
||||||
'body_text': body,
|
'body_text': body,
|
||||||
'message_text': message,
|
'message_text': message,
|
||||||
'start_date': start_date,
|
'start_date': start_date,
|
||||||
'end_date': end_date}
|
'end_date': end_date,
|
||||||
|
'start_time': start_time,
|
||||||
|
'end_time': end_time}
|
||||||
|
|
||||||
db.upsert(table_name='newsletter_log', key_dict=keys, value_dict=values)
|
db.upsert(table_name='newsletter_log', key_dict=keys, value_dict=values)
|
||||||
return db.last_insert_id()
|
return db.last_insert_id()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue