Renommages client/ticket > organisation.issue
This commit is contained in:
parent
518e94bed7
commit
d8c57dca57
|
@ -6,11 +6,11 @@
|
|||
background-color: cyan;
|
||||
padding: 1px 2px;
|
||||
}
|
||||
.email_attribute_client {
|
||||
.email_attribute_organisation {
|
||||
background-color: yellow;
|
||||
padding: 1px 2px;
|
||||
}
|
||||
.email_attribute_ticket {
|
||||
.email_attribute_issue {
|
||||
background-color: orange;
|
||||
padding: 1px 2px;
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@ class EmailsController < ApplicationController
|
|||
size: 100,
|
||||
from: 0,
|
||||
aggregations: {
|
||||
clients: { terms: { field: 'clients.keyword' } },
|
||||
organisations: { terms: { field: 'organisations.keyword' } },
|
||||
servers: { terms: { field: 'servers.keyword' } },
|
||||
tickets: { terms: { field: 'tickets.keyword' } }
|
||||
issues: { terms: { field: 'issues.keyword' } }
|
||||
},
|
||||
})
|
||||
@emails = results.results
|
||||
|
|
|
@ -18,9 +18,9 @@ class Email
|
|||
attribute :plain_body
|
||||
attribute :cron, :boolean, default: false
|
||||
attribute :mailing_list, :boolean, default: false
|
||||
attribute :clients, default: []
|
||||
attribute :organisations, default: []
|
||||
attribute :servers, default: []
|
||||
attribute :tickets, default: []
|
||||
attribute :issues, default: []
|
||||
attribute :created_at, :datetime, default: DateTime.now
|
||||
attribute :updated_at, :datetime, default: DateTime.now
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ class EmailRepository
|
|||
indexes :message_id, type: 'keyword'
|
||||
indexes :cron, type: 'boolean'
|
||||
indexes :mailing_list, type: 'boolean'
|
||||
indexes :clients, type: 'keyword'
|
||||
indexes :organisations, type: 'keyword'
|
||||
indexes :servers, type: 'keyword'
|
||||
indexes :tickets, type: 'keyword'
|
||||
indexes :issues, type: 'keyword'
|
||||
indexes :created_at, type: 'date'
|
||||
indexes :updated_at, type: 'date'
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ module EmailAction
|
|||
email.header_values(header_name)
|
||||
}.flatten.uniq
|
||||
|
||||
email.tickets = values
|
||||
email.issues = values
|
||||
|
||||
email
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ module EmailAction
|
|||
metadata_inputs = metadata_inputs(email)
|
||||
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
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
<td><%= email.date %></td>
|
||||
<td><%= email.subject %></td>
|
||||
<td>
|
||||
<% email.clients.each do |client| %>
|
||||
<span class="email_attribute_client"><%= client %></span>
|
||||
<% end if email.clients %>
|
||||
<% email.organisations.each do |organisation| %>
|
||||
<span class="email_attribute_organisation"><%= organisation %></span>
|
||||
<% end if email.organisations %>
|
||||
</td>
|
||||
<td>
|
||||
<% email.servers.each do |server| %>
|
||||
|
|
|
@ -23,12 +23,12 @@
|
|||
<th>Subject</th>
|
||||
<td><%= @email.subject %></td>
|
||||
</tr>
|
||||
<% if @email.clients.present? %>
|
||||
<% if @email.organisations.present? %>
|
||||
<tr>
|
||||
<th>Clients</th>
|
||||
<td>
|
||||
<% @email.clients.presence.each do |client| %>
|
||||
<span class="email_attribute_client"><%= client %></span>
|
||||
<% @email.organisations.presence.each do |organisation| %>
|
||||
<span class="email_attribute_organisation"><%= organisation %></span>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -43,12 +43,12 @@
|
|||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% if @email.tickets.present? %>
|
||||
<% if @email.issues.present? %>
|
||||
<tr>
|
||||
<th>Tickets</th>
|
||||
<th>Issues</th>
|
||||
<td>
|
||||
<% @email.tickets.presence.each do |ticket| %>
|
||||
<span class="email_attribute_ticket"><%= ticket %></span>
|
||||
<% @email.issues.presence.each do |issue| %>
|
||||
<span class="email_attribute_issue"><%= issue %></span>
|
||||
<% end %>
|
||||
</td>
|
||||
</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.boolean "cron"
|
||||
t.boolean "mailing_list"
|
||||
t.string "clients"
|
||||
t.string "organisations"
|
||||
t.string "servers"
|
||||
t.string "tickets"
|
||||
t.string "issues"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ MIME-Version: 1.0
|
|||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
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: 12345
|
||||
|
|
@ -9,7 +9,7 @@ MIME-Version: 1.0
|
|||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
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
|
||||
|
||||
dummy body
|
|
@ -9,7 +9,7 @@ MIME-Version: 1.0
|
|||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
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: 75FOOB0123
|
||||
|
|
@ -9,7 +9,7 @@ MIME-Version: 1.0
|
|||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
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
|
||||
|
||||
dummy body
|
|
@ -20,38 +20,38 @@ class RuleSetProcessorTest < ActiveSupport::TestCase
|
|||
assert_not_predicate email, :cron?
|
||||
end
|
||||
|
||||
test "single ticket" do
|
||||
email = email_from_eml_with_rules("tickets_single.eml")
|
||||
test "single issue" do
|
||||
email = email_from_eml_with_rules("issues_single.eml")
|
||||
|
||||
expected = ["49123"]
|
||||
actual = email.tickets
|
||||
actual = email.issues
|
||||
|
||||
assert_equal expected, actual
|
||||
end
|
||||
|
||||
test "multiple tickets" do
|
||||
email = email_from_eml_with_rules("tickets_multiple.eml")
|
||||
test "multiple issues" do
|
||||
email = email_from_eml_with_rules("issues_multiple.eml")
|
||||
|
||||
expected = ["49123", "12345"]
|
||||
actual = email.tickets
|
||||
actual = email.issues
|
||||
|
||||
assert_equal expected, actual
|
||||
end
|
||||
|
||||
test "single client" do
|
||||
email = email_from_eml_with_rules("clients_single.eml")
|
||||
test "single organisation" do
|
||||
email = email_from_eml_with_rules("organisations_single.eml")
|
||||
|
||||
expected = ["quux"]
|
||||
actual = email.clients
|
||||
actual = email.organisations
|
||||
|
||||
assert_equal expected, actual
|
||||
end
|
||||
|
||||
test "multiple clients" do
|
||||
email = email_from_eml_with_rules("clients_multiple.eml")
|
||||
test "multiple organisations" do
|
||||
email = email_from_eml_with_rules("organisations_multiple.eml")
|
||||
|
||||
expected = ["quux", "foobar"]
|
||||
actual = email.clients
|
||||
actual = email.organisations
|
||||
|
||||
assert_equal expected, actual
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue