Skip to content

Commit

Permalink
predict log
Browse files Browse the repository at this point in the history
  • Loading branch information
i.navrotskyj committed Jul 12, 2024
1 parent a8827f3 commit a222b70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
6 changes: 6 additions & 0 deletions queue/attempt.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,12 @@ func (a *Attempt) Log(info string) {
//})
}

func (a *Attempt) LogIfError(err error) {
if err != nil {
wlog.Debug(fmt.Sprintf("attempt [%v] > %s", a.Id(), err.Error()))
}
}

func (a *Attempt) LogsData() []byte {
data, _ := json.Marshal(a)
return data
Expand Down
17 changes: 8 additions & 9 deletions queue/call_predict.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/webitel/call_center/agent_manager"
"github.com/webitel/call_center/call_manager"
"github.com/webitel/call_center/model"
"github.com/webitel/wlog"
"time"
)

Expand Down Expand Up @@ -311,7 +310,7 @@ func (queue *PredictCallQueue) runOfferingAgents(attempt *Attempt, mCall call_ma

attempt.Log("answer & wait agent")
if err = queue.queueManager.AnswerPredictAndFindAgent(attempt.Id()); err != nil {
wlog.Error(err.Error())
attempt.LogIfError(err)
time.Sleep(time.Second * 3)
return
}
Expand Down Expand Up @@ -341,14 +340,14 @@ func (queue *PredictCallQueue) runOfferingAgents(attempt *Attempt, mCall call_ma
calling = false
break
} else {
wlog.Debug(fmt.Sprintf("[%d] change call state to %s", attempt.Id(), c))
attempt.Log(fmt.Sprintf("[%d] change call state to %s", attempt.Id(), c))
}

case <-ags:
agent = attempt.Agent()
team, err = queue.GetTeam(attempt)
if err != nil {
wlog.Error(err.Error())
attempt.LogIfError(err)
time.Sleep(time.Second * 3)
return
}
Expand Down Expand Up @@ -379,7 +378,7 @@ func (queue *PredictCallQueue) runOfferingAgents(attempt *Attempt, mCall call_ma
team.Distribute(queue, agent, NewDistributeEvent(attempt, agent.UserId(), queue, agent, queue.Processing(), mCall, agentCall))
agentCall.Invite()

wlog.Debug(fmt.Sprintf("call [%s] && agent [%s]", mCall.Id(), agentCall.Id()))
attempt.Log(fmt.Sprintf("call [%s] && agent [%s]", mCall.Id(), agentCall.Id()))

top:
for agentCall.HangupCause() == "" && (mCall.HangupCause() == "") {
Expand All @@ -400,7 +399,7 @@ func (queue *PredictCallQueue) runOfferingAgents(attempt *Attempt, mCall call_ma
if agentCall.HangupAt() == 0 {
agentCall.Hangup(model.CALL_HANGUP_LOSE_RACE, false, nil)
}
printfIfErr(err)
attempt.LogIfError(err)
} else {
if queue.AllowGreetingAgent && agent.GreetingMedia() != nil {
mCall.BroadcastPlaybackFile(agent.DomainId(), agent.GreetingMedia(), "both")
Expand All @@ -420,15 +419,15 @@ func (queue *PredictCallQueue) runOfferingAgents(attempt *Attempt, mCall call_ma
if agentCall.TransferTo() != nil && agentCall.TransferToAgentId() != nil && agentCall.TransferFromAttemptId() != nil {
attempt.Log("receive transfer")
if nc, err := queue.GetTransferredCall(*agentCall.TransferTo()); err != nil {
wlog.Error(err.Error())
attempt.LogIfError(err)
} else {
if nc.HangupAt() == 0 {
if newA, err := queue.queueManager.TransferFrom(team, attempt, *agentCall.TransferFromAttemptId(), *agentCall.TransferToAgentId(), *agentCall.TransferTo(), nc); err == nil {
agent = newA
attempt.Log(fmt.Sprintf("transfer call from [%s] to [%s] AGENT_ID = %s {%d, %d}", agentCall.Id(), nc.Id(), newA.Name(), attempt.Id(), *agentCall.TransferFromAttemptId()))
//transferred = true
} else {
wlog.Error(err.Error())
attempt.LogIfError(err)
}

agentCall = nc
Expand Down Expand Up @@ -485,7 +484,7 @@ func (queue *PredictCallQueue) runOfferingAgents(attempt *Attempt, mCall call_ma
}

if agentCall != nil && agentCall.HangupAt() == 0 {
wlog.Warn(fmt.Sprintf("agent call %s no hangup", agentCall.Id()))
attempt.Log(fmt.Sprintf("agent call %s no hangup", agentCall.Id()))
}

if mCall.HangupCause() == "" && (agentCall == nil || !agentCall.Transferred()) {
Expand Down

0 comments on commit a222b70

Please sign in to comment.