mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-27 18:07:57 +00:00
chore(ci): add daylight savings timezone for tests, fix daylight saving bug in analytics charts (#7484)
This commit is contained in:
parent
64b4d0bace
commit
39f7f74329
8
.github/workflows/build-and-test.yml
vendored
8
.github/workflows/build-and-test.yml
vendored
@ -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
|
||||
|
||||
@ -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 },
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -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();
|
||||
};
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user