def dataset_older_than_database(self, dataset_id,
                                    disk_datetime_processed,
                                    tile_class_filter=None):
        sql_dtp = ("SELECT datetime_processed FROM dataset\n" +
                   "WHERE dataset_id = %s;")
        result = self.execute_sql_single(sql_dtp, (dataset_id,))
        database_datetime_processed = result[0]

        if database_datetime_processed < disk_datetime_processed:
            return None

        # The database's dataset record is newer that what is on disk.
        # Consider whether the tile record's are older than dataset on disk.
        # Make the dataset's datetime_processed timezone-aware.
        utc = pytz.timezone("UTC")
        disk_datetime_processed = utc.localize(disk_datetime_processed)

        sql_ctime = ("SELECT MIN(ctime) FROM tile\n" +
                     "WHERE dataset_id = %(dataset_id)s\n" +
                     ("AND tile_class_id IN %(tile_class_filter)s\n" if
                      tile_class_filter else "") +
                     ";"
                     )
        params = {'dataset_id': dataset_id,
                  'tile_class_filter': tuple(tile_class_filter)
                  }
        result = self.execute_sql_single(sql_ctime, params)
        min_ctime = result[0]

        if min_ctime is None:
            return None

        if min_ctime < disk_datetime_processed:
            return None

        # The dataset on disk is more recent than the database records and
        # should be re-ingested. Return tuple containing relevant times
        return (disk_datetime_processed, utc.localize(database_datetime_processed), min_ctime)
Compares the datetime_processed of the dataset on disk with that on
dataset/ETHPy150Open GeoscienceAustralia/agdc/src/abstract_ingester/ingest_db_wrapper.py/IngestDBWrapper.dataset_older_than_database