File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
components/usage/pkg/stripe Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ package stripe
7
7
import (
8
8
"encoding/json"
9
9
"fmt"
10
+ "math"
10
11
"os"
11
12
"strings"
12
13
@@ -111,6 +112,7 @@ func queriesForCustomersWithTeamIds(teamIds []string) []string {
111
112
}
112
113
113
114
// workspaceSecondsToCredits converts seconds (of workspace usage) into Stripe credits.
115
+ // (1 credit = 6 minutes, rounded up)
114
116
func workspaceSecondsToCredits (seconds int64 ) int64 {
115
- return ( seconds + 59 ) / 60
117
+ return int64 ( math . Ceil ( float64 ( seconds ) / ( 60 * 6 )))
116
118
}
Original file line number Diff line number Diff line change @@ -105,20 +105,25 @@ func TestWorkspaceSecondsToCreditsCalcuation(t *testing.T) {
105
105
Seconds : 60 ,
106
106
ExpectedCredits : 1 ,
107
107
},
108
- {
109
- Name : "61 seconds" ,
110
- Seconds : 61 ,
111
- ExpectedCredits : 2 ,
112
- },
113
108
{
114
109
Name : "90 seconds" ,
115
110
Seconds : 90 ,
111
+ ExpectedCredits : 1 ,
112
+ },
113
+ {
114
+ Name : "6 minutes" ,
115
+ Seconds : 360 ,
116
+ ExpectedCredits : 1 ,
117
+ },
118
+ {
119
+ Name : "6 minutes and 1 second" ,
120
+ Seconds : 361 ,
116
121
ExpectedCredits : 2 ,
117
122
},
118
123
{
119
124
Name : "1 hour" ,
120
125
Seconds : 3600 ,
121
- ExpectedCredits : 60 ,
126
+ ExpectedCredits : 10 ,
122
127
},
123
128
}
124
129
You can’t perform that action at this time.
0 commit comments