code: def finished(finished_status,
               update_interval,
               table,
               status_column,
               edit_at_column):
      
      sql = select([table]).where(
          and_(*[
              status_column >= finished_status,
              edit_at_column >= x_seconds_before_now(update_interval)
          ])
      )
      return sql
docs: Create text sql statement query for sqlalchemy that getting all finished task.
  
      :param finished_status: int, status code that greater or equal than this
          will be considered as finished.
      :param update_interval: int, the record will be updated every x seconds.
  
      :return: sqlalchemy text sql statement.
  
      **中文文档**
  
      状态码大于某个值, 并且, 更新时间在最近一段时间以内.