Skip to content

Commit

Permalink
SI-2624-req-vin-confirmed (#113)
Browse files Browse the repository at this point in the history
* reward eligibility requires confirmed vin

* Add buildx to build jobs

* casing; swagger

* linter

* Fresh linter slate

* Fix the job too

* Update jobs

* Delete weird orphaned Workflow folder

---------

Co-authored-by: Dylan Moreland <dylan@dimo.zone>
  • Loading branch information
Allyson-English and elffjs authored May 16, 2024
1 parent 4e9afa5 commit d2dd6aa
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 24 deletions.
1 change: 0 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ jobs:
with:
version: latest
only-new-issues: false
args: --modules-download-mode=readonly -E prealloc -E revive -E goimports -E deadcode -E errcheck -E gosimple -E govet -E ineffassign -E staticcheck -E structcheck -E typecheck -E unused -E varcheck --timeout=5m
20 changes: 5 additions & 15 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
run:
timeout: 5m
linters:
enable:
- prealloc
- revive
- goimports
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck

issues:
fix: true

linters-settings: {}
10 changes: 8 additions & 2 deletions docs/docs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package docs GENERATED BY SWAG; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2023-03-28 09:07:04.575621 -0600 MDT m=+34.147678501
// 2024-05-09 07:49:17.086978 -0400 EDT m=+1.206332168
package docs

import "github.com/swaggo/swag"
Expand Down Expand Up @@ -97,7 +97,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/internal_controllers.TransactionHistory"
"$ref": "#/definitions/github.com_DIMO-Network_rewards-api_internal_controllers.TransactionHistory"
}
}
}
Expand Down Expand Up @@ -326,6 +326,9 @@ const docTemplate = `{
"description": "Tokens is the total number of tokens that the device has earned across all weeks.",
"type": "number",
"example": 5000
},
"vinConfirmed": {
"type": "boolean"
}
}
},
Expand Down Expand Up @@ -605,6 +608,9 @@ const docTemplate = `{
"description": "Tokens is the total number of tokens that the device has earned across all weeks.",
"type": "number",
"example": 5000
},
"vinConfirmed": {
"type": "boolean"
}
}
},
Expand Down
8 changes: 7 additions & 1 deletion docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/internal_controllers.TransactionHistory"
"$ref": "#/definitions/github.com_DIMO-Network_rewards-api_internal_controllers.TransactionHistory"
}
}
}
Expand Down Expand Up @@ -316,6 +316,9 @@
"description": "Tokens is the total number of tokens that the device has earned across all weeks.",
"type": "number",
"example": 5000
},
"vinConfirmed": {
"type": "boolean"
}
}
},
Expand Down Expand Up @@ -595,6 +598,9 @@
"description": "Tokens is the total number of tokens that the device has earned across all weeks.",
"type": "number",
"example": 5000
},
"vinConfirmed": {
"type": "boolean"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ definitions:
across all weeks.
example: 5000
type: number
vinConfirmed:
type: boolean
type: object
github.com_DIMO-Network_rewards-api_internal_controllers.UserResponseIntegration:
properties:
Expand Down Expand Up @@ -419,6 +421,8 @@ definitions:
across all weeks.
example: 5000
type: number
vinConfirmed:
type: boolean
type: object
internal_controllers.UserResponseIntegration:
properties:
Expand Down Expand Up @@ -534,7 +538,7 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/internal_controllers.TransactionHistory'
$ref: '#/definitions/github.com_DIMO-Network_rewards-api_internal_controllers.TransactionHistory'
security:
- BearerAuth: []
/user/referrals:
Expand Down
10 changes: 6 additions & 4 deletions internal/controllers/rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (r *RewardsController) GetUserRewards(c *fiber.Ctx) error {
OnChainPairingStatus: "Paired",
}

if vehicleMinted && integSignalsThisWeek.Contains(integr.Id) {
if device.VinConfirmed && vehicleMinted && integSignalsThisWeek.Contains(integr.Id) {
uri.Points = int(integr.Points)
uri.DataThisWeek = true
}
Expand All @@ -168,7 +168,7 @@ func (r *RewardsController) GetUserRewards(c *fiber.Ctx) error {
OnChainPairingStatus: "Paired",
}

if vehicleMinted && integSignalsThisWeek.Contains(integr.Id) {
if device.VinConfirmed && vehicleMinted && integSignalsThisWeek.Contains(integr.Id) {
uri.Points = int(integr.Points)
uri.DataThisWeek = true
}
Expand Down Expand Up @@ -223,8 +223,9 @@ func (r *RewardsController) GetUserRewards(c *fiber.Ctx) error {
ConnectionStreak: connectionStreak,
DisconnectionStreak: disconnectionStreak,
Level: *getLevelResp(lvl),
Minted: device.TokenId != nil,
Minted: vehicleMinted,
OptedIn: true,
VINConfirmed: device.VinConfirmed,
}
}

Expand Down Expand Up @@ -299,7 +300,8 @@ type UserResponseDevice struct {
// Minted is true if the device has been minted on-chain.
Minted bool `json:"minted"`
// OptedIn is true if the user has agreed to the terms of service.
OptedIn bool `json:"optedIn"`
OptedIn bool `json:"optedIn"`
VINConfirmed bool `json:"vinConfirmed"`
}

type UserResponseThisWeek struct {
Expand Down
5 changes: 5 additions & 0 deletions internal/services/rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ func (t *BaselineClient) assignPoints() error {
continue
}

if !ud.VinConfirmed {
logger.Info().Msg("Device does not have confirmed VIN.")
continue
}

if len(ud.OwnerAddress) != 20 {
logger.Info().Msg("User has minted a car but has no owner address?")
continue
Expand Down
1 change: 1 addition & 0 deletions internal/services/rewards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,7 @@ func (d *FakeDevClient) GetUserDevice(_ context.Context, in *pb_devices.GetUserD
Id: ud.ID,
TokenId: tk,
Vin: vin,
VinConfirmed: vin != nil,
OwnerAddress: owner,
}

Expand Down

0 comments on commit d2dd6aa

Please sign in to comment.