debug: gigachat won't create questions
This commit is contained in:
parent
ae22c06c3a
commit
00d607cd18
@ -8,19 +8,19 @@ on:
|
||||
|
||||
jobs:
|
||||
CreateImage:
|
||||
runs-on: [hubstaging]
|
||||
runs-on: [squizstaging]
|
||||
uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/build-image.yml@v1.1.6-p
|
||||
with:
|
||||
runner: hubstaging
|
||||
runner: squizstaging
|
||||
secrets:
|
||||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
DeployService:
|
||||
runs-on: [hubstaging]
|
||||
runs-on: [squizstaging]
|
||||
needs: CreateImage
|
||||
uses: http://gitea.pena/PenaDevops/actions.git/.gitea/workflows/deploy.yml@v1.1.4-p7
|
||||
with:
|
||||
runner: hubstaging
|
||||
runner: squizstaging
|
||||
actionid: ${{ gitea.run_id }}
|
||||
|
||||
|
||||
|
@ -104,11 +104,9 @@ func (w *SendToClient) processPendingAnswer(ctx context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println("ANS")
|
||||
|
||||
for _, key := range pendingAnswers {
|
||||
func() {
|
||||
fmt.Println("ANS1", key)
|
||||
answerJSON, err := w.redis.GetDel(ctx, key).Result()
|
||||
if err == redis.Nil {
|
||||
return
|
||||
@ -120,28 +118,24 @@ func (w *SendToClient) processPendingAnswer(ctx context.Context) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
w.reportError(nil, fmt.Sprintf("recovering from panic or error setting redis value %v", r))
|
||||
fmt.Println("ANS1ERRR", r)
|
||||
_ = w.redis.Set(ctx, key, answerJSON, 0).Err()
|
||||
}
|
||||
}()
|
||||
|
||||
var answer model.Answer
|
||||
err = json.Unmarshal([]byte(answerJSON), &answer)
|
||||
fmt.Println("ANS2", err)
|
||||
if err != nil {
|
||||
w.reportError(err, "Error unmarshal answer")
|
||||
return
|
||||
}
|
||||
|
||||
answerContent, err := wctools.ProcessAnswer(answer.Content)
|
||||
fmt.Println("ANS3", err)
|
||||
if err != nil {
|
||||
w.reportError(err, "Error unmarshal answer content")
|
||||
return
|
||||
}
|
||||
|
||||
allAnswersDirty, err := w.dal.WorkerAnsRepo.GetAllAnswersByQuizID(ctx, answer.Session)
|
||||
fmt.Println("ANS4", err)
|
||||
if err != nil {
|
||||
w.reportError(err, "Error getting all answers by quizID")
|
||||
return
|
||||
@ -149,7 +143,6 @@ func (w *SendToClient) processPendingAnswer(ctx context.Context) {
|
||||
allAnswers := wctools.CleanNullContent(allAnswersDirty)
|
||||
|
||||
questionsMap, sortedallAnswers, err := w.dal.QuestionRepo.GetMapQuestions(ctx, allAnswers)
|
||||
fmt.Println("ANS5", err)
|
||||
if err != nil {
|
||||
w.reportError(err, "Error getting questionsMap")
|
||||
return
|
||||
@ -160,14 +153,12 @@ func (w *SendToClient) processPendingAnswer(ctx context.Context) {
|
||||
}
|
||||
|
||||
quizConfig, accountId, err := w.dal.QuizRepo.GetQuizConfig(ctx, answer.QuizId)
|
||||
fmt.Println("ANS6", err)
|
||||
if err != nil {
|
||||
w.reportError(err, "Error getting quiz config")
|
||||
return
|
||||
}
|
||||
|
||||
quiz, err := w.dal.QuizRepo.GetQuizById(ctx, accountId, answer.QuizId)
|
||||
fmt.Println("ANS60", err, accountId, answer.QuizId)
|
||||
if err != nil {
|
||||
w.reportError(err, "Error getting quiz")
|
||||
return
|
||||
@ -180,7 +171,6 @@ func (w *SendToClient) processPendingAnswer(ctx context.Context) {
|
||||
}
|
||||
|
||||
account, privileges, err := w.dal.AccountRepo.GetAccAndPrivilegeByEmail(ctx, accountId)
|
||||
fmt.Println("ANS7", err)
|
||||
if err != nil {
|
||||
w.reportError(err, "Error getting account and privileges by email")
|
||||
return
|
||||
@ -196,7 +186,6 @@ func (w *SendToClient) processPendingAnswer(ctx context.Context) {
|
||||
answerContent: answerContent,
|
||||
answerTime: answer.CreatedAt,
|
||||
})
|
||||
fmt.Println("ANS8", err, result, privileges)
|
||||
if err != nil {
|
||||
w.reportError(err, "Error process answer with privileges")
|
||||
return
|
||||
@ -226,7 +215,6 @@ type ProcessAnsWithPriv struct {
|
||||
func (w *SendToClient) processAnswerWithPrivileges(ctx context.Context, data ProcessAnsWithPriv) (bool, error) {
|
||||
|
||||
err := w.notificationCustomer(ctx, data.account, data.privileges)
|
||||
fmt.Println("ANS81", err)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"github.com/go-resty/resty/v2"
|
||||
"go.uber.org/zap"
|
||||
"time"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var zapOptions = []zap.Option{
|
||||
@ -153,6 +154,7 @@ func New(ctx context.Context, cfg initialize.Config, build Build) error {
|
||||
// метод для обновления токенов гигачата
|
||||
go gigaChatClient.TokenResearch(ctx)
|
||||
|
||||
fmt.Println("INIT GGC WORKER", cfg.KafkaTopicGigaChat)
|
||||
gigaChatWorker, err := gigachatwc.NewGigaChatTaskScheduler(gigachatwc.Deps{
|
||||
KafkaBrokers: cfg.KafkaBrokers,
|
||||
KafkaTopic: cfg.KafkaTopicGigaChat,
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"github.com/twmb/franz-go/pkg/kgo"
|
||||
"go.uber.org/zap"
|
||||
"time"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type GigaChatTaskScheduler struct {
|
||||
@ -66,6 +67,7 @@ func (r *GigaChatTaskScheduler) Start(ctx context.Context) {
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
fmt.Println("FETCHED GGC")
|
||||
r.fetchMessages(ctx)
|
||||
case <-ctx.Done():
|
||||
return
|
||||
@ -85,6 +87,7 @@ func (r *GigaChatTaskScheduler) fetchMessages(ctx context.Context) {
|
||||
r.logger.Error("failed to unmarshal kafka message", zap.ByteString("value", record.Value), zap.Error(err))
|
||||
continue
|
||||
}
|
||||
fmt.Println("GGC MES", msg)
|
||||
|
||||
r.handleMessage(ctx, msg)
|
||||
}
|
||||
@ -113,6 +116,7 @@ func (r *GigaChatTaskScheduler) handleMessage(ctx context.Context, msg MessageGi
|
||||
// можем ли мы скипать вопросы с которыми у нас произошла ошибка
|
||||
for i := 0; i < 10; i++ {
|
||||
updJson, err = r.gigaChatClient.SendMsg(ctx, audience, question)
|
||||
fmt.Println("GGC ANS", updJson, err)
|
||||
if err == nil {
|
||||
if err = json.Unmarshal([]byte(updJson), &resp); err == nil {
|
||||
question.Title = resp.Title
|
||||
|
@ -44,7 +44,6 @@ func (w *CheckWorker) Start(ctx context.Context) {
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
fmt.Println("CHECK")
|
||||
w.deleteExpired(ctx)
|
||||
case <-ctx.Done():
|
||||
fmt.Println("Check worker terminated")
|
||||
|
@ -3,7 +3,6 @@ package shortstat
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"gitea.pena/SQuiz/common/dal"
|
||||
"gitea.pena/SQuiz/worker/internal/workers"
|
||||
"time"
|
||||
@ -26,9 +25,7 @@ func New(d *dal.DAL, p time.Duration) *ShortStat {
|
||||
// Start method for starting worker with long polling from postgres
|
||||
func (t *ShortStat) Start(ctx context.Context) {
|
||||
t.w.Start(ctx, func(ctx context.Context) error {
|
||||
fmt.Println("SHORTSTAT1")
|
||||
if err := t.d.WorkerRepo.WorkerStatProcess(ctx); err != nil {
|
||||
fmt.Println("SHORTSTAT2", err)
|
||||
if err != sql.ErrNoRows {
|
||||
return err
|
||||
}
|
||||
|
BIN
main
BIN
main
Binary file not shown.
Loading…
Reference in New Issue
Block a user