def set_active(self, when=None):
     if when is None:
         when = util.now_utc()
     self.last_active_time = when
     #print "Setting last active time!", self.last_active_time
     with sqlite3.connect(self.db) as c:
         cur = c.cursor()
         cur.execute(
             'update conversations set last_active_time=? where id=?',
             (util.to_ts(self.last_active_time), self.id))
         assert cur.rowcount == 1
 def get_all_reminders(self):
     reminders = []
     with sqlite3.connect(self.db) as c:
         c.row_factory = sqlite3.Row
         cur = c.cursor()
         cur.execute(
             '''select rowid, * from reminders where conv_id=?
                 and reminder_time>=?
                 and deleted=0
                 order by reminder_time''',
             (self.id, util.to_ts(util.now_utc())))
         for row in cur:
             reminders.append(Reminder.from_row(row, self.db))
     return reminders
Esempio n. 3
0
 def snooze_until(self, t):
     assert self.id is not None
     assert t is not None
     self.deleted = False
     self.reminder_time = t
     self.repetition = Repetition(None, None)
     with sqlite3.connect(self.db) as c:
         c.execute(
             'UPDATE reminders SET deleted=0, reminder_time=?, repetition_interval=?, repetition_nth=? WHERE rowid=?',
             (
                 util.to_ts(self.reminder_time),
                 None,
                 None,
                 self.id,
             ))
 def store(self):
     active_ts = util.to_ts(
         self.last_active_time) if self.last_active_time else 0
     #print "storing new conv " + self.channel
     with sqlite3.connect(self.db) as c:
         c.execute(
             '''insert into conversations (
             id,
             channel,
             last_active_time,
             context,
             reminder_rowid,
             debug,
             is_team,
             topic) values (?,?,?,?,?,?,?,?)''',
             (self.id, self.channel, active_ts, self.context,
              self.reminder_id, self.debug, self.is_team, self.topic))