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

Commite9f1aa9

Browse files
committed
make entitlement weight a method on the enum
1 parent41c2726 commite9f1aa9

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
@@ -35,9 +35,9 @@ const (
3535
EntitlementNotEntitledEntitlement="not_entitled"
3636
)
3737

38-
//entitlementWeight converts the enum types to a numerical value for easier
38+
//Weight converts the enum types to a numerical value for easier
3939
// comparisons. Easier than sets of if statements.
40-
funcentitlementWeight(eEntitlement)int {
40+
func (eEntitlement)Weight()int {
4141
switche {
4242
caseEntitlementEntitled:
4343
return2
@@ -194,7 +194,7 @@ func CompareFeatures(a, b Feature) int {
194194
// feature can be "greater" than an entitled.
195195
// If either is "NotEntitled" then we can defer to a strict entitlement
196196
// check.
197-
ifentitlementWeight(a.Entitlement)>=0&&entitlementWeight(b.Entitlement)>=0 {
197+
ifa.Entitlement.Weight()>=0&&b.Entitlement.Weight()>=0 {
198198
ifa.Capable()&&!b.Capable() {
199199
return1
200200
}
@@ -205,7 +205,7 @@ func CompareFeatures(a, b Feature) int {
205205
}
206206

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp