def handle(self, *args, **options):

    count_period = settings.COUNT_PERIOD
    count_start_hour = settings.COUNT_START_HOUR
    count_end_hour = settings.COUNT_END_HOUR
    logger.info("Count rows from " + str(count_start_hour) + " to " + str(count_end_hour) + " every " + str(count_period) + " days")
    
    # Wait to next day to count
    self.wait_to_next_day(count_start_hour)

    while True:
      period_start_time = datetime.datetime.now()

      # Get tables from database
      tables = Table.objects.filter(is_count_rows=True)

      # Count rows of tables one by one
      for table in tables:
        table_name = table.name
        cluster_name = table.cluster.name

        count = self.count_rows(cluster_name, table_name)

        # Insert result into database
        if count == -1:
          logger.info("Count error, will not update the database")
        else:
          table.rows = count
          table.last_update_time = datetime.datetime.now()
          table.save()
          logger.info("Save the new rows " + table.rows + " in database")

        # Continue or pause
        if datetime.datetime.now().hour >= count_end_hour:
          logger.info("Pause and wait to next day to count other tables")
          self.wait_to_next_day(count_start_hour)

      # Sleep for next period
      next_start_time = period_start_time + datetime.timedelta(days=count_period)
      sleep_time = (datetime.datetime.now() - next_start_time).total_seconds()

      logger.info("This period is finished. Sleep " + str(sleep_time) + " seconds for next period")
      time.sleep(sleep_time)
dataset/ETHPy150Open XiaoMi/minos/owl/monitor/management/commands/count_rows.py/Command.handle/swapped operands of `-`