From d4b906232c7a5ae2a38d2b3919c00266de7c8c29 Mon Sep 17 00:00:00 2001 From: lfg2 Date: Wed, 12 Jun 2024 17:05:42 +0000 Subject: [PATCH 1/3] feat:CheckHodlStatus --- backend/quests/status.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/quests/status.go b/backend/quests/status.go index 096b58e1..85263dce 100644 --- a/backend/quests/status.go +++ b/backend/quests/status.go @@ -29,8 +29,16 @@ func CheckAuthorityStatus(q *Quest, user string) (progress int, needed int) { } func CheckHodlStatus(q *Quest, user string) (progress int, needed int) { - // TODO: Implement this - return 0, 1 + extra_pixel_amount, err := core.PostgresQueryOne[int]("SELECT COUNT(*) FROM ExtraPixels WHERE address = $1", user) + + if err != nil { + return 0, 1 + } + if *extra_pixel_amount < 10 { + return 0, 1 + } + + return 1, 1 } func CheckNftStatus(q *Quest, user string) (progress int, needed int) { From 90ff404fff60daa4486314eca497bd3ccb5559b4 Mon Sep 17 00:00:00 2001 From: lfg2 Date: Thu, 13 Jun 2024 09:47:36 +0800 Subject: [PATCH 2/3] fix --- backend/quests/status.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/backend/quests/status.go b/backend/quests/status.go index 85263dce..165837ec 100644 --- a/backend/quests/status.go +++ b/backend/quests/status.go @@ -29,16 +29,13 @@ func CheckAuthorityStatus(q *Quest, user string) (progress int, needed int) { } func CheckHodlStatus(q *Quest, user string) (progress int, needed int) { - extra_pixel_amount, err := core.PostgresQueryOne[int]("SELECT COUNT(*) FROM ExtraPixels WHERE address = $1", user) + needed = q.GetInputData()[0] + available_amount, err := core.PostgresQueryOne[int]("SELECT available FROM ExtraPixels WHERE address = $1", user) if err != nil { - return 0, 1 - } - if *extra_pixel_amount < 10 { - return 0, 1 + return 0, needed } - - return 1, 1 + return *available_amount, needed } func CheckNftStatus(q *Quest, user string) (progress int, needed int) { From b204135f8b8a7286f5c2a10e5008d9713dc654c2 Mon Sep 17 00:00:00 2001 From: Brandon Roberts Date: Fri, 21 Jun 2024 10:06:15 -0500 Subject: [PATCH 3/3] Add input type for hodl quest backend --- backend/quests/inputs.go | 10 ++++++++++ backend/quests/status.go | 8 ++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/quests/inputs.go b/backend/quests/inputs.go index d5d0097a..4406d59b 100644 --- a/backend/quests/inputs.go +++ b/backend/quests/inputs.go @@ -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]), @@ -27,3 +31,9 @@ func NewVoteQuestInputs(encodedInputs []int) *VoteQuestInputs { DayIndex: uint32(encodedInputs[0]), } } + +func NewHodlQuestInputs(encodedInputs []int) *HodlQuestInputs { + return &HodlQuestInputs{ + Amount: encodedInputs[0], + } +} diff --git a/backend/quests/status.go b/backend/quests/status.go index 165837ec..ca012b22 100644 --- a/backend/quests/status.go +++ b/backend/quests/status.go @@ -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) {