

def _update_revision_txn(self, txn, user_id, room_id, next_id):
    'Update the latest revision of the tags for the given user and room.\n\n        Args:\n            txn: The database cursor\n            user_id(str): The ID of the user.\n            room_id(str): The ID of the room.\n            next_id(int): The the revision to advance to.\n        '
    txn.call_after(self._account_data_stream_cache.entity_has_changed, user_id, next_id)
    update_max_id_sql = 'UPDATE account_data_max_stream_id SET stream_id = ? WHERE stream_id < ?'
    txn.execute(update_max_id_sql, (next_id, next_id))
    update_sql = 'UPDATE room_tags_revisions SET stream_id = ? WHERE user_id = ? AND room_id = ?'
    txn.execute(update_sql, (next_id, user_id, room_id))
    if (txn.rowcount == 0):
        insert_sql = 'INSERT INTO room_tags_revisions (user_id, room_id, stream_id) VALUES (?, ?, ?)'
        try:
            txn.execute(insert_sql, (user_id, room_id, next_id))
        except self.database_engine.module.IntegrityError:
            pass

dataset/ETHPy150Open matrix-org/synapse/synapse/storage/tags.py TagsStore._update_revision_txn/original