Skip to content

Commit

Permalink
chore: change survey prompt frequency (#7912)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericzzzzzzz authored Oct 6, 2022
1 parent c50ca8a commit 34b203d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/skaffold/survey/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type config struct {
// startsAt mentions the date after the users survey should be prompted. This will ensure, Skaffold team can finalize the survey
// even after release date.
startsAt time.Time
// expiresAt places a time limit of the user survey. As users are only prompted every two weeks
// expiresAt places a time limit of the user survey. As users are only prompted every 5 days
// by design, this time limit should be at least 4 weeks after the upcoming release date to account
// for release propagation lag to Cloud SDK and Cloud Shell.
expiresAt time.Time
Expand Down
4 changes: 2 additions & 2 deletions pkg/skaffold/survey/survey.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ func (s *Runner) recentlyPromptedOrTaken(cfg *sConfig.GlobalConfig) string {
return s.selectSurvey(surveysTaken(cfg.Global.Survey))
}

// recentlyPrompted returns true if the user has been recently prompted for a survey.
// recentlyPrompted returns true if the user has been prompted for a survey in last 5 days.
func recentlyPrompted(gc *sConfig.SurveyConfig) bool {
return timeutil.LessThan(gc.LastPrompted, 10*24*time.Hour)
return timeutil.LessThan(gc.LastPrompted, 5*24*time.Hour)
}

func (s *Runner) DisplaySurveyPrompt(out io.Writer, id string) error {
Expand Down
10 changes: 5 additions & 5 deletions pkg/skaffold/survey/survey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ func TestDisplaySurveyForm(t *testing.T) {
}

func TestShouldDisplayPrompt(t *testing.T) {
tenDaysAgo := time.Now().AddDate(0, 0, -10).Format(time.RFC3339)
fiveDaysAgo := time.Now().AddDate(0, 0, -5).Format(time.RFC3339)
threeDaysAgo := time.Now().AddDate(0, 0, -3).Format(time.RFC3339)
// less than 90 days ago
twoMonthsAgo := time.Now().AddDate(0, -2, -5).Format(time.RFC3339)
// at least 90 days ago
Expand All @@ -86,12 +86,12 @@ func TestShouldDisplayPrompt(t *testing.T) {
}},
},
{
description: "should not display prompt when last prompted is less than 2 weeks",
description: "should not display prompt when last prompted is less than 5 days",
cfg: &sConfig.GlobalConfig{
Global: &sConfig.ContextConfig{
Survey: &sConfig.SurveyConfig{
DisablePrompt: util.BoolPtr(false),
LastPrompted: fiveDaysAgo,
LastPrompted: threeDaysAgo,
}},
},
},
Expand All @@ -106,12 +106,12 @@ func TestShouldDisplayPrompt(t *testing.T) {
},
},
{
description: "should display prompt when last prompted is before 2 weeks",
description: "should display prompt when last prompted is before 5 days",
cfg: &sConfig.GlobalConfig{
Global: &sConfig.ContextConfig{
Survey: &sConfig.SurveyConfig{
DisablePrompt: util.BoolPtr(false),
LastPrompted: tenDaysAgo,
LastPrompted: fiveDaysAgo,
}},
},
expected: true,
Expand Down

0 comments on commit 34b203d

Please sign in to comment.