Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,12 @@ export const CAI_CASES_INDEX_MAPPINGS: MappingTypeMapping = {
type: 'keyword',
},
time_to_resolve: {
// in seconds, calculated by case.closed_at - case.created_at
type: 'long',
},
time_to_acknowledge: {
// in seconds, calculated by case.in_progress_at - case.created_at
type: 'long',
},
time_to_investigaste: {
// in seconds, calculated by case.closed_at - case.in_progress_at
time_to_investigate: {
type: 'long',
},
custom_fields: {
Expand Down Expand Up @@ -151,5 +148,11 @@ export const CAI_CASES_INDEX_MAPPINGS: MappingTypeMapping = {
space_ids: {
type: 'keyword',
},
total_alerts: {
type: 'integer',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we only set numbers bigger than zero, should we change it to unsigned_long? Same for total_comments. If we are afraid that a negative number can slip in here, let's leave it as it is.

},
total_comments: {
type: 'integer',
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,24 @@ export const CAI_CASES_INDEX_SCRIPT: StoredScript = {
ctx._source.owner = source.cases.owner;
ctx._source.space_ids = source.namespaces;

if (ctx._source.created_at_ms != null && ctx._source.closed_at_ms != null){
ctx._source.time_to_resolve = (ctx._source.closed_at_ms - ctx._source.created_at_ms) / 1000;
if (source.cases.time_to_acknowledge != null){
ctx._source.time_to_acknowledge = source.cases.time_to_acknowledge;
}

if (source.cases.time_to_investigate != null){
ctx._source.time_to_investigate = source.cases.time_to_investigate;
}

if (source.cases.time_to_resolve != null){
ctx._source.time_to_resolve = source.cases.time_to_resolve;
}

if (source.cases.total_alerts != null && source.cases.total_alerts >= 0){
ctx._source.total_alerts = source.cases.total_alerts;
}

if (source.cases.total_comments != null && source.cases.total_comments >= 0){
ctx._source.total_comments = source.cases.total_comments;
}
`,
};