Skip to content

Commit

Permalink
Merge pull request #2268 from weaveworks/reduce-trial-length
Browse files Browse the repository at this point in the history
Reduce the trial length
  • Loading branch information
leth authored Aug 31, 2018
2 parents 5908f3a + 56eeb06 commit 8701f18
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 15 deletions.
9 changes: 1 addition & 8 deletions billing-api/trial/trial.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@ import (
common_time "github.com/weaveworks/service/common/time"
)

const (
trialFlag string = "trial:days"
defaultTrialLength int = 30
)

// Trial is a bundle of information about the trial period used by the frontend.
type Trial struct {
// Length is the original length of trial period. This isn't actually
// used. TODO(jml): Remove this field once weaveworks/service-ui#1037 is
// deployed to production.
// Length is the original length of trial period.
Length int `json:"length"`
// Remaining is the number of days remaining, rounded to whole days.
Remaining int `json:"remaining"`
Expand Down
2 changes: 1 addition & 1 deletion billing-api/trial/trial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestTrialInfo(t *testing.T) {
TrialExpiresAt: now.Add(asDays(20) + 1*time.Hour),
},
trial: trial.Trial{
Length: int(users.TrialDuration.Hours() / 24),
Length: 30,
Remaining: 21,
Start: now.Add(asDays(-10) + 1*time.Hour),
End: now.Add(asDays(20) + 1*time.Hour),
Expand Down
6 changes: 3 additions & 3 deletions users/api/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,18 @@ func TestAPI_adminTrial(t *testing.T) {
defer cleanup(t)

usr, org := getOrg(t)
assert.Equal(t, 30, org.TrialRemaining(), "trial is not 30 days on instance creation")
assert.Equal(t, 14, org.TrialRemaining(), "trial is not 14 days on instance creation")

{ // Cannot shrink
w := httptest.NewRecorder()
r := requestAs(t, usr, "POST", fmt.Sprintf("/admin/users/organizations/%s/trial", org.ExternalID), strings.NewReader("remaining=29"))
r := requestAs(t, usr, "POST", fmt.Sprintf("/admin/users/organizations/%s/trial", org.ExternalID), strings.NewReader("remaining=9"))
r.Header.Set("Content-Type", "application/x-www-form-urlencoded")
app.ServeHTTP(w, r)
assert.Equal(t, http.StatusFound, w.Code)

org, err := database.FindOrganizationByID(context.TODO(), org.ExternalID)
assert.NoError(t, err)
assert.Equal(t, 30, org.TrialRemaining())
assert.Equal(t, 14, org.TrialRemaining())
}
{ // but can expand
w := httptest.NewRecorder()
Expand Down
4 changes: 2 additions & 2 deletions users/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
const (
// TrialExtensionDuration is the extension period if billing is
// enabled for an existing customer
TrialExtensionDuration = 15 * 24 * time.Hour
TrialExtensionDuration = 7 * 24 * time.Hour

// TrialRefuseDataUploadAfter is the period after the trial expired before an
// instance's data upload is restricted.
TrialRefuseDataUploadAfter = 15 * 24 * time.Hour
TrialRefuseDataUploadAfter = 7 * 24 * time.Hour

defaultTeamNameTemplate = "%v Team"
)
Expand Down
2 changes: 1 addition & 1 deletion users/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

// TrialDuration is how long a user has a free trial
// period before we start charging for it.
const TrialDuration = 30 * 24 * time.Hour
const TrialDuration = 14 * 24 * time.Hour

// FindUserByIDer is an interface of just FindUserByID, for loosely coupling
// things to the db.DB
Expand Down

0 comments on commit 8701f18

Please sign in to comment.