def crawl_status
      first_status = crawl_statuses.first
      screenshots = []
      if first_status
        screenshots = UiChanged::Screenshot.where("created_at > ?", first_status.time).order("id desc").limit(50).reverse
      end

      job = job_running
      if job != nil
        job_running_status = job.status
        if job.name && job.name.include?("Control")
          job_running_type = "control"
        elsif job.name &&job.name.include?("Test")
          job_running_type = "test"
        elsif job.name
          job_running_type = "compare"
        end
      end

      diff_count = UiChanged::Screenshot.not_in_ignored.where(:diff_found => true).count
      control_count = UiChanged::Screenshot.not_in_ignored.where(:is_control => true).count
      test_count = UiChanged::Screenshot.not_in_ignored.where(:is_test => true).count
      compare_count = UiChanged::Screenshot.not_in_ignored.where(:is_compare => true).count

      render :json => [{
        :screenshots => screenshots,
        :counts => {
          :diff => diff_count,
          :control => control_count,
          :test => test_count,
          :compare => compare_count,
        },
        :worker => {
          :running_status => job_running_status,
          :running_type => job_running_type,
          :first_status => first_status ? first_status.status : ""
        }
      }]
    end
def crawl_status
      first_status = crawl_statuses.first
      screenshots = []
      if first_status
        screenshots = UiChanged::Screenshot.where("created_at > ?", first_status.time).order("id desc").limit(50).reverse
      end

      job = job_running
      if job != nil
        job_running_status = job.status
        if job.name && job.name.include?("Control")
          job_running_type = "control"
        elsif job.name &&job.name.include?("Test")
          job_running_type = "test"
        elsif job.name
          job_running_type = "compare"
        end
      end

      diff_count = UiChanged::Screenshot.not_in_ignored.where(:diff_found => true).count
      control_count = UiChanged::Screenshot.not_in_ignored.where(:is_control => true).count
      test_count = UiChanged::Screenshot.not_in_ignored.where(:is_test => true).count
      compare_count = UiChanged::Screenshot.not_in_ignored.where(:is_compare => true).count

      render :json => [{
        :screenshots => screenshots,
        :counts => {
          :diff => diff_count,
          :control => control_count,
          :test => test_count,
          :compare => compare_count,
        },
        :worker => {
          :running_status => job_running_status,
          :running_type => job_running_type,
          :first_status => first_status ? first_status.status : ""
        }
      }]
    end
GET /screenshots/crawl_status.json