Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cases] Add duration #130448

Merged
merged 11 commits into from
Apr 27, 2022
Merged

[Cases] Add duration #130448

merged 11 commits into from
Apr 27, 2022

Conversation

cnasikas
Copy link
Member

@cnasikas cnasikas commented Apr 18, 2022

Summary

This PR adds the duration field to a case. The field represents the duration of a case from open to close in seconds. The field is needed to calculate the average response time of a case by doing an average aggregation on it.

References: https://github.com/elastic/security-team/issues/2080

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@cnasikas cnasikas self-assigned this Apr 18, 2022
@cnasikas cnasikas added release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Feature:Cases Cases feature v8.3.0 labels Apr 18, 2022
@cnasikas cnasikas mentioned this pull request Apr 18, 2022
2 tasks
const updatedDt = new Date().toISOString();
const updatedCases = await caseService.patchCases({
cases: updateCases.map(({ updateReq, originalCase }) => {
// intentionally removing owner from the case so that we don't accidentally allow it to be updated
const { id: caseId, version, owner, ...updateCaseAttributes } = updateReq;
let closedInfo = {};
if (updateCaseAttributes.status && updateCaseAttributes.status === CaseStatuses.closed) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I created a helper function getClosedInfoForUpdate and move the logic there.

@cnasikas cnasikas marked this pull request as ready for review April 20, 2022 09:43
@cnasikas cnasikas requested a review from a team as a code owner April 20, 2022 09:43
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops-cases (Feature:Cases)

@cnasikas cnasikas requested a review from academo April 20, 2022 09:44

/**
* Duration is the time from the creation of the case to the close of the case in seconds
* If an error occurs or the case has not been close then the duration is set to null
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit - not been closed :)

@cnasikas
Copy link
Member Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
cases 57 52 -5

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
cases 19 20 +1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
cases 91.1KB 91.1KB +36.0B

Saved Objects .kibana field count

Every field in each saved object type adds overhead to Elasticsearch. Kibana needs to keep the total field count below Elasticsearch's default limit of 1000 fields. Only specify field mappings for the fields you wish to search on or query. See https://www.elastic.co/guide/en/kibana/master/development-plugin-saved-objects.html#_mappings

id before after diff
cases 39 40 +1
Unknown metric groups

API count

id before after diff
cases 71 66 -5

ESLint disabled line counts

id before after diff
cases 76 75 -1

Total ESLint disabled count

id before after diff
cases 92 91 -1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @cnasikas

@cnasikas cnasikas merged commit 2079f74 into elastic:main Apr 27, 2022
@cnasikas cnasikas deleted the case_duration branch April 27, 2022 14:00
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Apr 27, 2022
dmlemeshko pushed a commit to dmlemeshko/kibana that referenced this pull request May 5, 2022
* Migrate duration

* Add mapping

* Change duration when change status

* Add integration tests

* Fix tests

* Improve tests

* PR feedback

* Fix test

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
kertal pushed a commit to kertal/kibana that referenced this pull request May 24, 2022
* Migrate duration

* Add mapping

* Change duration when change status

* Add integration tests

* Fix tests

* Improve tests

* PR feedback

* Fix test

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Cases Cases feature release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants