Renommages client/ticket > organisation.issue
This commit is contained in:
parent
518e94bed7
commit
d8c57dca57
|
@ -6,11 +6,11 @@
|
||||||
background-color: cyan;
|
background-color: cyan;
|
||||||
padding: 1px 2px;
|
padding: 1px 2px;
|
||||||
}
|
}
|
||||||
.email_attribute_client {
|
.email_attribute_organisation {
|
||||||
background-color: yellow;
|
background-color: yellow;
|
||||||
padding: 1px 2px;
|
padding: 1px 2px;
|
||||||
}
|
}
|
||||||
.email_attribute_ticket {
|
.email_attribute_issue {
|
||||||
background-color: orange;
|
background-color: orange;
|
||||||
padding: 1px 2px;
|
padding: 1px 2px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,9 @@ class EmailsController < ApplicationController
|
||||||
size: 100,
|
size: 100,
|
||||||
from: 0,
|
from: 0,
|
||||||
aggregations: {
|
aggregations: {
|
||||||
clients: { terms: { field: 'clients.keyword' } },
|
organisations: { terms: { field: 'organisations.keyword' } },
|
||||||
servers: { terms: { field: 'servers.keyword' } },
|
servers: { terms: { field: 'servers.keyword' } },
|
||||||
tickets: { terms: { field: 'tickets.keyword' } }
|
issues: { terms: { field: 'issues.keyword' } }
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@emails = results.results
|
@emails = results.results
|
||||||
|
|
|
@ -18,9 +18,9 @@ class Email
|
||||||
attribute :plain_body
|
attribute :plain_body
|
||||||
attribute :cron, :boolean, default: false
|
attribute :cron, :boolean, default: false
|
||||||
attribute :mailing_list, :boolean, default: false
|
attribute :mailing_list, :boolean, default: false
|
||||||
attribute :clients, default: []
|
attribute :organisations, default: []
|
||||||
attribute :servers, default: []
|
attribute :servers, default: []
|
||||||
attribute :tickets, default: []
|
attribute :issues, default: []
|
||||||
attribute :created_at, :datetime, default: DateTime.now
|
attribute :created_at, :datetime, default: DateTime.now
|
||||||
attribute :updated_at, :datetime, default: DateTime.now
|
attribute :updated_at, :datetime, default: DateTime.now
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,9 @@ class EmailRepository
|
||||||
indexes :message_id, type: 'keyword'
|
indexes :message_id, type: 'keyword'
|
||||||
indexes :cron, type: 'boolean'
|
indexes :cron, type: 'boolean'
|
||||||
indexes :mailing_list, type: 'boolean'
|
indexes :mailing_list, type: 'boolean'
|
||||||
indexes :clients, type: 'keyword'
|
indexes :organisations, type: 'keyword'
|
||||||
indexes :servers, type: 'keyword'
|
indexes :servers, type: 'keyword'
|
||||||
indexes :tickets, type: 'keyword'
|
indexes :issues, type: 'keyword'
|
||||||
indexes :created_at, type: 'date'
|
indexes :created_at, type: 'date'
|
||||||
indexes :updated_at, type: 'date'
|
indexes :updated_at, type: 'date'
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ module EmailAction
|
||||||
email.header_values(header_name)
|
email.header_values(header_name)
|
||||||
}.flatten.uniq
|
}.flatten.uniq
|
||||||
|
|
||||||
email.tickets = values
|
email.issues = values
|
||||||
|
|
||||||
email
|
email
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ module EmailAction
|
||||||
metadata_inputs = metadata_inputs(email)
|
metadata_inputs = metadata_inputs(email)
|
||||||
metadata = metadata_mapping_class.where(input: metadata_inputs).all
|
metadata = metadata_mapping_class.where(input: metadata_inputs).all
|
||||||
|
|
||||||
email.clients = metadata.filter_map(&:organisation).uniq
|
email.organisations = metadata.filter_map(&:organisation).uniq
|
||||||
email.servers = metadata.filter_map(&:server).uniq
|
email.servers = metadata.filter_map(&:server).uniq
|
||||||
|
|
||||||
email
|
email
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
<td><%= email.date %></td>
|
<td><%= email.date %></td>
|
||||||
<td><%= email.subject %></td>
|
<td><%= email.subject %></td>
|
||||||
<td>
|
<td>
|
||||||
<% email.clients.each do |client| %>
|
<% email.organisations.each do |organisation| %>
|
||||||
<span class="email_attribute_client"><%= client %></span>
|
<span class="email_attribute_organisation"><%= organisation %></span>
|
||||||
<% end if email.clients %>
|
<% end if email.organisations %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<% email.servers.each do |server| %>
|
<% email.servers.each do |server| %>
|
||||||
|
|
|
@ -23,12 +23,12 @@
|
||||||
<th>Subject</th>
|
<th>Subject</th>
|
||||||
<td><%= @email.subject %></td>
|
<td><%= @email.subject %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% if @email.clients.present? %>
|
<% if @email.organisations.present? %>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Clients</th>
|
<th>Clients</th>
|
||||||
<td>
|
<td>
|
||||||
<% @email.clients.presence.each do |client| %>
|
<% @email.organisations.presence.each do |organisation| %>
|
||||||
<span class="email_attribute_client"><%= client %></span>
|
<span class="email_attribute_organisation"><%= organisation %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -43,12 +43,12 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @email.tickets.present? %>
|
<% if @email.issues.present? %>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Tickets</th>
|
<th>Issues</th>
|
||||||
<td>
|
<td>
|
||||||
<% @email.tickets.presence.each do |ticket| %>
|
<% @email.issues.presence.each do |issue| %>
|
||||||
<span class="email_attribute_ticket"><%= ticket %></span>
|
<span class="email_attribute_issue"><%= issue %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
class CreateEmails < ActiveRecord::Migration[6.0]
|
|
||||||
def change
|
|
||||||
create_table :emails do |t|
|
|
||||||
t.string :message_id
|
|
||||||
t.string :subject
|
|
||||||
t.datetime :date
|
|
||||||
t.string :to
|
|
||||||
t.string :delivered_to
|
|
||||||
t.string :from
|
|
||||||
t.text :plain_body
|
|
||||||
t.text :raw_headers
|
|
||||||
t.boolean :cron
|
|
||||||
t.boolean :mailing_list
|
|
||||||
t.string :clients
|
|
||||||
t.string :servers
|
|
||||||
t.string :tickets
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -70,9 +70,9 @@ ActiveRecord::Schema.define(version: 2021_01_18_132809) do
|
||||||
t.text "raw_headers"
|
t.text "raw_headers"
|
||||||
t.boolean "cron"
|
t.boolean "cron"
|
||||||
t.boolean "mailing_list"
|
t.boolean "mailing_list"
|
||||||
t.string "clients"
|
t.string "organisations"
|
||||||
t.string "servers"
|
t.string "servers"
|
||||||
t.string "tickets"
|
t.string "issues"
|
||||||
t.datetime "created_at", precision: 6, null: false
|
t.datetime "created_at", precision: 6, null: false
|
||||||
t.datetime "updated_at", precision: 6, null: false
|
t.datetime "updated_at", precision: 6, null: false
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ MIME-Version: 1.0
|
||||||
Content-Type: text/plain; charset=UTF-8
|
Content-Type: text/plain; charset=UTF-8
|
||||||
Content-Transfer-Encoding: 8bit
|
Content-Transfer-Encoding: 8bit
|
||||||
Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST)
|
Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST)
|
||||||
Message-Id: <tickets-single@example.com>
|
Message-Id: <issues-single@example.com>
|
||||||
X-Ticket-Id: 49123
|
X-Ticket-Id: 49123
|
||||||
X-Ticket-Id: 12345
|
X-Ticket-Id: 12345
|
||||||
|
|
|
@ -9,7 +9,7 @@ MIME-Version: 1.0
|
||||||
Content-Type: text/plain; charset=UTF-8
|
Content-Type: text/plain; charset=UTF-8
|
||||||
Content-Transfer-Encoding: 8bit
|
Content-Transfer-Encoding: 8bit
|
||||||
Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST)
|
Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST)
|
||||||
Message-Id: <tickets-single@example.com>
|
Message-Id: <issues-single@example.com>
|
||||||
X-Ticket-Id: 49123
|
X-Ticket-Id: 49123
|
||||||
|
|
||||||
dummy body
|
dummy body
|
|
@ -9,7 +9,7 @@ MIME-Version: 1.0
|
||||||
Content-Type: text/plain; charset=UTF-8
|
Content-Type: text/plain; charset=UTF-8
|
||||||
Content-Transfer-Encoding: 8bit
|
Content-Transfer-Encoding: 8bit
|
||||||
Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST)
|
Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST)
|
||||||
Message-Id: <clients-multiple@example.com>
|
Message-Id: <organisations-multiple@example.com>
|
||||||
X-Client-Id: 42QUUX4567
|
X-Client-Id: 42QUUX4567
|
||||||
X-Client-Id: 75FOOB0123
|
X-Client-Id: 75FOOB0123
|
||||||
|
|
|
@ -9,7 +9,7 @@ MIME-Version: 1.0
|
||||||
Content-Type: text/plain; charset=UTF-8
|
Content-Type: text/plain; charset=UTF-8
|
||||||
Content-Transfer-Encoding: 8bit
|
Content-Transfer-Encoding: 8bit
|
||||||
Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST)
|
Date: Sat, 12 Sep 2020 06:43:02 +0200 (CEST)
|
||||||
Message-Id: <clients-single@example.com>
|
Message-Id: <organisations-single@example.com>
|
||||||
X-Client-Id: 42QUUX4567
|
X-Client-Id: 42QUUX4567
|
||||||
|
|
||||||
dummy body
|
dummy body
|
|
@ -20,38 +20,38 @@ class RuleSetProcessorTest < ActiveSupport::TestCase
|
||||||
assert_not_predicate email, :cron?
|
assert_not_predicate email, :cron?
|
||||||
end
|
end
|
||||||
|
|
||||||
test "single ticket" do
|
test "single issue" do
|
||||||
email = email_from_eml_with_rules("tickets_single.eml")
|
email = email_from_eml_with_rules("issues_single.eml")
|
||||||
|
|
||||||
expected = ["49123"]
|
expected = ["49123"]
|
||||||
actual = email.tickets
|
actual = email.issues
|
||||||
|
|
||||||
assert_equal expected, actual
|
assert_equal expected, actual
|
||||||
end
|
end
|
||||||
|
|
||||||
test "multiple tickets" do
|
test "multiple issues" do
|
||||||
email = email_from_eml_with_rules("tickets_multiple.eml")
|
email = email_from_eml_with_rules("issues_multiple.eml")
|
||||||
|
|
||||||
expected = ["49123", "12345"]
|
expected = ["49123", "12345"]
|
||||||
actual = email.tickets
|
actual = email.issues
|
||||||
|
|
||||||
assert_equal expected, actual
|
assert_equal expected, actual
|
||||||
end
|
end
|
||||||
|
|
||||||
test "single client" do
|
test "single organisation" do
|
||||||
email = email_from_eml_with_rules("clients_single.eml")
|
email = email_from_eml_with_rules("organisations_single.eml")
|
||||||
|
|
||||||
expected = ["quux"]
|
expected = ["quux"]
|
||||||
actual = email.clients
|
actual = email.organisations
|
||||||
|
|
||||||
assert_equal expected, actual
|
assert_equal expected, actual
|
||||||
end
|
end
|
||||||
|
|
||||||
test "multiple clients" do
|
test "multiple organisations" do
|
||||||
email = email_from_eml_with_rules("clients_multiple.eml")
|
email = email_from_eml_with_rules("organisations_multiple.eml")
|
||||||
|
|
||||||
expected = ["quux", "foobar"]
|
expected = ["quux", "foobar"]
|
||||||
actual = email.clients
|
actual = email.organisations
|
||||||
|
|
||||||
assert_equal expected, actual
|
assert_equal expected, actual
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue