Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d66df080fe | |||
| 804b9b2792 | |||
| 3be1e46f69 | |||
| 0122b01037 | |||
| d8d857e82e | |||
| ab6b36c12c | |||
| f69b849ed7 | |||
| 3e103f18a5 | |||
| 746a492cd4 |
@@ -2,12 +2,9 @@ package models
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DBCall struct {
|
type DBCall struct {
|
||||||
gorm.Model
|
|
||||||
AfterCallWorkRequired bool
|
AfterCallWorkRequired bool
|
||||||
Confined bool
|
Confined bool
|
||||||
ConnectedTime *time.Time `gorm:"index"`
|
ConnectedTime *time.Time `gorm:"index"`
|
||||||
|
|||||||
@@ -2,12 +2,9 @@ package models
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DBConversation struct {
|
type DBConversation struct {
|
||||||
gorm.Model
|
|
||||||
Address *string
|
Address *string
|
||||||
DivisionIds *string `gorm:"type:json"`
|
DivisionIds *string `gorm:"type:json"`
|
||||||
End *time.Time `gorm:"index"`
|
End *time.Time `gorm:"index"`
|
||||||
@@ -22,8 +19,11 @@ type DBConversation struct {
|
|||||||
Start *time.Time `gorm:"index"`
|
Start *time.Time `gorm:"index"`
|
||||||
UtilizationLabelId *string
|
UtilizationLabelId *string
|
||||||
LiveUpdate *time.Time
|
LiveUpdate *time.Time
|
||||||
|
DetailsUpdate *time.Time
|
||||||
SemiLiveUpdate *time.Time
|
SemiLiveUpdate *time.Time
|
||||||
JobUpdate *time.Time
|
JobUpdate *time.Time
|
||||||
|
|
||||||
|
Participants []DBParticipant `gorm:"foreignKey:ConversationId;references:Id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (DBConversation) TableName() string {
|
func (DBConversation) TableName() string {
|
||||||
|
|||||||
@@ -2,12 +2,9 @@ package models
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DBParticipant struct {
|
type DBParticipant struct {
|
||||||
gorm.Model
|
|
||||||
Address *string
|
Address *string
|
||||||
Attributes *string `gorm:"type:json"`
|
Attributes *string `gorm:"type:json"`
|
||||||
ConnectedTime *time.Time `gorm:"index"`
|
ConnectedTime *time.Time `gorm:"index"`
|
||||||
@@ -23,6 +20,8 @@ type DBParticipant struct {
|
|||||||
Wrapup *string `gorm:"type:json"`
|
Wrapup *string `gorm:"type:json"`
|
||||||
WrapupExpected *bool
|
WrapupExpected *bool
|
||||||
WrapupRequired *bool
|
WrapupRequired *bool
|
||||||
|
|
||||||
|
Sessions []DBSession `gorm:"foreignKey:ParticipantId;references:Id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (DBParticipant) TableName() string {
|
func (DBParticipant) TableName() string {
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ type DBQueueLog struct {
|
|||||||
ConversationId string `gorm:"primaryKey"`
|
ConversationId string `gorm:"primaryKey"`
|
||||||
Start time.Time `gorm:"index"`
|
Start time.Time `gorm:"index"`
|
||||||
End time.Time `gorm:"index"`
|
End time.Time `gorm:"index"`
|
||||||
Result string `gorm:"type:json"`
|
Duration float64
|
||||||
|
Result string `gorm:"type:json"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (DBQueueLog) TableName() string {
|
func (DBQueueLog) TableName() string {
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
|
type AnalyticsConversationWithAttributesQuery struct {
|
||||||
|
Conversations []AnalyticsConversationWithAttributes `json:"conversations"`
|
||||||
|
Cursor *string `json:"cursor"`
|
||||||
|
}
|
||||||
|
|
||||||
type AnalyticsConversationWithAttributes struct {
|
type AnalyticsConversationWithAttributes struct {
|
||||||
ConversationEnd string `json:"conversationEnd"`
|
ConversationEnd string `json:"conversationEnd"`
|
||||||
ConversationId string `json:"conversationId"`
|
ConversationId string `json:"conversationId"`
|
||||||
@@ -88,6 +93,20 @@ type AnalyticsConversationWithoutAttributes struct {
|
|||||||
Q850ResponseCodes []int `json:"q850ResponseCodes"`
|
Q850ResponseCodes []int `json:"q850ResponseCodes"`
|
||||||
Conference bool `json:"conference"`
|
Conference bool `json:"conference"`
|
||||||
} `json:"segments"`
|
} `json:"segments"`
|
||||||
|
Flow struct {
|
||||||
|
EndingLanguage string `json:"endingLanguage"`
|
||||||
|
EntryReason string `json:"entryReason"`
|
||||||
|
EntryType string `json:"entryType"`
|
||||||
|
ExitReason string `json:"exitReason"`
|
||||||
|
FlowId string `json:"flowId"`
|
||||||
|
FlowName string `json:"flowName"`
|
||||||
|
FlowType string `json:"flowType"`
|
||||||
|
FlowVersion string `json:"flowVersion"`
|
||||||
|
StartingLanguage string `json:"startingLanguage"`
|
||||||
|
TransferTargetAddress string `json:"transferTargetAddress"`
|
||||||
|
TransferTargetName string `json:"transferTargetName"`
|
||||||
|
TransferType string `json:"transferType"`
|
||||||
|
} `json:"flow"`
|
||||||
Metrics []struct {
|
Metrics []struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Value int `json:"value"`
|
Value int `json:"value"`
|
||||||
|
|||||||
@@ -2,12 +2,9 @@ package models
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type DBSegment struct {
|
type DBSegment struct {
|
||||||
gorm.Model
|
|
||||||
Id string `gorm:"primaryKey;index"`
|
Id string `gorm:"primaryKey;index"`
|
||||||
Conference bool
|
Conference bool
|
||||||
DisconnectType string
|
DisconnectType string
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import "gorm.io/gorm"
|
|
||||||
|
|
||||||
type DBSession struct {
|
type DBSession struct {
|
||||||
gorm.Model
|
|
||||||
Ani string
|
Ani string
|
||||||
Direction string
|
Direction string
|
||||||
Dnis string
|
Dnis string
|
||||||
@@ -18,6 +15,9 @@ type DBSession struct {
|
|||||||
Recording bool
|
Recording bool
|
||||||
RemoteNameDisplayable string
|
RemoteNameDisplayable string
|
||||||
SessionDnis string
|
SessionDnis string
|
||||||
|
Flow string `gorm:"type:json"`
|
||||||
|
|
||||||
|
Segments []DBSegment `gorm:"foreignKey:SessionId;references:Id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (DBSession) TableName() string {
|
func (DBSession) TableName() string {
|
||||||
|
|||||||
258
util/extract.go
258
util/extract.go
@@ -33,8 +33,6 @@ func ExtractWithoutAttributes(base models.AnalyticsConversationWithoutAttributes
|
|||||||
}
|
}
|
||||||
divisionIdsBytesStr := string(divisionIdsBytes)
|
divisionIdsBytesStr := string(divisionIdsBytes)
|
||||||
|
|
||||||
currentTime := time.Now()
|
|
||||||
|
|
||||||
conversation := models.DBConversation{
|
conversation := models.DBConversation{
|
||||||
DivisionIds: &divisionIdsBytesStr,
|
DivisionIds: &divisionIdsBytesStr,
|
||||||
End: endTime,
|
End: endTime,
|
||||||
@@ -43,7 +41,6 @@ func ExtractWithoutAttributes(base models.AnalyticsConversationWithoutAttributes
|
|||||||
MinRFactor: &base.MediaStatsMinConversationRFactor,
|
MinRFactor: &base.MediaStatsMinConversationRFactor,
|
||||||
OriginatingDirection: &base.OriginatingDirection,
|
OriginatingDirection: &base.OriginatingDirection,
|
||||||
Start: startTime,
|
Start: startTime,
|
||||||
SemiLiveUpdate: ¤tTime,
|
|
||||||
}
|
}
|
||||||
var participants []models.DBParticipant
|
var participants []models.DBParticipant
|
||||||
var sessions []models.DBSession
|
var sessions []models.DBSession
|
||||||
@@ -73,6 +70,11 @@ func ExtractWithoutAttributes(base models.AnalyticsConversationWithoutAttributes
|
|||||||
metricsBytes = nil
|
metricsBytes = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flowBytes, err := json.Marshal(sess.Flow)
|
||||||
|
if err != nil {
|
||||||
|
flowBytes = nil
|
||||||
|
}
|
||||||
|
|
||||||
session := models.DBSession{
|
session := models.DBSession{
|
||||||
Ani: sess.ANI,
|
Ani: sess.ANI,
|
||||||
Direction: sess.Direction,
|
Direction: sess.Direction,
|
||||||
@@ -88,6 +90,7 @@ func ExtractWithoutAttributes(base models.AnalyticsConversationWithoutAttributes
|
|||||||
Recording: sess.Recording,
|
Recording: sess.Recording,
|
||||||
RemoteNameDisplayable: sess.RemoteNameDisplayable,
|
RemoteNameDisplayable: sess.RemoteNameDisplayable,
|
||||||
SessionDnis: sess.SessionDNIS,
|
SessionDnis: sess.SessionDNIS,
|
||||||
|
Flow: string(flowBytes),
|
||||||
}
|
}
|
||||||
sessions = append(sessions, session)
|
sessions = append(sessions, session)
|
||||||
|
|
||||||
@@ -129,7 +132,6 @@ func ExtractWithoutAttributes(base models.AnalyticsConversationWithoutAttributes
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ExtractLive(base models.NotificationConversationWithAttributes) (models.DBConversation, []models.DBParticipant, []models.DBCall) {
|
func ExtractLive(base models.NotificationConversationWithAttributes) (models.DBConversation, []models.DBParticipant, []models.DBCall) {
|
||||||
currentTime := time.Now()
|
|
||||||
|
|
||||||
conversation := models.DBConversation{
|
conversation := models.DBConversation{
|
||||||
Id: base.Id,
|
Id: base.Id,
|
||||||
@@ -138,7 +140,6 @@ func ExtractLive(base models.NotificationConversationWithAttributes) (models.DBC
|
|||||||
RecordingState: &base.RecordingState,
|
RecordingState: &base.RecordingState,
|
||||||
SecurePause: &base.SecurePause,
|
SecurePause: &base.SecurePause,
|
||||||
UtilizationLabelId: &base.UtilizationLabelId,
|
UtilizationLabelId: &base.UtilizationLabelId,
|
||||||
LiveUpdate: ¤tTime,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var participants []models.DBParticipant
|
var participants []models.DBParticipant
|
||||||
@@ -260,128 +261,125 @@ func ExtractLive(base models.NotificationConversationWithAttributes) (models.DBC
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExtractWithAttributes(base models.AnalyticsConversationWithAttributes) (models.DBConversation, []models.DBParticipant, []models.DBSession, []models.DBSegment) {
|
//func ExtractWithAttributes(base models.AnalyticsConversationWithAttributes) (models.DBConversation, []models.DBParticipant, []models.DBSession, []models.DBSegment) {
|
||||||
|
//
|
||||||
var startTime *time.Time
|
// var startTime *time.Time
|
||||||
parsedStartTime, err := time.Parse(time.RFC3339, base.ConversationStart)
|
// parsedStartTime, err := time.Parse(time.RFC3339, base.ConversationStart)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
startTime = nil
|
// startTime = nil
|
||||||
} else {
|
// } else {
|
||||||
startTime = &parsedStartTime
|
// startTime = &parsedStartTime
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
var endTime *time.Time
|
// var endTime *time.Time
|
||||||
parsedEndTime, err := time.Parse(time.RFC3339, base.ConversationEnd)
|
// parsedEndTime, err := time.Parse(time.RFC3339, base.ConversationEnd)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
endTime = nil
|
// endTime = nil
|
||||||
} else {
|
// } else {
|
||||||
endTime = &parsedEndTime
|
// endTime = &parsedEndTime
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
divisionIdsBytes, err := json.Marshal(base.DivisionIds)
|
// divisionIdsBytes, err := json.Marshal(base.DivisionIds)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
divisionIdsBytes = nil
|
// divisionIdsBytes = nil
|
||||||
}
|
// }
|
||||||
divisionIdsBytesStr := string(divisionIdsBytes)
|
// divisionIdsBytesStr := string(divisionIdsBytes)
|
||||||
|
//
|
||||||
currentTime := time.Now()
|
// conversation := models.DBConversation{
|
||||||
|
// DivisionIds: &divisionIdsBytesStr,
|
||||||
conversation := models.DBConversation{
|
// End: endTime,
|
||||||
DivisionIds: &divisionIdsBytesStr,
|
// Id: base.ConversationId,
|
||||||
End: endTime,
|
// MinMos: &base.MediaStatsMinConversationMos,
|
||||||
Id: base.ConversationId,
|
// MinRFactor: &base.MediaStatsMinConversationRFactor,
|
||||||
MinMos: &base.MediaStatsMinConversationMos,
|
// OriginatingDirection: &base.OriginatingDirection,
|
||||||
MinRFactor: &base.MediaStatsMinConversationRFactor,
|
// Start: startTime,
|
||||||
OriginatingDirection: &base.OriginatingDirection,
|
// }
|
||||||
Start: startTime,
|
// var participants []models.DBParticipant
|
||||||
JobUpdate: ¤tTime,
|
// var sessions []models.DBSession
|
||||||
}
|
// var segments []models.DBSegment
|
||||||
var participants []models.DBParticipant
|
//
|
||||||
var sessions []models.DBSession
|
// for _, p := range base.Participants {
|
||||||
var segments []models.DBSegment
|
//
|
||||||
|
// attributesBytes, err := json.Marshal(p.Attributes)
|
||||||
for _, p := range base.Participants {
|
// if err != nil {
|
||||||
|
// attributesBytes = nil
|
||||||
attributesBytes, err := json.Marshal(p.Attributes)
|
// }
|
||||||
if err != nil {
|
// attributesBytesStr := string(attributesBytes)
|
||||||
attributesBytes = nil
|
//
|
||||||
}
|
// participant := models.DBParticipant{
|
||||||
attributesBytesStr := string(attributesBytes)
|
// ConnectedTime: nil,
|
||||||
|
// ConversationId: base.ConversationId,
|
||||||
participant := models.DBParticipant{
|
// EndTime: nil,
|
||||||
ConnectedTime: nil,
|
// ExternalContactId: &p.ExternalContactId,
|
||||||
ConversationId: base.ConversationId,
|
// Id: p.ParticipantId,
|
||||||
EndTime: nil,
|
// Name: &p.ParticipantName,
|
||||||
ExternalContactId: &p.ExternalContactId,
|
// Purpose: &p.Purpose,
|
||||||
Id: p.ParticipantId,
|
// Attributes: &attributesBytesStr,
|
||||||
Name: &p.ParticipantName,
|
// }
|
||||||
Purpose: &p.Purpose,
|
// participants = append(participants, participant)
|
||||||
Attributes: &attributesBytesStr,
|
//
|
||||||
}
|
// for _, sess := range p.Sessions {
|
||||||
participants = append(participants, participant)
|
// mediaEndpointStatsBytes, err := json.Marshal(sess.MediaEndpointStats)
|
||||||
|
// if err != nil {
|
||||||
for _, sess := range p.Sessions {
|
// mediaEndpointStatsBytes = nil
|
||||||
mediaEndpointStatsBytes, err := json.Marshal(sess.MediaEndpointStats)
|
// }
|
||||||
if err != nil {
|
//
|
||||||
mediaEndpointStatsBytes = nil
|
// metricsBytes, err := json.Marshal(sess.Metrics)
|
||||||
}
|
// if err != nil {
|
||||||
|
// metricsBytes = nil
|
||||||
metricsBytes, err := json.Marshal(sess.Metrics)
|
// }
|
||||||
if err != nil {
|
//
|
||||||
metricsBytes = nil
|
// session := models.DBSession{
|
||||||
}
|
// Ani: sess.ANI,
|
||||||
|
// Direction: sess.Direction,
|
||||||
session := models.DBSession{
|
// Dnis: sess.DNIS,
|
||||||
Ani: sess.ANI,
|
// EdgeId: sess.EdgeId,
|
||||||
Direction: sess.Direction,
|
// Id: fmt.Sprintf("%s_%s", p.ParticipantId, sess.SessionId),
|
||||||
Dnis: sess.DNIS,
|
// MediaEndpointStats: string(mediaEndpointStatsBytes),
|
||||||
EdgeId: sess.EdgeId,
|
// MediaType: sess.MediaType,
|
||||||
Id: fmt.Sprintf("%s_%s", p.ParticipantId, sess.SessionId),
|
// Metrics: string(metricsBytes),
|
||||||
MediaEndpointStats: string(mediaEndpointStatsBytes),
|
// ParticipantId: p.ParticipantId,
|
||||||
MediaType: sess.MediaType,
|
// ProtocolCallId: sess.ProtocolCallId,
|
||||||
Metrics: string(metricsBytes),
|
// Provider: sess.Provider,
|
||||||
ParticipantId: p.ParticipantId,
|
// Recording: sess.Recording,
|
||||||
ProtocolCallId: sess.ProtocolCallId,
|
// RemoteNameDisplayable: sess.RemoteNameDisplayable,
|
||||||
Provider: sess.Provider,
|
// SessionDnis: sess.SessionDnis,
|
||||||
Recording: sess.Recording,
|
// }
|
||||||
RemoteNameDisplayable: sess.RemoteNameDisplayable,
|
// sessions = append(sessions, session)
|
||||||
SessionDnis: sess.SessionDnis,
|
//
|
||||||
}
|
// for _, seg := range sess.Segments {
|
||||||
sessions = append(sessions, session)
|
//
|
||||||
|
// segmentStart, err := time.Parse(time.RFC3339, seg.SegmentStart)
|
||||||
for _, seg := range sess.Segments {
|
// if err != nil {
|
||||||
|
// segmentStart = time.Now()
|
||||||
segmentStart, err := time.Parse(time.RFC3339, seg.SegmentStart)
|
// }
|
||||||
if err != nil {
|
//
|
||||||
segmentStart = time.Now()
|
// segmentEnd, err := time.Parse(time.RFC3339, seg.SegmentEnd)
|
||||||
}
|
// if err != nil {
|
||||||
|
// segmentEnd = time.Now()
|
||||||
segmentEnd, err := time.Parse(time.RFC3339, seg.SegmentEnd)
|
// }
|
||||||
if err != nil {
|
//
|
||||||
segmentEnd = time.Now()
|
// q850ResponseCodesBytes, err := json.Marshal(seg.Q850ResponseCodes)
|
||||||
}
|
// if err != nil {
|
||||||
|
// q850ResponseCodesBytes = nil
|
||||||
q850ResponseCodesBytes, err := json.Marshal(seg.Q850ResponseCodes)
|
// }
|
||||||
if err != nil {
|
//
|
||||||
q850ResponseCodesBytes = nil
|
// segment := models.DBSegment{
|
||||||
}
|
// Id: fmt.Sprintf("%s_%s", session.Id, seg.SegmentType),
|
||||||
|
// Conference: seg.Conference,
|
||||||
segment := models.DBSegment{
|
// DisconnectType: seg.DisconnectType,
|
||||||
Id: fmt.Sprintf("%s_%s", session.Id, seg.SegmentType),
|
// Q850ResponseCodes: string(q850ResponseCodesBytes),
|
||||||
Conference: seg.Conference,
|
// SegmentEnd: segmentEnd,
|
||||||
DisconnectType: seg.DisconnectType,
|
// SegmentStart: segmentStart,
|
||||||
Q850ResponseCodes: string(q850ResponseCodesBytes),
|
// SegmentType: seg.SegmentType,
|
||||||
SegmentEnd: segmentEnd,
|
// SessionId: sess.SessionId,
|
||||||
SegmentStart: segmentStart,
|
// WrapUpCode: seg.WrapUpCode,
|
||||||
SegmentType: seg.SegmentType,
|
// }
|
||||||
SessionId: sess.SessionId,
|
//
|
||||||
WrapUpCode: seg.WrapUpCode,
|
// segments = append(segments, segment)
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
segments = append(segments, segment)
|
// }
|
||||||
}
|
//
|
||||||
}
|
// return conversation, participants, sessions, segments
|
||||||
}
|
//}
|
||||||
|
|
||||||
return conversation, participants, sessions, segments
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user