chore(ci): add daylight savings timezone for tests, fix daylight saving bug in analytics charts (#7484)

This commit is contained in:
Aseem Bansal 2023-03-14 16:12:29 +05:30 committed by GitHub
parent 64b4d0bace
commit 39f7f74329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 8 deletions

View File

@ -30,9 +30,17 @@ jobs:
"./gradlew :datahub-frontend:build :datahub-web-react:build --parallel",
"./gradlew :metadata-ingestion-modules:airflow-plugin:build --parallel"
]
timezone:
[
"UTC",
"America/New_York",
]
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: szenius/set-timezone@v1.0
with:
timezoneLinux: ${{ matrix.timezone }}
- uses: actions/checkout@v3
with:
fetch-depth: 0

View File

@ -1,19 +1,14 @@
import { computeLines } from '../TimeSeriesChart';
describe('timeUtils', () => {
describe('addInterval', () => {
describe('timeSeriesChart', () => {
describe('computeLines', () => {
it('compute lines works works correctly for weekly case', () => {
const chartData = {
title: 'Weekly Active Users',
lines: [
{
name: 'total',
data: [
{
x: '2023-02-20T00:00:00.000Z',
y: 1,
},
],
data: [{ x: '2023-02-20T00:00:00.000Z', y: 1 }],
},
],
dateRange: {
@ -38,5 +33,44 @@ describe('timeUtils', () => {
],
});
});
it('compute lines works works correctly for monthly case', () => {
const chartData = {
title: 'Weekly Active Users',
lines: [
{
name: 'total',
data: [
{ x: '2023-01-01T00:00:00.000Z', y: 49 },
{ x: '2023-02-01T00:00:00.000Z', y: 52 },
{ x: '2023-03-01T00:00:00.000Z', y: 16 },
],
},
],
dateRange: {
start: '1648771200000',
end: '1680307199999',
},
interval: 'MONTH',
};
const result = computeLines(chartData, true);
expect(result[0]).toEqual({
name: 'total',
data: [
{ x: '2022-04-01T00:00:00.000Z', y: 0 },
{ x: '2022-05-01T00:00:00.000Z', y: 0 },
{ x: '2022-06-01T00:00:00.000Z', y: 0 },
{ x: '2022-07-01T00:00:00.000Z', y: 0 },
{ x: '2022-08-01T00:00:00.000Z', y: 0 },
{ x: '2022-09-01T00:00:00.000Z', y: 0 },
{ x: '2022-10-01T00:00:00.000Z', y: 0 },
{ x: '2022-11-01T00:00:00.000Z', y: 0 },
{ x: '2022-12-01T00:00:00.000Z', y: 0 },
{ x: '2023-01-01T00:00:00.000Z', y: 49 },
{ x: '2023-02-01T00:00:00.000Z', y: 52 },
{ x: '2023-03-01T00:00:00.000Z', y: 16 },
],
});
});
});
});

View File

@ -60,6 +60,7 @@ export const getTimeWindowSizeMs = (windowSize: TimeWindowSize): TimeWindowSizeM
export const addInterval = (interval_num: number, date: Date, interval: DateInterval): Date => {
return moment(date)
.utc()
.add(interval_num, INTERVAL_TO_MOMENT_INTERVAL[interval] as moment.DurationInputArg2)
.toDate();
};

View File

@ -14,6 +14,7 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.time.ZoneId;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@ -31,6 +32,7 @@ public class Config extends HttpServlet {
put("retention", "true");
put("statefulIngestionCapable", true);
put("patchCapable", true);
put("timeZone", ZoneId.systemDefault());
}};
ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);