Class: AirTest::MondayTicketParser

Inherits:
Object
  • Object
show all
Includes:
TicketParser
Defined in:
lib/air_test/monday_ticket_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(config = AirTest.configuration) ⇒ MondayTicketParser

Returns a new instance of MondayTicketParser.



11
12
13
14
15
16
# File 'lib/air_test/monday_ticket_parser.rb', line 11

def initialize(config = AirTest.configuration)
  @api_token = config.monday[:token]
  @board_id = config.monday[:board_id]
  @domain = config.monday[:domain]
  @base_url = "https://api.monday.com/v2"
end

Instance Method Details

#extract_ticket_id(ticket) ⇒ Object



71
72
73
# File 'lib/air_test/monday_ticket_parser.rb', line 71

def extract_ticket_id(ticket)
  ticket["id"] || "No ID"
end

#extract_ticket_title(ticket) ⇒ Object



67
68
69
# File 'lib/air_test/monday_ticket_parser.rb', line 67

def extract_ticket_title(ticket)
  ticket["name"] || "No title"
end

#extract_ticket_url(ticket) ⇒ Object



75
76
77
# File 'lib/air_test/monday_ticket_parser.rb', line 75

def extract_ticket_url(ticket)
  "https://#{@domain}/boards/#{@board_id}/pulses/#{ticket["id"]}"
end

#fetch_tickets(limit: 5) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/air_test/monday_ticket_parser.rb', line 18

def fetch_tickets(limit: 5)
  # First, get all items from the board
  query = "    query {\n      boards(ids: \"\#{@board_id}\") {\n        items_page {\n          items {\n            id\n            name\n            column_values {\n              id\n              text\n              value\n            }\n          }\n        }\n      }\n    }\n  GRAPHQL\n\n  response = make_graphql_request(query)\n  return [] unless response[\"data\"]\n\n  items = response.dig(\"data\", \"boards\", 0, \"items_page\", \"items\") || []\n\n  # Filter for items with \"Not Started\" status\n  not_started_items = items.select do |item|\n    status_column = item[\"column_values\"].find { |cv| cv[\"id\"] == \"project_status\" }\n    status_column && status_column[\"text\"] == \"Not Started\"\n  end\n\n  not_started_items.first(limit)\nend\n"

#parse_ticket_content(item_id) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/air_test/monday_ticket_parser.rb', line 52

def parse_ticket_content(item_id)
  # For Monday, we'll use the item name as feature and create a simple scenario
  # In the future, you could add a description column to Monday and parse it like Notion
  {
    feature: "Feature: #{extract_ticket_title({ "id" => item_id, "name" => "Loading..." })}",
    scenarios: [
      {
        title: "Scenario",
        steps: ["Implement the feature"]
      }
    ],
    meta: { tags: [], priority: "", estimate: nil, assignee: "" }
  }
end