def remove_old_dashboard_data(self):
    last_cursor = None
    last_model = None

    # If we have state information beyond what function to use,
    # load the last seen model and cursor if available.
    if (len(self.groomer_state) > 1 and
      self.groomer_state[0] == self.CLEAN_DASHBOARD_TASK):
      last_model = self.DASHBOARD_DATA_MODELS[int(self.groomer_state[1])]
      if len(self.groomer_state) > 2:
        last_cursor = Cursor(self.groomer_state[2])

    self.register_db_accessor(constants.DASHBOARD_APP_ID)
    timeout = datetime.datetime.utcnow() - \
      datetime.timedelta(seconds=self.DASHBOARD_DATA_TIMEOUT)
    for model_number in range(len(self.DASHBOARD_DATA_MODELS)):
      model_type = self.DASHBOARD_DATA_MODELS[model_number]
      if last_model and model_type != last_model:
        continue
      counter = 0
      while True:
        query = model_type.query().filter(model_type.timestamp < timeout)
        entities, next_cursor, more = query.fetch_page(self.BATCH_SIZE,
          start_cursor=last_cursor)
        for entity in entities:
          entity.key.delete()
          counter += 1
        if time.time() > self.last_logged + self.LOG_PROGRESS_FREQUENCY:
          logging.info('Removed {} {} entities.'
            .format(counter, model_type.__class__.__name__))
          self.last_logged = time.time()
        if more:
          last_cursor = next_cursor
          self.update_groomer_state([self.CLEAN_DASHBOARD_TASK,
            str(model_number), last_cursor.urlsafe()])
        else:
          break
      if model_number != len(self.DASHBOARD_DATA_MODELS) - 1:
        self.update_groomer_state([self.CLEAN_DASHBOARD_TASK,
          str(model_number + 1)])
        last_model = None
        last_cursor = None
      if counter > 0:
        logging.info("Removed {0} {1} dashboard entities".format(counter,
          model_type))

      # Do a scan of all entities and remove any that
      # do not have timestamps for AppScale versions 2.3 and before. 
      # This may take some time on the initial run, but subsequent runs should
      # be quick given a low dashboard data timeout.
      self.remove_deprecated_dashboard_data(model_type)
    return
Removes old statistics from the AppScale dashboard application.
dataset/ETHPy150Open AppScale/appscale/AppDB/groomer.py/DatastoreGroomer.remove_old_dashboard_data