Skip to content

Commit

Permalink
constraint_added_for_creating_exam
Browse files Browse the repository at this point in the history
  • Loading branch information
golanguzb71 committed Oct 27, 2024
1 parent fb5e308 commit b4b8965
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion auth-service/internal/telegram/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func sendWelcome(message *tgbotapi.Message) {
🇺🇿
Salom %s 👋
CodeVan servicega xush kelibsiz
examify.uz ro'yxatdan o'tish uchun ⬇️kontaktingizni yuboring va 1 daqiqalik kalitingizni oling!
examify.uz ro'yxatdan o'tish uchun ⬇️ kontaktingizni yuboring va 1 daqiqalik kalitingizni oling!
🇺🇸
Hi %s 👋
Expand Down
26 changes: 13 additions & 13 deletions ielts-service/internal/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,23 +171,23 @@ func (r *PostgresRepository) GetAnswerByBookId(bookId string) ([]models.Answer,

func (r *PostgresRepository) CreateExam(userID, bookID int32) (*string, error) {
var count int
//var chatId string
_ = r.db.QueryRow(`SELECT count(*)
var chatId string
err := r.db.QueryRow(`SELECT count(*)
FROM exam
WHERE user_id = $1
AND DATE(created_at) = CURRENT_DATE`, userID).Scan(&count)

//if err != nil || count >= 2 {
// err = r.db.QueryRow(`SELECT chat_id FROM users where id=$1`, userID).Scan(&chatId)
// if err != nil {
// return nil, err
// }
// response := r.bonusClient.CreateAttemptBonus(chatId)
// if response {
// return createExam(r.db, userID, bookID)
// }
// return nil, errors.New("you can create exam 2 times in a day")
//}
if err != nil || count >= 2 {
err = r.db.QueryRow(`SELECT chat_id FROM users where id=$1`, userID).Scan(&chatId)
if err != nil {
return nil, err
}
response := r.bonusClient.CreateAttemptBonus(chatId)
if response {
return createExam(r.db, userID, bookID)
}
return nil, errors.New("you can create exam 2 times in a day")
}
return createExam(r.db, userID, bookID)

}
Expand Down

0 comments on commit b4b8965

Please sign in to comment.