Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 194cb5bbe6 | |||
| aa15b86efd | |||
| b52f1cd80d | |||
| abf0d6caf0 | |||
| 42f9ba2848 | |||
| 055ad59d12 | |||
| d66df080fe | |||
| 804b9b2792 | |||
| 3be1e46f69 | |||
| 0122b01037 | |||
| d8d857e82e | |||
| ab6b36c12c | |||
| f69b849ed7 | |||
| 3e103f18a5 | |||
| 746a492cd4 | |||
| c76a900b19 | |||
| 8eda80c61a |
31
models/amendment.go
Normal file
31
models/amendment.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type DBAmendment struct {
|
||||
Id int `gorm:"primaryKey;autoIncrement"`
|
||||
ConversationId string `gorm:"index"`
|
||||
AmendmentColumn string
|
||||
AmendmentValue string
|
||||
Requestor string
|
||||
RequestedAt time.Time
|
||||
}
|
||||
|
||||
func (DBAmendment) TableName() string {
|
||||
return "gc_amendments"
|
||||
}
|
||||
|
||||
type DBAmendmentLog struct {
|
||||
Id int `gorm:"primaryKey;autoIncrement"`
|
||||
ConversationId string `gorm:"index"`
|
||||
AmendmentColumn string
|
||||
OldValue string
|
||||
NewValue string
|
||||
Requestor string
|
||||
RequestedAt time.Time
|
||||
AmendedAt time.Time
|
||||
}
|
||||
|
||||
func (DBAmendmentLog) TableName() string {
|
||||
return "gc_amendment_logs"
|
||||
}
|
||||
26
models/base_call.go
Normal file
26
models/base_call.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type BaseCall struct {
|
||||
ClientConversationId string `gorm:"primaryKey;index"`
|
||||
CallType string `gorm:"index"`
|
||||
GenderPreference string
|
||||
ClientId int `gorm:"index"`
|
||||
CustomerDnis string
|
||||
CustomerAni string
|
||||
P1ConnectTime time.Time `gorm:"index"`
|
||||
P1DisconnectTime time.Time `gorm:"index"`
|
||||
P3ConnectTime *time.Time
|
||||
P3DisconnectTime *time.Time
|
||||
BookingRequestNumber *int `gorm:"index"`
|
||||
IvrData *int
|
||||
UtsEntries int
|
||||
InterpreterCount int
|
||||
}
|
||||
|
||||
func (BaseCall) TableName() string {
|
||||
return "gc_base_calls"
|
||||
}
|
||||
@@ -2,12 +2,9 @@ package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type DBCall struct {
|
||||
gorm.Model
|
||||
AfterCallWorkRequired bool
|
||||
Confined bool
|
||||
ConnectedTime *time.Time `gorm:"index"`
|
||||
|
||||
@@ -2,12 +2,9 @@ package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type DBConversation struct {
|
||||
gorm.Model
|
||||
Address *string
|
||||
DivisionIds *string `gorm:"type:json"`
|
||||
End *time.Time `gorm:"index"`
|
||||
@@ -22,8 +19,11 @@ type DBConversation struct {
|
||||
Start *time.Time `gorm:"index"`
|
||||
UtilizationLabelId *string
|
||||
LiveUpdate *time.Time
|
||||
DetailsUpdate *time.Time
|
||||
SemiLiveUpdate *time.Time
|
||||
JobUpdate *time.Time
|
||||
|
||||
Participants []DBParticipant `gorm:"foreignKey:ConversationId;references:Id"`
|
||||
}
|
||||
|
||||
func (DBConversation) TableName() string {
|
||||
|
||||
185
models/gencloud.go
Normal file
185
models/gencloud.go
Normal file
@@ -0,0 +1,185 @@
|
||||
package models
|
||||
|
||||
type AnalyticsConversationWithAttributesQuery struct {
|
||||
Conversations []AnalyticsConversationWithAttributes `json:"conversations"`
|
||||
Cursor *string `json:"cursor"`
|
||||
}
|
||||
|
||||
type AnalyticsConversationWithAttributes struct {
|
||||
ConversationEnd string `json:"conversationEnd"`
|
||||
ConversationId string `json:"conversationId"`
|
||||
ConversationStart string `json:"conversationStart"`
|
||||
DivisionIds []string `json:"divisionIds"`
|
||||
ExternalTag string `json:"externalTag"`
|
||||
MediaStatsMinConversationMos float32 `json:"mediaStatsMinConversationMos"`
|
||||
MediaStatsMinConversationRFactor float32 `json:"mediaStatsMinConversationRFactor"`
|
||||
OriginatingDirection string `json:"originatingDirection"`
|
||||
Participants []struct {
|
||||
ExternalContactId string `json:"externalContactId"`
|
||||
ParticipantId string `json:"participantId"`
|
||||
ParticipantName string `json:"participantName"`
|
||||
Purpose string `json:"purpose"`
|
||||
Sessions []struct {
|
||||
ANI string `json:"ani"`
|
||||
Direction string `json:"direction"`
|
||||
DNIS string `json:"dnis"`
|
||||
EdgeId string `json:"edgeId"`
|
||||
MediaType string `json:"mediaType"`
|
||||
ProtocolCallId string `json:"protocolCallId"`
|
||||
Provider string `json:"provider"`
|
||||
Recording bool `json:"recording"`
|
||||
RemoteNameDisplayable string `json:"remoteNameDisplayable"`
|
||||
SessionDnis string `json:"sessionDnis"`
|
||||
SessionId string `json:"sessionId"`
|
||||
MediaEndpointStats []struct {
|
||||
Codecs []string `json:"codecs"`
|
||||
EventTime string `json:"eventTime"`
|
||||
MaxLatencyMs int `json:"maxLatencyMs"`
|
||||
MinMos float32 `json:"minMos"`
|
||||
MinRFactor float32 `json:"minRFactor"`
|
||||
ReceivedPackets int `json:"receivedPackets"`
|
||||
} `json:"mediaEndpointStats"`
|
||||
Metrics []struct {
|
||||
EmitDate string `json:"emitDate"`
|
||||
Name string `json:"name"`
|
||||
Value int `json:"value"`
|
||||
} `json:"metrics"`
|
||||
Segments []struct {
|
||||
Conference bool `json:"conference"`
|
||||
DisconnectType string `json:"disconnectType"`
|
||||
Q850ResponseCodes []int `json:"q850ResponseCodes"`
|
||||
SegmentEnd string `json:"segmentEnd"`
|
||||
SegmentStart string `json:"segmentStart"`
|
||||
SegmentType string `json:"segmentType"`
|
||||
WrapUpCode string `json:"wrapUpCode"`
|
||||
} `json:"segments"`
|
||||
} `json:"sessions"`
|
||||
Attributes map[string]any `json:"attributes"`
|
||||
} `json:"participants"`
|
||||
}
|
||||
|
||||
type AnalyticsConversationWithoutAttributesQuery struct {
|
||||
Conversations []AnalyticsConversationWithoutAttributes `json:"conversations"`
|
||||
TotalHits int `json:"totalHits"`
|
||||
}
|
||||
type AnalyticsConversationWithoutAttributes struct {
|
||||
ConversationId string `json:"conversationId"`
|
||||
ConversationStart string `json:"conversationStart"`
|
||||
ConversationEnd string `json:"conversationEnd"`
|
||||
MediaStatsMinConversationMos float32 `json:"mediaStatsMinConversationMos"`
|
||||
MediaStatsMinConversationRFactor float32 `json:"mediaStatsMinConversationRFactor"`
|
||||
OriginatingDirection string `json:"originatingDirection"`
|
||||
DivisionIds []string `json:"divisionIds"`
|
||||
Participants []struct {
|
||||
ParticipantId string `json:"participantId"`
|
||||
ParticipantName string `json:"participantName"`
|
||||
Purpose string `json:"purpose"`
|
||||
ExternalContactId string `json:"externalContactId"`
|
||||
Sessions []struct {
|
||||
MediaType string `json:"mediaType"`
|
||||
SessionId string `json:"sessionId"`
|
||||
ANI string `json:"ani"`
|
||||
Direction string `json:"direction"`
|
||||
DNIS string `json:"dnis"`
|
||||
SessionDNIS string `json:"sessionDnis"`
|
||||
EdgeId string `json:"edgeId"`
|
||||
RemoteNameDisplayable string `json:"remoteNameDisplayable"`
|
||||
Segments []struct {
|
||||
SegmentStart string `json:"segmentStart"`
|
||||
SegmentEnd string `json:"segmentEnd"`
|
||||
WrapUpCode string `json:"wrapUpCode"`
|
||||
DisconnectType string `json:"disconnectType"`
|
||||
SegmentType string `json:"SegmentType"`
|
||||
Q850ResponseCodes []int `json:"q850ResponseCodes"`
|
||||
Conference bool `json:"conference"`
|
||||
} `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 {
|
||||
Name string `json:"name"`
|
||||
Value int `json:"value"`
|
||||
EmitDate string `json:"emitDate"`
|
||||
} `json:"metrics"`
|
||||
MediaEndpointStats []struct {
|
||||
Codecs []string `json:"codecs"`
|
||||
MinMos float32 `json:"minMos"`
|
||||
MinRFactor float32 `json:"minRFactor"`
|
||||
MaxLatencyMs int `json:"maxLatencyMs"`
|
||||
ReceivedPackets int `json:"receivedPackets"`
|
||||
} `json:"mediaEndpointStats"`
|
||||
Recording bool `json:"recording"`
|
||||
ProtocolCallId string `json:"protocolCallId"`
|
||||
Provider string `json:"provider"`
|
||||
} `json:"sessions"`
|
||||
} `json:"participants"`
|
||||
}
|
||||
|
||||
type NotificationConversationWithAttributes struct {
|
||||
Address string `json:"address"`
|
||||
Divisions []struct {
|
||||
Division struct {
|
||||
Id string `json:"id"`
|
||||
SelfUri string `json:"selfUri"`
|
||||
} `json:"division"`
|
||||
Entities []struct {
|
||||
DateDivisionUpdated string `json:"dateDivisionUpdated"`
|
||||
Id string `json:"id"`
|
||||
SelfUri string `json:"selfUri"`
|
||||
} `json:"entities"`
|
||||
} `json:"divisions"`
|
||||
ExternalTag string `json:"externalTag"`
|
||||
Id string `json:"id"`
|
||||
Participants []struct {
|
||||
Address string `json:"address"`
|
||||
Attributes map[string]any `json:"attributes"`
|
||||
Calls []struct {
|
||||
AfterCallWorkRequired bool `json:"afterCallWorkRequired"`
|
||||
Confined bool `json:"confined"`
|
||||
ConnectedTime string `json:"connectedTime"`
|
||||
Direction string `json:"direction"`
|
||||
DisconnectReasons []struct{} `json:"disconnectReasons"`
|
||||
DisconnectType string `json:"disconnectType"`
|
||||
DisconnectedTime string `json:"disconnectedTime"`
|
||||
Held bool `json:"held"`
|
||||
Id string `json:"id"`
|
||||
InitialState string `json:"initialState"`
|
||||
Muted bool `json:"muted"`
|
||||
Other map[string]any `json:"other"`
|
||||
PeerId string `json:"peerId"`
|
||||
Provider string `json:"provider"`
|
||||
Recording bool `json:"recording"`
|
||||
RecordingState string `json:"recordingState"`
|
||||
SecurePause bool `json:"securePause"`
|
||||
Self map[string]any `json:"self"`
|
||||
State string `json:"state"`
|
||||
} `json:"calls"`
|
||||
ConnectedTime string `json:"connectedTime"`
|
||||
EndTime string `json:"endTime"`
|
||||
ExternalContactId string `json:"externalContactId"`
|
||||
ExternalContactInitialDivisionId string `json:"externalContactInitialDivisionId"`
|
||||
Id string `json:"id"`
|
||||
MediaRoles []string `json:"mediaRoles"`
|
||||
Name string `json:"name"`
|
||||
Purpose string `json:"purpose"`
|
||||
QueueId string `json:"queueId"`
|
||||
Wrapup map[string]any `json:"wrapup"`
|
||||
WrapupExpected bool `json:"wrapupExpected"`
|
||||
WrapupRequired bool `json:"wrapupRequired"`
|
||||
} `json:"participants"`
|
||||
RecentTransfers []map[string]any `json:"recentTransfers"`
|
||||
RecordingState string `json:"recordingState"`
|
||||
SecurePause bool `json:"securePause"`
|
||||
UtilizationLabelId string `json:"utilizationLabelId"`
|
||||
}
|
||||
22
models/interpreter_connection.go
Normal file
22
models/interpreter_connection.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type InterpreterConnection struct {
|
||||
InterpreterConversationId string `gorm:"primaryKey;index"`
|
||||
InterpreterAccepted bool
|
||||
InterpreterId int `gorm:"index"`
|
||||
CallType string
|
||||
CallConnected string
|
||||
ClientConversationId string `gorm:"index"`
|
||||
LanguageId int
|
||||
InterpreterPhone string
|
||||
ConferenceStart time.Time
|
||||
ConferenceEnd time.Time
|
||||
}
|
||||
|
||||
func (InterpreterConnection) TableName() string {
|
||||
return "gc_interpreter_connections"
|
||||
}
|
||||
@@ -2,12 +2,9 @@ package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type DBParticipant struct {
|
||||
gorm.Model
|
||||
Address *string
|
||||
Attributes *string `gorm:"type:json"`
|
||||
ConnectedTime *time.Time `gorm:"index"`
|
||||
@@ -23,6 +20,8 @@ type DBParticipant struct {
|
||||
Wrapup *string `gorm:"type:json"`
|
||||
WrapupExpected *bool
|
||||
WrapupRequired *bool
|
||||
|
||||
Sessions []DBSession `gorm:"foreignKey:ParticipantId;references:Id"`
|
||||
}
|
||||
|
||||
func (DBParticipant) TableName() string {
|
||||
|
||||
16
models/queue_log.go
Normal file
16
models/queue_log.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type DBQueueLog struct {
|
||||
Queue string `gorm:"primaryKey"`
|
||||
ConversationId string `gorm:"primaryKey"`
|
||||
Start time.Time `gorm:"index"`
|
||||
End time.Time `gorm:"index"`
|
||||
Duration float64
|
||||
Result string `gorm:"type:json"`
|
||||
}
|
||||
|
||||
func (DBQueueLog) TableName() string {
|
||||
return "gc_queue_logs"
|
||||
}
|
||||
27
models/raw.go
Normal file
27
models/raw.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type GCRaw struct {
|
||||
ClientConversationId string
|
||||
InterpreterConversationId string
|
||||
LanguageId int
|
||||
CallType string
|
||||
GenderPreference string
|
||||
ClientId int
|
||||
CustomerDnis string
|
||||
CustomerAni string
|
||||
ClientConnectTimeUtc *time.Time
|
||||
ClientDisconnectTimeUtc *time.Time
|
||||
NesConnectTimeUtc *time.Time
|
||||
NesDisconnectTimeUtc *time.Time
|
||||
BookingReference *int
|
||||
IvrData *int
|
||||
InterpreterId int
|
||||
InterpreterConnectTimeUtc time.Time
|
||||
InterpreterDisconnectTimeUtc time.Time
|
||||
}
|
||||
|
||||
func (GCRaw) TableName() string {
|
||||
return "gc_raw"
|
||||
}
|
||||
@@ -2,12 +2,9 @@ package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type DBSegment struct {
|
||||
gorm.Model
|
||||
Id string `gorm:"primaryKey;index"`
|
||||
Conference bool
|
||||
DisconnectType string
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package models
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
type DBSession struct {
|
||||
gorm.Model
|
||||
Ani string
|
||||
Direction string
|
||||
Dnis string
|
||||
@@ -18,6 +15,9 @@ type DBSession struct {
|
||||
Recording bool
|
||||
RemoteNameDisplayable string
|
||||
SessionDnis string
|
||||
Flow string `gorm:"type:json"`
|
||||
|
||||
Segments []DBSegment `gorm:"foreignKey:SessionId;references:Id"`
|
||||
}
|
||||
|
||||
func (DBSession) TableName() string {
|
||||
|
||||
385
util/extract.go
Normal file
385
util/extract.go
Normal file
@@ -0,0 +1,385 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"huron.connectingnow.net/fholland/gorm_models/models"
|
||||
)
|
||||
|
||||
func ExtractWithoutAttributes(base models.AnalyticsConversationWithoutAttributes) (models.DBConversation, []models.DBParticipant, []models.DBSession, []models.DBSegment) {
|
||||
|
||||
var startTime *time.Time
|
||||
|
||||
parsedStartTime, err := time.Parse(time.RFC3339, base.ConversationStart)
|
||||
if err != nil {
|
||||
startTime = nil
|
||||
} else {
|
||||
startTime = &parsedStartTime
|
||||
}
|
||||
|
||||
var endTime *time.Time
|
||||
parsedEndTime, err := time.Parse(time.RFC3339, base.ConversationEnd)
|
||||
if err != nil {
|
||||
startTime = nil
|
||||
} else {
|
||||
startTime = &parsedEndTime
|
||||
}
|
||||
|
||||
divisionIdsBytes, err := json.Marshal(base.DivisionIds)
|
||||
if err != nil {
|
||||
divisionIdsBytes = nil
|
||||
}
|
||||
divisionIdsBytesStr := string(divisionIdsBytes)
|
||||
|
||||
conversation := models.DBConversation{
|
||||
DivisionIds: &divisionIdsBytesStr,
|
||||
End: endTime,
|
||||
Id: base.ConversationId,
|
||||
MinMos: &base.MediaStatsMinConversationMos,
|
||||
MinRFactor: &base.MediaStatsMinConversationRFactor,
|
||||
OriginatingDirection: &base.OriginatingDirection,
|
||||
Start: startTime,
|
||||
}
|
||||
var participants []models.DBParticipant
|
||||
var sessions []models.DBSession
|
||||
var segments []models.DBSegment
|
||||
|
||||
for _, p := range base.Participants {
|
||||
|
||||
participant := models.DBParticipant{
|
||||
ConnectedTime: nil,
|
||||
ConversationId: base.ConversationId,
|
||||
EndTime: nil,
|
||||
ExternalContactId: &p.ExternalContactId,
|
||||
Id: p.ParticipantId,
|
||||
Name: &p.ParticipantName,
|
||||
Purpose: &p.Purpose,
|
||||
}
|
||||
participants = append(participants, participant)
|
||||
|
||||
for _, sess := range p.Sessions {
|
||||
mediaEndpointStatsBytes, err := json.Marshal(sess.MediaEndpointStats)
|
||||
if err != nil {
|
||||
mediaEndpointStatsBytes = nil
|
||||
}
|
||||
|
||||
metricsBytes, err := json.Marshal(sess.Metrics)
|
||||
if err != nil {
|
||||
metricsBytes = nil
|
||||
}
|
||||
|
||||
flowBytes, err := json.Marshal(sess.Flow)
|
||||
if err != nil {
|
||||
flowBytes = nil
|
||||
}
|
||||
|
||||
session := models.DBSession{
|
||||
Ani: sess.ANI,
|
||||
Direction: sess.Direction,
|
||||
Dnis: sess.DNIS,
|
||||
EdgeId: sess.EdgeId,
|
||||
Id: fmt.Sprintf("%s_%s", p.ParticipantId, sess.SessionId),
|
||||
MediaEndpointStats: string(mediaEndpointStatsBytes),
|
||||
MediaType: sess.MediaType,
|
||||
Metrics: string(metricsBytes),
|
||||
ParticipantId: p.ParticipantId,
|
||||
ProtocolCallId: sess.ProtocolCallId,
|
||||
Provider: sess.Provider,
|
||||
Recording: sess.Recording,
|
||||
RemoteNameDisplayable: sess.RemoteNameDisplayable,
|
||||
SessionDnis: sess.SessionDNIS,
|
||||
Flow: string(flowBytes),
|
||||
}
|
||||
sessions = append(sessions, session)
|
||||
|
||||
for _, seg := range sess.Segments {
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
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,
|
||||
DisconnectType: seg.DisconnectType,
|
||||
Q850ResponseCodes: string(q850ResponseCodesBytes),
|
||||
SegmentEnd: segmentEnd,
|
||||
SegmentStart: segmentStart,
|
||||
SegmentType: seg.SegmentType,
|
||||
SessionId: session.Id,
|
||||
WrapUpCode: seg.WrapUpCode,
|
||||
}
|
||||
|
||||
segments = append(segments, segment)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return conversation, participants, sessions, segments
|
||||
}
|
||||
|
||||
func ExtractLive(base models.NotificationConversationWithAttributes) (models.DBConversation, []models.DBParticipant, []models.DBCall) {
|
||||
|
||||
conversation := models.DBConversation{
|
||||
Id: base.Id,
|
||||
Address: &base.Address,
|
||||
ExternalTag: &base.ExternalTag,
|
||||
RecordingState: &base.RecordingState,
|
||||
SecurePause: &base.SecurePause,
|
||||
UtilizationLabelId: &base.UtilizationLabelId,
|
||||
}
|
||||
|
||||
var participants []models.DBParticipant
|
||||
var calls []models.DBCall
|
||||
|
||||
for _, partPayload := range base.Participants {
|
||||
attributesBytes, err := json.Marshal(partPayload.Attributes)
|
||||
if err != nil {
|
||||
attributesBytes = nil
|
||||
}
|
||||
attributesBytesStr := string(attributesBytes)
|
||||
|
||||
mediaRolesBytes, err := json.Marshal(partPayload.MediaRoles)
|
||||
if err != nil {
|
||||
mediaRolesBytes = nil
|
||||
}
|
||||
mediaRolesBytesStr := string(mediaRolesBytes)
|
||||
|
||||
wrapupBytes, err := json.Marshal(partPayload.Wrapup)
|
||||
if err != nil {
|
||||
wrapupBytes = nil
|
||||
}
|
||||
wrapupBytesStr := string(wrapupBytes)
|
||||
|
||||
var connectedTime *time.Time
|
||||
parsedConnectedTime, err := time.Parse(time.RFC3339, partPayload.ConnectedTime)
|
||||
if err != nil {
|
||||
connectedTime = nil
|
||||
} else {
|
||||
connectedTime = &parsedConnectedTime
|
||||
}
|
||||
|
||||
var endTime *time.Time
|
||||
parsedEndTime, err := time.Parse(time.RFC3339, partPayload.EndTime)
|
||||
if err != nil {
|
||||
endTime = nil
|
||||
} else {
|
||||
endTime = &parsedEndTime
|
||||
}
|
||||
|
||||
participant := models.DBParticipant{
|
||||
ConversationId: base.Id,
|
||||
Id: partPayload.Id,
|
||||
Address: &partPayload.Address,
|
||||
Attributes: &attributesBytesStr,
|
||||
ConnectedTime: connectedTime,
|
||||
EndTime: endTime,
|
||||
ExternalContactId: &partPayload.ExternalContactId,
|
||||
ExternalContactInitialDivisionId: &partPayload.ExternalContactInitialDivisionId,
|
||||
MediaRoles: &mediaRolesBytesStr,
|
||||
Name: &partPayload.Name,
|
||||
Purpose: &partPayload.Purpose,
|
||||
QueueId: &partPayload.QueueId,
|
||||
Wrapup: &wrapupBytesStr,
|
||||
WrapupExpected: &partPayload.WrapupExpected,
|
||||
WrapupRequired: &partPayload.WrapupRequired,
|
||||
}
|
||||
participants = append(participants, participant)
|
||||
|
||||
for _, callPayload := range partPayload.Calls {
|
||||
var connectedTime *time.Time
|
||||
parsedConnectedTime, err := time.Parse(time.RFC3339, callPayload.ConnectedTime)
|
||||
if err != nil {
|
||||
connectedTime = nil
|
||||
} else {
|
||||
connectedTime = &parsedConnectedTime
|
||||
}
|
||||
|
||||
var disconnectedTime *time.Time
|
||||
parsedDisconnectedTime, err := time.Parse(time.RFC3339, callPayload.DisconnectedTime)
|
||||
if err != nil {
|
||||
disconnectedTime = nil
|
||||
} else {
|
||||
disconnectedTime = &parsedDisconnectedTime
|
||||
}
|
||||
|
||||
otherBytes, err := json.Marshal(callPayload.Other)
|
||||
if err != nil {
|
||||
otherBytes = nil
|
||||
}
|
||||
|
||||
selfBytes, err := json.Marshal(callPayload.Self)
|
||||
if err != nil {
|
||||
selfBytes = nil
|
||||
}
|
||||
|
||||
disconnectReasonsBytes, err := json.Marshal(callPayload.DisconnectReasons)
|
||||
if err != nil {
|
||||
disconnectReasonsBytes = nil
|
||||
}
|
||||
|
||||
call := models.DBCall{
|
||||
ParticipantId: partPayload.Id,
|
||||
AfterCallWorkRequired: callPayload.AfterCallWorkRequired,
|
||||
Confined: callPayload.Confined,
|
||||
ConnectedTime: connectedTime,
|
||||
DisconnectedTime: disconnectedTime,
|
||||
Direction: callPayload.Direction,
|
||||
DisconnectReasons: string(disconnectReasonsBytes),
|
||||
DisconnectType: callPayload.DisconnectType,
|
||||
Held: callPayload.Held,
|
||||
Id: callPayload.Id,
|
||||
InitialState: callPayload.InitialState,
|
||||
Muted: callPayload.Muted,
|
||||
Other: string(otherBytes),
|
||||
Provider: callPayload.Provider,
|
||||
Recording: callPayload.Recording,
|
||||
RecordingState: callPayload.RecordingState,
|
||||
SecurePause: callPayload.SecurePause,
|
||||
Self: string(selfBytes),
|
||||
State: callPayload.State,
|
||||
}
|
||||
|
||||
calls = append(calls, call)
|
||||
}
|
||||
}
|
||||
|
||||
return conversation, participants, calls
|
||||
|
||||
}
|
||||
|
||||
//func ExtractWithAttributes(base models.AnalyticsConversationWithAttributes) (models.DBConversation, []models.DBParticipant, []models.DBSession, []models.DBSegment) {
|
||||
//
|
||||
// var startTime *time.Time
|
||||
// parsedStartTime, err := time.Parse(time.RFC3339, base.ConversationStart)
|
||||
// if err != nil {
|
||||
// startTime = nil
|
||||
// } else {
|
||||
// startTime = &parsedStartTime
|
||||
// }
|
||||
//
|
||||
// var endTime *time.Time
|
||||
// parsedEndTime, err := time.Parse(time.RFC3339, base.ConversationEnd)
|
||||
// if err != nil {
|
||||
// endTime = nil
|
||||
// } else {
|
||||
// endTime = &parsedEndTime
|
||||
// }
|
||||
//
|
||||
// divisionIdsBytes, err := json.Marshal(base.DivisionIds)
|
||||
// if err != nil {
|
||||
// divisionIdsBytes = nil
|
||||
// }
|
||||
// divisionIdsBytesStr := string(divisionIdsBytes)
|
||||
//
|
||||
// conversation := models.DBConversation{
|
||||
// DivisionIds: &divisionIdsBytesStr,
|
||||
// End: endTime,
|
||||
// Id: base.ConversationId,
|
||||
// MinMos: &base.MediaStatsMinConversationMos,
|
||||
// MinRFactor: &base.MediaStatsMinConversationRFactor,
|
||||
// OriginatingDirection: &base.OriginatingDirection,
|
||||
// Start: startTime,
|
||||
// }
|
||||
// var participants []models.DBParticipant
|
||||
// var sessions []models.DBSession
|
||||
// var segments []models.DBSegment
|
||||
//
|
||||
// for _, p := range base.Participants {
|
||||
//
|
||||
// attributesBytes, err := json.Marshal(p.Attributes)
|
||||
// if err != nil {
|
||||
// attributesBytes = nil
|
||||
// }
|
||||
// attributesBytesStr := string(attributesBytes)
|
||||
//
|
||||
// participant := models.DBParticipant{
|
||||
// ConnectedTime: nil,
|
||||
// ConversationId: base.ConversationId,
|
||||
// EndTime: nil,
|
||||
// ExternalContactId: &p.ExternalContactId,
|
||||
// Id: p.ParticipantId,
|
||||
// Name: &p.ParticipantName,
|
||||
// Purpose: &p.Purpose,
|
||||
// Attributes: &attributesBytesStr,
|
||||
// }
|
||||
// participants = append(participants, participant)
|
||||
//
|
||||
// for _, sess := range p.Sessions {
|
||||
// mediaEndpointStatsBytes, err := json.Marshal(sess.MediaEndpointStats)
|
||||
// if err != nil {
|
||||
// mediaEndpointStatsBytes = nil
|
||||
// }
|
||||
//
|
||||
// metricsBytes, err := json.Marshal(sess.Metrics)
|
||||
// if err != nil {
|
||||
// metricsBytes = nil
|
||||
// }
|
||||
//
|
||||
// session := models.DBSession{
|
||||
// Ani: sess.ANI,
|
||||
// Direction: sess.Direction,
|
||||
// Dnis: sess.DNIS,
|
||||
// EdgeId: sess.EdgeId,
|
||||
// Id: fmt.Sprintf("%s_%s", p.ParticipantId, sess.SessionId),
|
||||
// MediaEndpointStats: string(mediaEndpointStatsBytes),
|
||||
// MediaType: sess.MediaType,
|
||||
// Metrics: string(metricsBytes),
|
||||
// ParticipantId: p.ParticipantId,
|
||||
// ProtocolCallId: sess.ProtocolCallId,
|
||||
// Provider: sess.Provider,
|
||||
// Recording: sess.Recording,
|
||||
// RemoteNameDisplayable: sess.RemoteNameDisplayable,
|
||||
// SessionDnis: sess.SessionDnis,
|
||||
// }
|
||||
// sessions = append(sessions, session)
|
||||
//
|
||||
// for _, seg := range sess.Segments {
|
||||
//
|
||||
// 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()
|
||||
// }
|
||||
//
|
||||
// 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,
|
||||
// DisconnectType: seg.DisconnectType,
|
||||
// Q850ResponseCodes: string(q850ResponseCodesBytes),
|
||||
// SegmentEnd: segmentEnd,
|
||||
// SegmentStart: segmentStart,
|
||||
// SegmentType: seg.SegmentType,
|
||||
// SessionId: sess.SessionId,
|
||||
// WrapUpCode: seg.WrapUpCode,
|
||||
// }
|
||||
//
|
||||
// segments = append(segments, segment)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return conversation, participants, sessions, segments
|
||||
//}
|
||||
Reference in New Issue
Block a user