def save_newest_items(self): """ Get list of item dicts from the newest items by id Includes all acceptable kinds of items (ignores pollopts) Saves items in order of ascending ID – important for parent_id and root_id references """ # Get latest item ids from db and from api max_api_id = self.fetch_max_item_id() max_db_id = Status.get_max_item_id() # If no new data, quit. We don't want to use this function to update items if (max_api_id <= max_db_id): return # Save latest items and update max id save = lambda item_data: self.save_item(item_data, update_max_id=True) self.fetch_items(range(max_db_id + 1, max_api_id), callback=save)
def save_newest_items(self): """ Get list of item dicts from the newest items by id Includes all acceptable kinds of items (ignores pollopts) Saves items in order of ascending ID – important for parent_id and root_id references """ # Get latest item ids from db and from api max_api_id = self.fetch_max_item_id() max_db_id = Status.get_max_item_id() # If no new data, quit. We don't want to use this function to update items if (max_api_id <= max_db_id): return # Save latest items and update max id save = lambda item_data: self.save_item(item_data, update_max_id=True) self.fetch_items(range(max_db_id+1, max_api_id), callback=save)