-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add total number of daily quests completed (#13)
* build: remove swagger on make deploy command * feat: add new query to fetch the total number of daily quests completed and convert compeleted to a boolean
- Loading branch information
1 parent
c6fa98e
commit 07b8bc9
Showing
7 changed files
with
77 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/v1/quests/internal/queries/fetchtotaldailyevents.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package queries | ||
|
||
import ( | ||
"fmt" | ||
"lib/utils" | ||
_types "quests/internal/types" | ||
) | ||
|
||
func FetchTotalDailyEvents(account string, logger *utils.Logger) ([]_types.TotalDailyEvent, error) { | ||
var response _types.PostHogQueryResponse | ||
var result []_types.TotalDailyEvent | ||
|
||
query := fmt.Sprintf(`{"query":{"kind":"HogQLQuery","query":"select events.event as \"event-name\", count(distinct dateTrunc('day', events.timestamp)) AS \"total\" from events where person.pdi.distinct_id = '%s' and events.properties.genesisHash = 'IXnoWtviVVJW5LGivNFc0Dq14V3kqaXuK2u5OQrdVZo=' group by \"event-name\" order by \"event-name\""}}`, account) | ||
err := PostHogQuery(query, &response) | ||
if err != nil { | ||
logger.Error(err) | ||
|
||
return nil, err | ||
} | ||
|
||
for _, value := range response.Results { | ||
result = append(result, _types.TotalDailyEvent{ | ||
Name: value[0].(string), | ||
Total: int(value[1].(float64)), | ||
}) | ||
} | ||
|
||
return result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package types | ||
|
||
type DailyEvent struct { | ||
Amount int | ||
Name string | ||
Completed bool | ||
Name string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package types | ||
|
||
// DailyQuest | ||
// @Description The ID of the quest and the amount of times it has been completed. | ||
// @Description The ID of the quest, whether the quest has been completed today and the total number of daily quests. | ||
type DailyQuest struct { | ||
// The amount of times the quest has been completed | ||
Completed int `json:"completed" example:"22"` | ||
Completed bool `json:"completed" example:"true"` | ||
// The ID of the quest | ||
Id string `json:"id" example:"send-native-currency-action"` | ||
// The total number of daily quests completed | ||
Total int `json:"total" example:"22"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package types | ||
|
||
type TotalDailyEvent struct { | ||
Name string | ||
Total int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters