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

Add parseTrend() function to ScanConfig model #1583

Merged
merged 6 commits into from
Aug 28, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]

### Added
- Added parseTrend() function to ScanConfig model [#1583](https://github.com/greenbone/gsa/pull/1583)
- Added DetailsPage and more funtionalities to TLS Certificate assets [#1578](https://github.com/greenbone/gsa/pull/1578)
- Added Explicit Compliance [#1495](https://github.com/greenbone/gsa/pull/1495)
- Added tasktrendgroup component for tasks filter dialog [#1511](https://github.com/greenbone/gsa/pull/1511)
Expand Down
5 changes: 3 additions & 2 deletions gsa/src/gmp/models/__tests__/scanconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import ScanConfig, {
filterEmptyScanConfig,
openVasScanConfigsFilter,
ospScanConfigsFilter,
SCANCONFIG_TREND_DYNAMIC,
} from 'gmp/models/scanconfig';
import {testModel} from 'gmp/models/testing';

Expand Down Expand Up @@ -119,7 +120,7 @@ describe('ScanConfig model tests', () => {
const scanConfig = new ScanConfig(elem);

expect(scanConfig.families.count).toEqual(42);
expect(scanConfig.families.trend).toEqual('1');
expect(scanConfig.families.trend).toEqual(SCANCONFIG_TREND_DYNAMIC);
expect(scanConfig.family_count).toBeUndefined();
});

Expand All @@ -134,7 +135,7 @@ describe('ScanConfig model tests', () => {
};
const res = {
count: 42,
trend: '1',
trend: SCANCONFIG_TREND_DYNAMIC,
known: 21,
max: 1337,
};
Expand Down
6 changes: 4 additions & 2 deletions gsa/src/gmp/models/scanconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export const openVasScanConfigsFilter = config =>
export const ospScanConfigsFilter = config =>
config.scan_config_type === OSP_SCAN_CONFIG_TYPE;

const parseTrend = parseInt;

class ScanConfig extends Model {
static entityType = 'scanconfig';

Expand Down Expand Up @@ -85,7 +87,7 @@ class ScanConfig extends Model {

if (isDefined(ret.family_count)) {
families.count = parse_count(ret.family_count.__text);
families.trend = ret.family_count.growing;
families.trend = parseTrend(ret.family_count.growing);

delete ret.family_count;
} else {
Expand All @@ -97,7 +99,7 @@ class ScanConfig extends Model {
if (isDefined(ret.nvt_count)) {
ret.nvts = {
count: parse_count(ret.nvt_count.__text),
trend: ret.nvt_count.growing,
trend: parseTrend(ret.nvt_count.growing),
};

delete ret.nvt_count;
Expand Down