Skip to content

Commit

Permalink
Proper fix for rating change check (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raajheer1 authored Dec 1, 2024
1 parent f961c5b commit 394a98c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/v1/user/visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,21 @@ func isEligibleVisiting(user *models.User) bool {
return false
}

// Ignore rating change date if current rating is C3, I1, I3
if user.RatingID != 7 && user.RatingID != 8 && user.RatingID != 10 {
ratechange, err := vatsim.GetDateOfRatingChange(fmt.Sprint(user.CID))
if err != nil {
log.Errorf("Error getting date of rating change: %s", err)
return false
}
// Check that ratechange is more than 90 days ago
// VATSIM API apparently returns nil if it was a long time ago... so we can assume this check is true
// VATUSA only knows about controllers whose rating is changed by VATUSA, so we enforce this by also checking VATSIM
if ratechange != nil && ratechange.After(time.Now().AddDate(0, 0, -90)) {
return false
}
}

// Check VATUSA eligibility
eligible, _, err := vatusa.IsVisitorEligible(fmt.Sprint(user.CID))
if err != nil {
Expand Down

0 comments on commit 394a98c

Please sign in to comment.