Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite06b434

Browse files
committed
make entitlement weight a method on the enum
1 parent7436159 commite06b434

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎codersdk/deployment.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ const (
3434
EntitlementNotEntitledEntitlement="not_entitled"
3535
)
3636

37-
//entitlementWeight converts the enum types to a numerical value for easier
37+
//Weight converts the enum types to a numerical value for easier
3838
// comparisons. Easier than sets of if statements.
39-
funcentitlementWeight(eEntitlement)int {
39+
func (eEntitlement)Weight()int {
4040
switche {
4141
caseEntitlementEntitled:
4242
return2
@@ -193,7 +193,7 @@ func CompareFeatures(a, b Feature) int {
193193
// feature can be "greater" than an entitled.
194194
// If either is "NotEntitled" then we can defer to a strict entitlement
195195
// check.
196-
ifentitlementWeight(a.Entitlement)>=0&&entitlementWeight(b.Entitlement)>=0 {
196+
ifa.Entitlement.Weight()>=0&&b.Entitlement.Weight()>=0 {
197197
ifa.Capable()&&!b.Capable() {
198198
return1
199199
}
@@ -204,7 +204,7 @@ func CompareFeatures(a, b Feature) int {
204204
}
205205

206206
// Strict entitlement check. Higher is better
207-
entitlementDifference:=entitlementWeight(a.Entitlement)-entitlementWeight(b.Entitlement)
207+
entitlementDifference:=a.Entitlement.Weight()-b.Entitlement.Weight()
208208
ifentitlementDifference!=0 {
209209
returnentitlementDifference
210210
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp