From 34b203da7624be2eb10ce7a909019d7fc7865124 Mon Sep 17 00:00:00 2001 From: ericzzzzzzz <102683393+ericzzzzzzz@users.noreply.github.com> Date: Thu, 6 Oct 2022 13:03:20 -0400 Subject: [PATCH] chore: change survey prompt frequency (#7912) --- pkg/skaffold/survey/config.go | 2 +- pkg/skaffold/survey/survey.go | 4 ++-- pkg/skaffold/survey/survey_test.go | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/skaffold/survey/config.go b/pkg/skaffold/survey/config.go index f0b33260ad8..80c691bf168 100644 --- a/pkg/skaffold/survey/config.go +++ b/pkg/skaffold/survey/config.go @@ -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 diff --git a/pkg/skaffold/survey/survey.go b/pkg/skaffold/survey/survey.go index 9b893e410fb..ec08728a4af 100644 --- a/pkg/skaffold/survey/survey.go +++ b/pkg/skaffold/survey/survey.go @@ -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 { diff --git a/pkg/skaffold/survey/survey_test.go b/pkg/skaffold/survey/survey_test.go index d50e3b606aa..81b8937e299 100644 --- a/pkg/skaffold/survey/survey_test.go +++ b/pkg/skaffold/survey/survey_test.go @@ -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 @@ -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, }}, }, }, @@ -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,