Skip to content

Commit

Permalink
removed daysRemaining
Browse files Browse the repository at this point in the history
  • Loading branch information
sbryzak committed Jun 27, 2024
1 parent 9912c3d commit 3eed976
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 17 deletions.
9 changes: 0 additions & 9 deletions pkg/signup/service/signup_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package service

import (
"fmt"
"github.com/codeready-toolchain/registration-service/pkg/util"
"hash/crc32"
"math"
"regexp"
"strings"
"time"
Expand Down Expand Up @@ -462,13 +460,6 @@ func (s *ServiceImpl) DoGetSignup(ctx *gin.Context, provider ResourceProvider, u

if !userSignup.Status.ScheduledDeactivationTimestamp.IsZero() {
signupResponse.EndDate = userSignup.Status.ScheduledDeactivationTimestamp.Format(time.RFC3339)
remaining := time.Until(userSignup.Status.ScheduledDeactivationTimestamp.Time)
// Round the days remaining to 2 decimal points
signupResponse.DaysRemaining = util.Ptr(math.Round(remaining.Hours()/24*100) / 100)
// If for whatever reason the days remaining is negative, set it to zero
if *signupResponse.DaysRemaining < float64(0) {
signupResponse.DaysRemaining = util.Ptr(float64(0))
}
}

// If UserSignup status is complete as active
Expand Down
4 changes: 0 additions & 4 deletions pkg/signup/service/signup_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1161,8 +1161,6 @@ func (s *TestSignupServiceSuite) TestGetSignupStatusOK() {
require.Equal(t, us.Name, response.Name)
require.Equal(t, "jsmith", response.Username)
require.Equal(t, "ted", response.CompliantUsername)
require.NotNil(t, response.DaysRemaining)
require.InEpsilon(t, float64(30), *response.DaysRemaining, 0.1)
require.Equal(t, mur.Status.ProvisionedTime.Format(time.RFC3339), response.StartDate)
require.Equal(t, us.Status.ScheduledDeactivationTimestamp.Format(time.RFC3339), response.EndDate)
assert.True(t, response.Status.Ready)
Expand Down Expand Up @@ -1291,8 +1289,6 @@ func (s *TestSignupServiceSuite) TestGetSignupByUsernameOK() {
require.WithinDuration(s.T(), expectedEndDate, responseEndDate, time.Minute*5,
"endDate in response [%s] not in expected range [%s]", responseEndDate, expectedEndDate.Format(time.RFC3339))

// DaysRemaining should be zero
require.InDelta(s.T(), float64(0), *response.DaysRemaining, 0)
require.Equal(s.T(), us.Name, response.Name)
require.Equal(s.T(), "jsmith", response.Username)
require.Equal(s.T(), "ted", response.CompliantUsername)
Expand Down
4 changes: 0 additions & 4 deletions pkg/signup/signup.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ type Signup struct {
StartDate string `json:"startDate,omitempty"`
// End Date is the date that the user's current subscription will end, in RFC3339 format
EndDate string `json:"endDate,omitempty"`
// DaysRemaining is a float pointer representing the number of days remaining in the user's subscription
// If the subscription is not currently active then this property should be nil and therefore shouldn't be returned
// in the response
DaysRemaining *float64 `json:"daysRemaining,omitempty"`
}

// Status represents UserSignup resource status
Expand Down

0 comments on commit 3eed976

Please sign in to comment.