[CLD-6536] Adjustments to cloud annual renewal announcement bar (#25927)
* Adjustments to cloud annual renewal announcement bar * Add exclusion for trials * Add more exceptions for when on trial during renewal period * Add support for simulated_current_time_ms * A few more changes to allow us to test this post-merge * Fix tests, pipeline * Final fix around emails --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
@@ -5,8 +5,6 @@ package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@@ -185,17 +183,16 @@ type Subscription struct {
|
||||
BillingType string `json:"billing_type"`
|
||||
CancelAt *int64 `json:"cancel_at"`
|
||||
WillRenew string `json:"will_renew"`
|
||||
SimulatedCurrentTimeMs *int64 `json:"simulated_current_time_ms"`
|
||||
}
|
||||
|
||||
func (s *Subscription) DaysToExpiration() int64 {
|
||||
now := time.Now().UnixMilli()
|
||||
// Allows us to base the current time off of an environment variable for testing purposes
|
||||
if GetServiceEnvironment() == ServiceEnvironmentTest {
|
||||
if currTime, set := os.LookupEnv("CLOUD_MOCK_CURRENT_TIME"); set {
|
||||
timeInt, err := strconv.ParseInt(currTime, 10, 64)
|
||||
if err == nil {
|
||||
now = time.Unix(timeInt, 0).UnixMilli()
|
||||
}
|
||||
// In the test environment we have test clocks. A test clock is a ms timestamp
|
||||
// If it's not nil, we use it as the current time in all calculations
|
||||
if s.SimulatedCurrentTimeMs != nil {
|
||||
now = *s.SimulatedCurrentTimeMs
|
||||
}
|
||||
}
|
||||
daysToExpiry := (s.EndAt - now) / (1000 * 60 * 60 * 24)
|
||||
|
||||
Ссылка в новой задаче
Block a user