Sha256: 2660615e3a7f60242e7960617cf3c6a8f63c4dcc099e981c11f2c033de045514

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

require 'time'

class RequestScraper

  def initialize(b, navigator)
    @b = b
    @navigator = navigator
  end

  def scrape(id)
    @navigator.goto "hd/ticket/euTicketView.ssp?ticket_id=#{id}&log=show"
    cells = @b.tables[1].tds.to_a
    {
        id: @b.text.match(/Request #(\d+)/)[1],
        title: cells[0].text,
        status: cells[2].text,
        service: cells[3].text,
        request_type: cells[4].text,
        time_spent: cells[6].text,
        priority: cells[7].text,
        deadline: Time.parse(cells[8].text),
        submitted_to: cells[10].text,
        submitted_by: cells[11].text.upcase,
        submitted_on: Time.parse(cells[12].text),
        assigned_to: cells[15].text.upcase,
        assigned_by: cells[16].text,
        assigned_on: Time.parse(cells[17].text),
        department_id: cells[19].text,
        closed_by: cells[20].text,
        closed_on: cells[21].text == 'None' ? 'None' : Time.parse(cells[21].text)
    }.merge scrape_resolved_data_from_audit_log
  end

  private

  def scrape_resolved_data_from_audit_log
    rows = @b.tables[3].trs.to_a
    index = rows.index { |r| r.text =~ /Resolved by/ }
    return {} unless index
    text = rows[index-1].text
    matches = text.match /(.+) by (.+)/
    {
        resolved_on: Time.parse(matches[1]),
        resolved_by: matches[2].upcase
    }
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
help_desk_dashboard-0.0.3 lib/help-desk-dashboard/providers/track-it/2003.10.1/request_scraper.rb
help_desk_dashboard-0.0.2 lib/help-desk-dashboard/providers/track-it/2003.10.1/request_scraper.rb
help_desk_dashboard-0.0.1 lib/help-desk-dashboard/providers/track-it/2003.10.1/request_scraper.rb