Skip to content

Commit

Permalink
Add input type for hodl quest backend
Browse files Browse the repository at this point in the history
  • Loading branch information
b-j-roberts committed Jun 21, 2024
1 parent 90ff404 commit b204135
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions backend/quests/inputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ type VoteQuestInputs struct {
DayIndex uint32
}

type HodlQuestInputs struct {
Amount int
}

func NewPixelQuestInputs(encodedInputs []int) *PixelQuestInputs {
return &PixelQuestInputs{
PixelsNeeded: uint32(encodedInputs[0]),
Expand All @@ -27,3 +31,9 @@ func NewVoteQuestInputs(encodedInputs []int) *VoteQuestInputs {
DayIndex: uint32(encodedInputs[0]),
}
}

func NewHodlQuestInputs(encodedInputs []int) *HodlQuestInputs {
return &HodlQuestInputs{
Amount: encodedInputs[0],
}
}
8 changes: 4 additions & 4 deletions backend/quests/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ func CheckAuthorityStatus(q *Quest, user string) (progress int, needed int) {
}

func CheckHodlStatus(q *Quest, user string) (progress int, needed int) {
needed = q.GetInputData()[0]
available_amount, err := core.PostgresQueryOne[int]("SELECT available FROM ExtraPixels WHERE address = $1", user)
hodlQuestInputs := NewHodlQuestInputs(q.InputData)
available, err := core.PostgresQueryOne[int]("SELECT available FROM ExtraPixels WHERE address = $1", user)

if err != nil {
return 0, needed
return 0, hodlQuestInputs.Amount
}
return *available_amount, needed
return *available, hodlQuestInputs.Amount
}

func CheckNftStatus(q *Quest, user string) (progress int, needed int) {
Expand Down

0 comments on commit b204135

Please sign in to comment.