Skip to content

Commit

Permalink
[ResponseOps][Cases] Remove deprecated date format from telemetry (#2…
Browse files Browse the repository at this point in the history
…00331)

## Summary

The Cases telemetry uses a deprecated date format that will not be
supported in 9.0. This PR changes the format of the date set in the
`format` field as suggested here
https://www.elastic.co/blog/locale-changes-elasticsearch-8-16-jdk-23.
Specifically, it changes `Y` to `y`. From the docs:

> In particular, if you are using the Y specifier as part of a calendar
date format, you are probably using it erroneously; Joda time uses Y to
represent year-of-era, but the JDK uses Y to represent week-years. You
need to modify your format to use y instead, or change to a built-in
format.

Fixes: elastic/kibana-team#1188

### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

(cherry picked from commit 7ace262)
  • Loading branch information
cnasikas committed Nov 18, 2024
1 parent 6e90b7c commit 7f73ef8
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('alerts', () => {
counts: {
date_range: {
field: 'cases-comments.attributes.created_at',
format: 'dd/MM/YYYY',
format: 'dd/MM/yyyy',
ranges: [
{
from: 'now-1d',
Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/cases/server/telemetry/queries/cases.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ describe('getCasesTelemetryData', () => {
"counts": Object {
"date_range": Object {
"field": "cases.attributes.created_at",
"format": "dd/MM/YYYY",
"format": "dd/MM/yyyy",
"ranges": Array [
Object {
"from": "now-1d",
Expand Down Expand Up @@ -501,7 +501,7 @@ describe('getCasesTelemetryData', () => {
"counts": Object {
"date_range": Object {
"field": "cases.attributes.created_at",
"format": "dd/MM/YYYY",
"format": "dd/MM/yyyy",
"ranges": Array [
Object {
"from": "now-1d",
Expand Down Expand Up @@ -547,7 +547,7 @@ describe('getCasesTelemetryData', () => {
"counts": Object {
"date_range": Object {
"field": "cases.attributes.created_at",
"format": "dd/MM/YYYY",
"format": "dd/MM/yyyy",
"ranges": Array [
Object {
"from": "now-1d",
Expand Down Expand Up @@ -605,7 +605,7 @@ describe('getCasesTelemetryData', () => {
"counts": Object {
"date_range": Object {
"field": "cases.attributes.created_at",
"format": "dd/MM/YYYY",
"format": "dd/MM/yyyy",
"ranges": Array [
Object {
"from": "now-1d",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('comments', () => {
counts: {
date_range: {
field: 'cases-comments.attributes.created_at',
format: 'dd/MM/YYYY',
format: 'dd/MM/yyyy',
ranges: [
{
from: 'now-1d',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('user_actions', () => {
counts: {
date_range: {
field: 'cases-user-actions.attributes.created_at',
format: 'dd/MM/YYYY',
format: 'dd/MM/yyyy',
ranges: [
{
from: 'now-1d',
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/cases/server/telemetry/queries/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ describe('utils', () => {
counts: {
date_range: {
field: 'test.attributes.created_at',
format: 'dd/MM/YYYY',
format: 'dd/MM/yyyy',
ranges: [
{ from: 'now-1d', to: 'now' },
{ from: 'now-1w', to: 'now' },
Expand Down Expand Up @@ -1132,7 +1132,7 @@ describe('utils', () => {
counts: {
date_range: {
field: 'test.attributes.created_at',
format: 'dd/MM/YYYY',
format: 'dd/MM/yyyy',
ranges: [
{
from: 'now-1d',
Expand Down Expand Up @@ -1261,7 +1261,7 @@ describe('utils', () => {
counts: {
date_range: {
field: 'cases-comments.attributes.created_at',
format: 'dd/MM/YYYY',
format: 'dd/MM/yyyy',
ranges: [
{
from: 'now-1d',
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/cases/server/telemetry/queries/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const getCountsAggregationQuery = (savedObjectType: string) => ({
counts: {
date_range: {
field: `${savedObjectType}.attributes.created_at`,
format: 'dd/MM/YYYY',
format: 'dd/MM/yyyy',
ranges: [
{ from: 'now-1d', to: 'now' },
{ from: 'now-1w', to: 'now' },
Expand All @@ -52,7 +52,7 @@ export const getAlertsCountsAggregationQuery = () => ({
counts: {
date_range: {
field: `${CASE_COMMENT_SAVED_OBJECT}.attributes.created_at`,
format: 'dd/MM/YYYY',
format: 'dd/MM/yyyy',
ranges: [
{ from: 'now-1d', to: 'now' },
{ from: 'now-1w', to: 'now' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default ({ getService }: FtrProviderContext): void => {
});
});

it('should return the corect total number of alerts attached to cases', async () => {
it('should return the correct total number of alerts attached to cases', async () => {
const firstCase = await createCase(supertest, getPostCaseRequest());
const secondCase = await createCase(supertest, getPostCaseRequest());

Expand Down

0 comments on commit 7f73ef8

Please sign in to comment.