Merge pull request #784 from theseyi/prev-seen

adds num of days window to recent suggestions check
This commit is contained in:
Seyi Adebajo 2017-10-04 13:01:05 -07:00 committed by GitHub
commit f93bcbbabb
2 changed files with 16 additions and 4 deletions

View File

@ -12,7 +12,8 @@ import {
logicalTypesForIds,
logicalTypesForGeneric,
hasPredefinedFieldFormat,
getDefaultLogicalType
getDefaultLogicalType,
lastSeenSuggestionInterval
} from 'wherehows-web/constants';
import {
isPolicyExpectedShape,
@ -332,10 +333,11 @@ export default Component.extend({
]);
const { lastModified: suggestionsLastModified, complianceSuggestions = [] } = complianceSuggestion;
// If modification dates exist, check that the suggestions are newer than the last time the policy was saved
// If modification dates exist, check that the suggestions are considered 'unseen' since the last time the policy was saved
// and we have at least 1 suggestion, otherwise check that the count of suggestions is at least 1
if (policyModificationTimeInEpoch && suggestionsLastModified) {
return complianceSuggestions.length && suggestionsLastModified > policyModificationTimeInEpoch;
const suggestionIsUnseen = suggestionsLastModified - policyModificationTimeInEpoch >= lastSeenSuggestionInterval;
return complianceSuggestions.length && suggestionIsUnseen;
}
return !!complianceSuggestions.length;

View File

@ -44,12 +44,21 @@ interface IFieldIdTypes {
[prop: string]: IFieldIdProps;
}
/**
* Length of time between suggestion modification time and last modified time for the compliance policy
* If a policy has been updated within the range of this window then it is considered as stale / or
* has been seen previously
* @type {number}
*/
const lastSeenSuggestionInterval: number = 7 * 24 * 60 * 60 * 1000;
/**
* Percentage value for a compliance policy suggestion with a low confidence score
* @type {number}
*/
const lowQualitySuggestionConfidenceThreshold = 0.5;
/**
* A list of id logical types
* @type {Array.<String>}
@ -350,6 +359,7 @@ export {
logicalTypesForIds,
logicalTypesForGeneric,
getDefaultLogicalType,
SuggestionIntent,
lastSeenSuggestionInterval,
SuggestionIntent
lowQualitySuggestionConfidenceThreshold
};