-
-
Notifications
You must be signed in to change notification settings - Fork 729
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
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"> --------- (cherry picked from commit b07c032) <!-- Thanks for creating a PR! To make it easier for reviewers and everyone else to understand what your changes relate to, please add some relevant content to the headings below. Feel free to ignore or delete sections that you don't think are relevant. Thank you! ❤️ --> ## About the changes <!-- Describe the changes introduced. What are they and why are they being introduced? Feel free to also add screenshots or steps to view the changes if they're visual. --> <!-- Does it close an issue? Multiple? --> Closes # <!-- (For internal contributors): Does it relate to an issue on public roadmap? --> <!-- Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item: # --> ### Important files <!-- PRs can contain a lot of changes, but not all changes are equally important. Where should a reviewer start looking to get an overview of the changes? Are any files particularly important? --> ## Discussion points <!-- Anything about the PR you'd like to discuss before it gets merged? Got any questions or doubts? --> --------- Signed-off-by: andreas-unleash <[email protected]>
- Loading branch information
1 parent
32305bb
commit ba40ed1
Showing
6 changed files
with
51 additions
and
46 deletions.
There are no files selected for viewing
23 changes: 16 additions & 7 deletions
23
.../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
19 changes: 15 additions & 4 deletions
19
.../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