Skip to content

Commit

Permalink
Histogram models renamed.
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrczarnas committed Sep 30, 2024
1 parent e0df214 commit 3b46c1d
Show file tree
Hide file tree
Showing 13 changed files with 214 additions and 218 deletions.
14 changes: 7 additions & 7 deletions dqops/src/main/frontend/src/pages/IncidentDetail/BarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import moment from 'moment/moment';
import React, { useState } from 'react';
import { Bar } from 'react-chartjs-2';
import {
IncidentDailyIssuesCount,
IncidentIssueHistogramModel
HistogramDailyIssuesCount,
IssueHistogramModel
} from '../../api';
import { useActionDispatch } from '../../hooks/useActionDispatch';
import { setIncidentsHistogram } from '../../redux/actions/incidents.actions';

type BarChartProps = {
histograms: IncidentIssueHistogramModel;
histograms: IssueHistogramModel;
};

export const BarChart = ({ histograms }: BarChartProps) => {
const [savedHistograms, setSavedHistograms] =
useState<IncidentIssueHistogramModel | null>(null);
useState<IssueHistogramModel | null>(null);
const dispatch = useActionDispatch();
const data = {
labels: Object.keys(histograms?.days || {}).map((item) =>
Expand All @@ -24,23 +24,23 @@ export const BarChart = ({ histograms }: BarChartProps) => {
{
label: 'Warnings',
data: Object.values(histograms?.days || {}).map(
(item: IncidentDailyIssuesCount) => item.warnings
(item: HistogramDailyIssuesCount) => item.warnings
),
backgroundColor: '#EBE51E',
barPercentage: 0.9
},
{
label: 'Errors',
data: Object.values(histograms?.days || {}).map(
(item: IncidentDailyIssuesCount) => item.errors
(item: HistogramDailyIssuesCount) => item.errors
),
backgroundColor: '#FF9900',
barPercentage: 0.9
},
{
label: 'Fatals',
data: Object.values(histograms?.days || {}).map(
(item: IncidentDailyIssuesCount) => item.fatals
(item: HistogramDailyIssuesCount) => item.fatals
),
backgroundColor: '#E3170A',
barPercentage: 0.9
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import clsx from 'clsx';
import React, { useEffect } from 'react';
import { useSelector } from 'react-redux';
import { IncidentIssueHistogramModel } from '../../api';
import { IssueHistogramModel } from '../../api';
import SectionWrapper from '../../components/Dashboard/SectionWrapper';
import { useActionDispatch } from '../../hooks/useActionDispatch';
import {
Expand Down Expand Up @@ -42,7 +42,7 @@ export const HistogramChart = ({
histograms,
histogramFilter
}: {
histograms: IncidentIssueHistogramModel;
histograms: IssueHistogramModel;
histogramFilter: IncidentHistogramFilter;
} = useSelector(getFirstLevelIncidentsState);
const { activeTab } = useSelector((state: IRootState) => state.incidents);
Expand Down
4 changes: 2 additions & 2 deletions dqops/src/main/frontend/src/pages/IncidentDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import { useHistory } from 'react-router-dom';
import {
IncidentIssueHistogramModel,
IssueHistogramModel,
IncidentModel,
IncidentModelNotificationLocationEnum,
IncidentModelStatusEnum
Expand Down Expand Up @@ -104,7 +104,7 @@ export const IncidentDetail = () => {
const { sidebarWidth } = useTree();
const { issues, filters = {} } = useSelector(getFirstLevelIncidentsState);
const history = useHistory();
const { histograms }: { histograms: IncidentIssueHistogramModel } =
const { histograms }: { histograms: IssueHistogramModel } =
useSelector(getFirstLevelIncidentsState);
useEffect(() => {
IncidentsApi.getIncident(connection, year, month, incidentId).then(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Dispatch } from 'redux';
import { AxiosResponse } from 'axios';
import {
CheckResultEntryModel,
IncidentIssueHistogramModel,
IssueHistogramModel,
IncidentModel,
IncidentsPerConnectionModel
} from '../../api';
Expand Down Expand Up @@ -210,7 +210,7 @@ export const getIncidentsHistogramsRequest = () => ({
});

export const getIncidentsHistogramsSuccess = (
data: IncidentIssueHistogramModel
data: IssueHistogramModel
) => ({
type: INCIDENTS_ACTION.GET_INCIDENTS_HISTOGRAMS_SUCCESS,
data
Expand All @@ -236,7 +236,7 @@ export const getIncidentsHistograms =
async (dispatch: Dispatch) => {
dispatch(getIncidentsHistogramsRequest());
try {
const res: AxiosResponse<IncidentIssueHistogramModel> =
const res: AxiosResponse<IssueHistogramModel> =
await IncidentsApi.getIncidentHistogram(
connection,
year,
Expand Down Expand Up @@ -266,7 +266,7 @@ export const addSelectedConnection = (data: { [key: string]: string }) => ({
data
});

export const setIncidentsHistogram = (data: IncidentIssueHistogramModel) => ({
export const setIncidentsHistogram = (data: IssueHistogramModel) => ({
type: INCIDENTS_ACTION.SET_INCIDENTS_HISTOGRAM,
data
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.dqops.data.checkresults.models;

import com.dqops.checks.CheckType;
import com.dqops.data.incidents.models.IncidentDailyIssuesCount;
import com.dqops.data.incidents.models.HistogramDailyIssuesCount;
import com.dqops.metadata.timeseries.TimePeriodGradient;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
Expand All @@ -31,13 +31,13 @@
import java.util.stream.Collectors;

/**
* Model that returns histograms of the data quality issue occurrences related to a data quality incident.
* Model that returns histograms of the data quality issue occurrences related to a data quality incident or a table.
* The dates in the daily histogram are using the default timezone of the DQOps server.
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.LowerCamelCaseStrategy.class)
@Data
public class IncidentIssueHistogramModel {
public class IssueHistogramModel {
/**
* True when this data quality incident is based on data quality issues from profiling checks within the filters applied to search for linked data quality issues.
*/
Expand Down Expand Up @@ -72,7 +72,7 @@ public class IncidentIssueHistogramModel {
* A map of the numbers of data quality issues per day, the day uses the DQOps server timezone.
*/
@JsonPropertyDescription("A map of the numbers of data quality issues per day, the day uses the DQOps server timezone.")
private Map<LocalDate, IncidentDailyIssuesCount> days = new TreeMap<>();
private Map<LocalDate, HistogramDailyIssuesCount> days = new TreeMap<>();

/**
* A map of column names with the most data quality issues related to the incident. The map returns the count of issues as the value.
Expand Down Expand Up @@ -131,13 +131,13 @@ public void markCheckType(CheckType checkType, TimePeriodGradient timeScale) {
* @param severity Severity level of a failed data quality check.
*/
public void incrementSeverityForDay(LocalDate date, int severity) {
IncidentDailyIssuesCount incidentDailyIssuesCount = this.days.get(date);
if (incidentDailyIssuesCount == null) {
incidentDailyIssuesCount = new IncidentDailyIssuesCount();
this.days.put(date, incidentDailyIssuesCount);
HistogramDailyIssuesCount histogramDailyIssuesCount = this.days.get(date);
if (histogramDailyIssuesCount == null) {
histogramDailyIssuesCount = new HistogramDailyIssuesCount();
this.days.put(date, histogramDailyIssuesCount);
}

incidentDailyIssuesCount.incrementForIssueSeverity(severity);
histogramDailyIssuesCount.incrementForIssueSeverity(severity);
}

/**
Expand Down Expand Up @@ -184,8 +184,8 @@ public void addMissingDaysInRange() {
LocalDate lastDate;

if (this.days instanceof TreeMap) {
firstDate = ((TreeMap<LocalDate, IncidentDailyIssuesCount>) this.days).firstKey();
lastDate = ((TreeMap<LocalDate, IncidentDailyIssuesCount>) this.days).lastKey();
firstDate = ((TreeMap<LocalDate, HistogramDailyIssuesCount>) this.days).firstKey();
lastDate = ((TreeMap<LocalDate, HistogramDailyIssuesCount>) this.days).lastKey();
} else {
List<LocalDate> daysKeysSortedList = this.days.keySet().stream().sorted().collect(Collectors.toList());
firstDate = daysKeysSortedList.get(0);
Expand All @@ -198,7 +198,7 @@ public void addMissingDaysInRange() {
continue;
}

this.days.put(date, new IncidentDailyIssuesCount());
this.days.put(date, new HistogramDailyIssuesCount());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ CheckResultEntryModel[] loadCheckResultsRelatedToIncident(String connectionName,
* @param userDomainIdentity User identity with the data domain.
* @return Daily histogram of failed data quality checks.
*/
IncidentIssueHistogramModel buildDailyIssuesHistogramForIncident(String connectionName,
PhysicalTableName physicalTableName,
long incidentHash,
Instant firstSeen,
Instant incidentUntil,
int minSeverity,
IncidentHistogramFilterParameters filterParameters,
UserDomainIdentity userDomainIdentity);
IssueHistogramModel buildDailyIssuesHistogramForIncident(String connectionName,
PhysicalTableName physicalTableName,
long incidentHash,
Instant firstSeen,
Instant incidentUntil,
int minSeverity,
IncidentHistogramFilterParameters filterParameters,
UserDomainIdentity userDomainIdentity);

/**
* Analyzes the table to find the status of the most recent data quality check for each time series
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,14 +711,14 @@ public CheckResultEntryModel[] loadCheckResultsRelatedToIncident(String connecti
* @return Daily histogram of failed data quality checks.
*/
@Override
public IncidentIssueHistogramModel buildDailyIssuesHistogramForIncident(String connectionName,
PhysicalTableName physicalTableName,
long incidentHash,
Instant firstSeen,
Instant incidentUntil,
int minSeverity,
IncidentHistogramFilterParameters filterParameters,
UserDomainIdentity userDomainIdentity) {
public IssueHistogramModel buildDailyIssuesHistogramForIncident(String connectionName,
PhysicalTableName physicalTableName,
long incidentHash,
Instant firstSeen,
Instant incidentUntil,
int minSeverity,
IncidentHistogramFilterParameters filterParameters,
UserDomainIdentity userDomainIdentity) {
ZoneId defaultTimeZoneId = this.defaultTimeZoneProvider.getDefaultTimeZoneId();

CheckResultsSnapshot checkResultsSnapshot = this.checkResultsSnapshotFactory.createReadOnlySnapshot(connectionName,
Expand All @@ -736,7 +736,7 @@ public IncidentIssueHistogramModel buildDailyIssuesHistogramForIncident(String c

LocalDate endMonth = incidentUntil.plus(12L, ChronoUnit.HOURS).atZone(defaultTimeZoneId).toLocalDate();
if (!checkResultsSnapshot.ensureMonthsAreLoaded(startDay, endMonth)) {
return new IncidentIssueHistogramModel();
return new IssueHistogramModel();
}

Instant startTimestamp = firstSeen;
Expand All @@ -750,7 +750,7 @@ public IncidentIssueHistogramModel buildDailyIssuesHistogramForIncident(String c
}
}

IncidentIssueHistogramModel histogramModel = new IncidentIssueHistogramModel();
IssueHistogramModel histogramModel = new IssueHistogramModel();

Map<ParquetPartitionId, LoadedMonthlyPartition> loadedMonthlyPartitions = checkResultsSnapshot.getLoadedMonthlyPartitions();
for (Map.Entry<ParquetPartitionId, LoadedMonthlyPartition> loadedPartitionEntry : loadedMonthlyPartitions.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Data;

import java.time.LocalDateTime;
import java.time.ZoneOffset;

/**
* A model that stores a daily number of incidents.
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.LowerCamelCaseStrategy.class)
@Data
public class IncidentDailyIssuesCount {
public class HistogramDailyIssuesCount {
/**
* The number of failed data quality checks that generated a warning severity data quality issue.
*/
Expand Down Expand Up @@ -77,10 +74,10 @@ else if (severityLevel == 3) {
/**
* Sample factory for an incident model.
*/
public static class IncidentDailyIssuesCountSampleFactory implements SampleValueFactory<IncidentDailyIssuesCount> {
public static class IncidentDailyIssuesCountSampleFactory implements SampleValueFactory<HistogramDailyIssuesCount> {
@Override
public IncidentDailyIssuesCount createSample() {
return new IncidentDailyIssuesCount() {{
public HistogramDailyIssuesCount createSample() {
return new HistogramDailyIssuesCount() {{
setTotalCount(10);
setWarnings(2);
setErrors(7);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.dqops.data.checkresults.models.CheckResultEntryModel;
import com.dqops.data.checkresults.models.CheckResultListFilterParameters;
import com.dqops.data.checkresults.models.IncidentHistogramFilterParameters;
import com.dqops.data.checkresults.models.IncidentIssueHistogramModel;
import com.dqops.data.checkresults.models.IssueHistogramModel;
import com.dqops.data.incidents.factory.IncidentStatus;
import com.dqops.data.incidents.models.*;

Expand Down Expand Up @@ -100,10 +100,10 @@ CheckResultEntryModel[] loadCheckResultsForIncident(String connectionName,
* @param userDomainIdentity Calling user identity with the data domain.
* @return Daily histogram of days when a data quality issue failed.
*/
IncidentIssueHistogramModel buildDailyIssuesHistogramForIncident(String connectionName,
int year,
int month,
String incidentId,
IncidentHistogramFilterParameters filterParameters,
UserDomainIdentity userDomainIdentity);
IssueHistogramModel buildDailyIssuesHistogramForIncident(String connectionName,
int year,
int month,
String incidentId,
IncidentHistogramFilterParameters filterParameters,
UserDomainIdentity userDomainIdentity);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.dqops.data.checkresults.models.CheckResultEntryModel;
import com.dqops.data.checkresults.models.CheckResultListFilterParameters;
import com.dqops.data.checkresults.models.IncidentHistogramFilterParameters;
import com.dqops.data.checkresults.models.IncidentIssueHistogramModel;
import com.dqops.data.checkresults.models.IssueHistogramModel;
import com.dqops.data.checkresults.services.CheckResultsDataService;
import com.dqops.data.incidents.factory.IncidentStatus;
import com.dqops.data.incidents.factory.IncidentsColumnNames;
Expand Down Expand Up @@ -358,18 +358,18 @@ public CheckResultEntryModel[] loadCheckResultsForIncident(String connectionName
* @return Daily histogram of days when a data quality issue failed.
*/
@Override
public IncidentIssueHistogramModel buildDailyIssuesHistogramForIncident(String connectionName,
int year,
int month,
String incidentId,
IncidentHistogramFilterParameters filterParameters,
UserDomainIdentity userDomainIdentity) {
public IssueHistogramModel buildDailyIssuesHistogramForIncident(String connectionName,
int year,
int month,
String incidentId,
IncidentHistogramFilterParameters filterParameters,
UserDomainIdentity userDomainIdentity) {
IncidentModel incidentModel = this.loadIncident(connectionName, year, month, incidentId, userDomainIdentity);
if (incidentModel == null) {
return null;
}

IncidentIssueHistogramModel histogramModel = this.checkResultsDataService.buildDailyIssuesHistogramForIncident(connectionName,
IssueHistogramModel histogramModel = this.checkResultsDataService.buildDailyIssuesHistogramForIncident(connectionName,
new PhysicalTableName(incidentModel.getSchema(), incidentModel.getTable()),
incidentModel.getIncidentHash(),
incidentModel.getFirstSeen(),
Expand Down
Loading

0 comments on commit 3b46c1d

Please sign in to comment.