-
-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update potentially-stale status dynamically (#4905)
Fixes 2 bugs: - project-health-service keeping the feature types as an instance variable and only updating it once was preventing real calculation to happen if the lifetime value changed for a feature toggle type - the ui was reading from a predefined map for the lifetime values so they would never reflect the BE change Closes # [SR-66](https://linear.app/unleash/issue/SR-66/slack-question-around-potentially-stale-and-its-uses) <img width="1680" alt="Screenshot 2023-10-02 at 14 37 17" src="https://github.com/Unleash/unleash/assets/104830839/7bee8d4a-9054-4214-a1a2-11ad8169c3d5"> <img width="1660" alt="Screenshot 2023-10-02 at 14 37 06" src="https://github.com/Unleash/unleash/assets/104830839/23bf55c7-a380-4423-a732-205ad81d5c3c"> --------- Signed-off-by: andreas-unleash <[email protected]>
- Loading branch information
1 parent
bd8b54b
commit b07c032
Showing
6 changed files
with
49 additions
and
44 deletions.
There are no files selected for viewing
21 changes: 15 additions & 6 deletions
21
.../component/project/Project/ProjectHealth/ReportTable/ReportExpiredCell/formatExpiredAt.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 14 additions & 3 deletions
17
.../src/component/project/Project/ProjectHealth/ReportTable/ReportStatusCell/formatStatus.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 5 additions & 12 deletions
17
frontend/src/component/project/Project/ProjectHealth/ReportTable/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,12 @@ | ||
import differenceInDays from 'date-fns/differenceInDays'; | ||
import { EXPERIMENT, OPERATIONAL, RELEASE } from 'constants/featureToggleTypes'; | ||
|
||
const FORTY_DAYS = 40; | ||
const SEVEN_DAYS = 7; | ||
|
||
export const toggleExpiryByTypeMap: Record<string, number> = { | ||
[EXPERIMENT]: FORTY_DAYS, | ||
[RELEASE]: FORTY_DAYS, | ||
[OPERATIONAL]: SEVEN_DAYS, | ||
}; | ||
import { FeatureTypeSchema } from 'openapi'; | ||
|
||
export const getDiffInDays = (date: Date, now: Date) => { | ||
return Math.abs(differenceInDays(date, now)); | ||
}; | ||
|
||
export const expired = (diff: number, type: string) => { | ||
return diff >= toggleExpiryByTypeMap[type]; | ||
export const expired = (diff: number, type: FeatureTypeSchema) => { | ||
if (type.lifetimeDays) return diff >= type?.lifetimeDays?.valueOf(); | ||
|
||
return false; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters