Skip to content

Commit 608a351

Browse files
authored
Merge pull request #22 from ppolariss/main
chore: debug question
2 parents 1965872 + 480c7a0 commit 608a351

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

apis/cache.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ LOAD_FILES:
227227
GlobalQuestionConfig.Lock()
228228
GlobalQuestionConfig.Questions = newQuestions
229229
GlobalQuestionConfig.CurrentVersion = newQuestionCurrentVersion
230+
jsonQuestions, _ := json.Marshal(GlobalQuestionConfig.Questions)
231+
log.Debug().Msgf("questionsResponse: %s", string(jsonQuestions))
230232
GlobalQuestionConfig.Unlock()
231233

232234
return nil

apis/question.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package apis
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"sort"
67

8+
. "auth_next/models"
9+
710
"github.com/gofiber/fiber/v2"
811
"github.com/opentreehole/go-common"
12+
"github.com/rs/zerolog/log"
913
"golang.org/x/exp/rand"
1014
"golang.org/x/exp/slices"
11-
12-
. "auth_next/models"
1315
)
1416

1517
// RetrieveQuestions godoc
@@ -128,8 +130,6 @@ func RetrieveQuestions(c *fiber.Ctx) (err error) {
128130
tmpQuestions = append(tmpQuestions, chosenCampusQuestions[:numberOfCampusQuestions]...)
129131
}
130132

131-
132-
133133
if !inOrder {
134134
rand.Shuffle(len(tmpQuestions), func(i, j int) {
135135
tmpQuestions[i], tmpQuestions[j] = tmpQuestions[j], tmpQuestions[i]
@@ -144,6 +144,9 @@ func RetrieveQuestions(c *fiber.Ctx) (err error) {
144144
questionsResponse.Questions[i] = *question
145145
}
146146

147+
jsonQuestions, _ := json.Marshal(questionsResponse)
148+
log.Debug().Msgf("questionsResponse: %s", string(jsonQuestions))
149+
147150
// shuffle options
148151
for i := range questionsResponse.Questions {
149152
options := questionsResponse.Questions[i].Options // copy slice pointer only
@@ -162,6 +165,9 @@ func RetrieveQuestions(c *fiber.Ctx) (err error) {
162165
questionsResponse.Questions[i].Option = questionsResponse.Questions[i].Options
163166
}
164167

168+
jsonQuestions, _ = json.Marshal(questionsResponse)
169+
log.Debug().Msgf("questionsResponse: %s", string(jsonQuestions))
170+
165171
return c.JSON(questionsResponse)
166172
}
167173

0 commit comments

Comments
 (0)