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

fix compliance graph not showing data of past n days (IN-864) #7748

Merged
merged 1 commit into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ describe('ReportingOverviewComponent', () => {
it('gets node status data', () => {
spyOn(component, 'getNodeStatusData');
component.selectedButtonTab = 'Node Status';
localStorage.setItem('current-url', 'reporting/controls');
component.getData(reportQuery);
expect(component.getNodeStatusData).toHaveBeenCalledWith(reportQuery);
});
Expand All @@ -119,7 +118,6 @@ describe('ReportingOverviewComponent', () => {
it('gets profile status data', () => {
spyOn(component, 'getProfileStatusData');
component.selectedButtonTab = 'Profile Status';
localStorage.setItem('current-url', 'reporting/controls');
component.getData(reportQuery);
expect(component.getProfileStatusData).toHaveBeenCalledWith(reportQuery);
});
Expand All @@ -128,14 +126,12 @@ describe('ReportingOverviewComponent', () => {
describe('getNodeStatusData()', () => {
it('gets node status failure data', () => {
spyOn(component, 'getNodeStatusFailures');
localStorage.setItem('current-url', 'reporting/controls');
component.getNodeStatusData(reportQuery);
expect(component.getNodeStatusFailures).toHaveBeenCalledWith(reportQuery);
});

it('gets node status summary data', () => {
spyOn(component, 'getNodeSummary');
localStorage.setItem('current-url', 'reporting/controls');
component.getNodeStatusData(reportQuery);
expect(component.getNodeSummary).toHaveBeenCalledWith(reportQuery);
});
Expand All @@ -150,7 +146,6 @@ describe('ReportingOverviewComponent', () => {
describe('getProfileStatusData()', () => {
it('gets profile status failure data', () => {
spyOn(component, 'getProfileStatusFailures');
localStorage.setItem('current-url', 'reporting/controls');
component.getProfileStatusData(reportQuery);
expect(component.getProfileStatusFailures).toHaveBeenCalledWith(reportQuery);
});
Expand Down Expand Up @@ -286,7 +281,6 @@ describe('ReportingOverviewComponent', () => {
});

describe('getControlsTrend()', () => {
localStorage.setItem('current-url', 'reporting/controls');
beforeEach(() => {
spyOn(statsService, 'getControlsTrend').and.returnValue(observableOf([
{
Expand Down Expand Up @@ -439,7 +433,6 @@ describe('ReportingOverviewComponent', () => {
}
];

localStorage.setItem('current-url', 'reporting/controls');

beforeEach(() => {
spyOn(statsService, 'getNodeTrend').and.returnValue(observableOf(data));
Expand All @@ -464,7 +457,6 @@ describe('ReportingOverviewComponent', () => {
filters: [ {type: { name: 'node'}, value: { id: '1231'}}],
last24h: false
};
localStorage.setItem('current-url', 'reporting/controls');
const data = [
{
'report_time': dateRange.end,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ describe('StatsService', () => {
last24h: false
};

localStorage.setItem('current-url', 'reporting/controls');
const expectedUrl = `${COMPLIANCE_URL}/reporting/stats/trend`;
const expectedResponse = [{
'time': '2017-03-05T00:00:00+0000',
Expand Down Expand Up @@ -529,7 +528,6 @@ describe('StatsService', () => {
filters: filters,
last24h: false
};
localStorage.setItem('current-url', 'test');

const expectedUrl = `${COMPLIANCE_URL}/reporting/stats/trend`;
const expectedResponse = [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class StatsService {

getFailures(types: Array<string>, reportQuery: ReportQuery): Observable<any> {
const url = `${CC_API_URL}/reporting/stats/failures`;
reportQuery = this.getStartDate(reportQuery);
const formatted = this.formatFilters(reportQuery);
formatted.push({ type: 'types', values: types });
const body = { filters: formatted };
Expand All @@ -50,6 +51,7 @@ export class StatsService {

getNodeSummary(reportQuery: ReportQuery): Observable<any> {
const url = `${CC_API_URL}/reporting/stats/summary`;
reportQuery = this.getStartDate(reportQuery);
const formatted = this.formatFilters(reportQuery);
const body = { type: 'nodes', filters: formatted };

Expand All @@ -59,6 +61,7 @@ export class StatsService {

getControlsSummary(reportQuery: ReportQuery): Observable<any> {
const url = `${CC_API_URL}/reporting/stats/summary`;
reportQuery = this.getStartDate(reportQuery);
const formatted = this.formatFilters(reportQuery);
const body = { type: 'controls', filters: formatted };

Expand Down Expand Up @@ -89,14 +92,8 @@ export class StatsService {
getNodeTrend(reportQuery: ReportQuery) {
const url = `${CC_API_URL}/reporting/stats/trend`;
const interval = 86400;
const prev = localStorage.getItem('current-url');
const url_array = ['reporting/nodes' , 'reporting/profiles' , 'reporting/controls'];
const urlcheck = url_array.some(urlVar => prev.includes(urlVar));
if (urlcheck) {
const timeInterval = reportQuery.interval;
this.getTimeInterval(timeInterval, reportQuery);
localStorage.setItem('current-url', url);
}
const timeInterval = reportQuery.interval;
this.getTimeInterval(timeInterval, reportQuery);
const formatted = this.formatFilters(reportQuery, false);
const body = {type: 'nodes', interval, filters: formatted};

Expand All @@ -107,14 +104,8 @@ export class StatsService {
getControlsTrend(reportQuery: ReportQuery) {
const url = `${CC_API_URL}/reporting/stats/trend`;
const interval = 86400;
const prev = localStorage.getItem('current-url');
const url_array = ['reporting/nodes' , 'reporting/profiles' , 'reporting/controls'];
const urlcheck = url_array.some(urlVar => prev.includes(urlVar));
if (urlcheck) {
const timeInterval = reportQuery.interval;
this.getTimeInterval(timeInterval, reportQuery);
localStorage.setItem('current-url', url);
}
const timeInterval = reportQuery.interval;
this.getTimeInterval(timeInterval, reportQuery);
const formatted = this.formatFilters(reportQuery, false);
const body = {type: 'controls', interval, filters: formatted};

Expand Down Expand Up @@ -151,8 +142,6 @@ export class StatsService {

getNodes(reportQuery: ReportQuery, listParams: any): Observable<any> {
const url = `${CC_API_URL}/reporting/nodes/search`;
localStorage.setItem('current-url', url);

reportQuery = this.getStartDate(reportQuery);
let formatted = this.formatFilters(reportQuery);
formatted = this.addStatusParam(formatted);
Expand Down Expand Up @@ -189,7 +178,6 @@ export class StatsService {

getProfiles(reportQuery: ReportQuery, listParams: any): Observable<any> {
const url = `${CC_API_URL}/reporting/profiles`;
localStorage.setItem('current-url', url);
reportQuery = this.getStartDate(reportQuery);

let formatted = this.formatFilters(reportQuery);
Expand All @@ -213,7 +201,6 @@ export class StatsService {

getControls(reportQuery: ReportQuery): Observable<{total: any, items: any}> {
const url = `${CC_API_URL}/reporting/controls`;
localStorage.setItem('current-url', url);
reportQuery = this.getStartDate(reportQuery);
let formatted = this.formatFilters(reportQuery);

Expand Down