Skip to content

Commit 4fd44f4

Browse files
committed
chore/qg-157: добавлено логгирование обработки запроса создания анкеты
1 parent a793272 commit 4fd44f4

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

app/src/main/kotlin/pro/qyoga/app/publc/surverys/ProcessSurveyOp.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package pro.qyoga.app.publc.surverys
22

3+
import org.slf4j.LoggerFactory
34
import org.springframework.stereotype.Component
45
import org.springframework.transaction.annotation.Transactional
56
import pro.qyoga.core.clients.cards.ClientsRepo
67
import pro.qyoga.core.clients.cards.findByPhone
78
import pro.qyoga.core.clients.cards.model.PhoneNumber
9+
import pro.qyoga.core.clients.cards.model.toLogString
810
import pro.qyoga.core.survey_forms.settings.model.SurveyFormsSettingsRepo
911
import pro.qyoga.core.survey_forms.settings.model.findByYandexAdminEmail
1012
import java.time.LocalDate
@@ -16,15 +18,24 @@ class ProcessSurveyOp(
1618
private val surveyFormsSettingsRepo: SurveyFormsSettingsRepo
1719
) : (SurveyRq) -> Unit {
1820

21+
private val log = LoggerFactory.getLogger(javaClass)
22+
1923
@Transactional
2024
override operator fun invoke(surveyRq: SurveyRq) {
25+
log.debug("Processing survey: {}", surveyRq)
2126
val therapistRef = surveyFormsSettingsRepo.findByYandexAdminEmail(surveyRq.yandexAdminEmail)
2227
?.therapistRef
2328
?: throw InvalidSurveyException.surveySettingsNotFoundForAdminEmail()
2429

2530
var client = clientsRepo.findByPhone(therapistRef, PhoneNumber.of(surveyRq.survey.phone))
2631
?: surveyRq.survey.toClient(therapistRef)
2732

33+
if (client.version > 0) {
34+
log.info("Updating client: {} from survey", client.toLogString())
35+
} else {
36+
log.info("Creating client: {} from survey", client.toLogString())
37+
}
38+
2839
val today = LocalDate.now()
2940
client = client
3041
.prependComplaints(formatComplaintsEntry(surveyRq, today))

app/src/main/kotlin/pro/qyoga/core/clients/cards/model/Client.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,7 @@ private fun prependTextBlock(value: String?, base: String?): String? {
6363
}
6464

6565
return value.trimEnd('\n') + "\n\n" + base
66-
}
66+
}
67+
68+
fun Client.toLogString() =
69+
"$lastName $firstName ($id)"

0 commit comments

Comments
 (0)