src/dirbs/listgen/generator.py
def _store_blacklist_delta(self, executor):
        """Job to update the blacklist from the computed delta table."""
        per_type_counts = {}
        with create_db_connection(self._config.db_config) as conn, conn.cursor() as cursor, CodeProfiler() as cp:
            tbl = sql.Identifier(self._blacklist_tblname)
            delta_tbl = sql.Identifier(self._blacklist_delta_tblname)
            # We set the end_run_id on any current row where we have a change in the delta table
            cursor.execute(sql.SQL("""UPDATE {tbl} bl
                                         SET end_run_id = %s
                                       WHERE end_run_id IS NULL
                                         AND EXISTS (SELECT 1
                                                       FROM {delta_tbl}
                                                      WHERE imei_norm = bl.imei_norm)
                                   """).format(tbl=tbl, delta_tbl=delta_tbl),
                           [self._run_id])
            per_type_counts['invalidated'] = cursor.rowcount
            # Now we should be able to just insert the delta list into the blacklist
            cursor.execute(sql.SQL("""INSERT INTO {tbl}(imei_norm,
                                                        virt_imei_shard,
                                                        block_date,
                                                        reasons,
                                                        start_run_id,
                                                        end_run_id,
                                                        delta_reason)
                                           SELECT imei_norm,
                                                  virt_imei_shard,
                                                  block_date,
                                                  reasons,
                                                  start_run_id,
                                                  end_run_id,
                                                  delta_reason
                                             FROM {delta_tbl}
                                   """).format(tbl=tbl, delta_tbl=delta_tbl),
                           [self._run_id])
            per_type_counts['new'] = cursor.rowcount
            self._analyze_helper(cursor, self._blacklist_tblname)

        return per_type_counts, cp.duration
Job to update the blacklist from the computed delta table.
Job to update the blacklist from the computed delta table.
Job to update the blacklist from the computed delta table .
def _store_blacklist_delta(self, executor):
        per_type_counts = {}
        with create_db_connection(self._config.db_config) as conn, conn.cursor() as cursor, CodeProfiler() as cp:
            tbl = sql.Identifier(self._blacklist_tblname)
            delta_tbl = sql.Identifier(self._blacklist_delta_tblname)
            cursor.execute(sql.SQL("""UPDATE {tbl} bl
                                         SET end_run_id = %s
                                       WHERE end_run_id IS NULL
                                         AND EXISTS (SELECT 1
                                                       FROM {delta_tbl}
                                                      WHERE imei_norm = bl.imei_norm)
                                   """).format(tbl=tbl, delta_tbl=delta_tbl),
                           [self._run_id])
            per_type_counts['invalidated'] = cursor.rowcount
            cursor.execute(sql.SQL("""INSERT INTO {tbl}(imei_norm,
                                                        virt_imei_shard,
                                                        block_date,
                                                        reasons,
                                                        start_run_id,
                                                        end_run_id,
                                                        delta_reason)
                                           SELECT imei_norm,
                                                  virt_imei_shard,
                                                  block_date,
                                                  reasons,
                                                  start_run_id,
                                                  end_run_id,
                                                  delta_reason
                                             FROM {delta_tbl}
                                   """).format(tbl=tbl, delta_tbl=delta_tbl),
                           [self._run_id])
            per_type_counts['new'] = cursor.rowcount
            self._analyze_helper(cursor, self._blacklist_tblname)
        return per_type_counts, cp.duration
def _store_blacklist_delta ( self , executor ) : per_type_counts = { } with create_db_connection ( self . _config . db_config ) as conn , conn . cursor ( ) as cursor , CodeProfiler ( ) as cp : tbl = sql . Identifier ( self . _blacklist_tblname ) delta_tbl = sql . Identifier ( self . _blacklist_delta_tblname ) cursor . execute ( sql . SQL ( """UPDATE {tbl} bl
                                         SET end_run_id = %s
                                       WHERE end_run_id IS NULL
                                         AND EXISTS (SELECT 1
                                                       FROM {delta_tbl}
                                                      WHERE imei_norm = bl.imei_norm)
                                   """ ) . format ( tbl = tbl , delta_tbl = delta_tbl ) , [ self . _run_id ] ) per_type_counts [ 'invalidated' ] = cursor . rowcount cursor . execute ( sql . SQL ( """INSERT INTO {tbl}(imei_norm,
                                                        virt_imei_shard,
                                                        block_date,
                                                        reasons,
                                                        start_run_id,
                                                        end_run_id,
                                                        delta_reason)
                                           SELECT imei_norm,
                                                  virt_imei_shard,
                                                  block_date,
                                                  reasons,
                                                  start_run_id,
                                                  end_run_id,
                                                  delta_reason
                                             FROM {delta_tbl}
                                   """ ) . format ( tbl = tbl , delta_tbl = delta_tbl ) , [ self . _run_id ] ) per_type_counts [ 'new' ] = cursor . rowcount self . _analyze_helper ( cursor , self . _blacklist_tblname ) return per_type_counts , cp . duration
Job to update the blacklist from the computed delta table.
Job to update the blacklist from the computed delta table .
"""Job to update the blacklist from the computed delta table.""" # We set the end_run_id on any current row where we have a change in the delta table # Now we should be able to just insert the delta list into the blacklist
self
executor