this repo has no description

feat(most-liked): move DB to shared memory, check for post before trying to update likes

+6 -2
+6 -2
feeds/mostliked.py
··· 53 53 """ 54 54 55 55 def __init__(self): 56 - self.db_cnx = apsw.Connection('db/mostliked.db') 56 + self.db_cnx = apsw.Connection('/dev/shm/mostliked.db') 57 57 self.db_cnx.pragma('foreign_keys', True) 58 58 self.db_cnx.pragma('journal_mode', 'WAL') 59 59 self.db_cnx.pragma('wal_autocheckpoint', '0') ··· 76 76 self.logger = logging.getLogger('feeds.mostliked') 77 77 78 78 self.db_writes = queue.Queue() 79 - db_worker = DatabaseWorker('mostliked', 'db/mostliked.db', self.db_writes) 79 + db_worker = DatabaseWorker('mostliked', '/dev/shm/mostliked.db', self.db_writes) 80 80 db_worker.start() 81 81 82 82 def process_commit(self, commit): ··· 105 105 try: 106 106 subject_uri = record['subject']['uri'] 107 107 except KeyError: 108 + return 109 + 110 + subject_exists = self.db_cnx.execute('select 1 from posts where uri = ?', [subject_uri]) 111 + if subject_exists.fetchone() is None: 108 112 return 109 113 110 114 task = (