Fixed ExtractWithAttributes
This commit is contained in:
242
util/extract.go
242
util/extract.go
@@ -262,125 +262,123 @@ 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)
|
||||||
//
|
|
||||||
// conversation := models.DBConversation{
|
conversation := models.DBConversation{
|
||||||
// DivisionIds: &divisionIdsBytesStr,
|
DivisionIds: &divisionIdsBytesStr,
|
||||||
// End: endTime,
|
End: endTime,
|
||||||
// Id: base.ConversationId,
|
Id: base.ConversationId,
|
||||||
// MinMos: &base.MediaStatsMinConversationMos,
|
MinMos: &base.MediaStatsMinConversationMos,
|
||||||
// MinRFactor: &base.MediaStatsMinConversationRFactor,
|
MinRFactor: &base.MediaStatsMinConversationRFactor,
|
||||||
// OriginatingDirection: &base.OriginatingDirection,
|
OriginatingDirection: &base.OriginatingDirection,
|
||||||
// Start: startTime,
|
Start: startTime,
|
||||||
// }
|
}
|
||||||
// var participants []models.DBParticipant
|
var participants []models.DBParticipant
|
||||||
// var sessions []models.DBSession
|
var sessions []models.DBSession
|
||||||
// var segments []models.DBSegment
|
var segments []models.DBSegment
|
||||||
//
|
|
||||||
// for _, p := range base.Participants {
|
for _, p := range base.Participants {
|
||||||
//
|
|
||||||
// attributesBytes, err := json.Marshal(p.Attributes)
|
attributesBytes, err := json.Marshal(p.Attributes)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// attributesBytes = nil
|
attributesBytes = nil
|
||||||
// }
|
}
|
||||||
// attributesBytesStr := string(attributesBytes)
|
attributesBytesStr := string(attributesBytes)
|
||||||
//
|
|
||||||
// participant := models.DBParticipant{
|
participant := models.DBParticipant{
|
||||||
// ConnectedTime: nil,
|
ConversationId: base.ConversationId,
|
||||||
// ConversationId: base.ConversationId,
|
ExternalContactId: &p.ExternalContactId,
|
||||||
// EndTime: nil,
|
Id: p.ParticipantId,
|
||||||
// ExternalContactId: &p.ExternalContactId,
|
Name: &p.ParticipantName,
|
||||||
// Id: p.ParticipantId,
|
Purpose: &p.Purpose,
|
||||||
// Name: &p.ParticipantName,
|
Attributes: &attributesBytesStr,
|
||||||
// Purpose: &p.Purpose,
|
}
|
||||||
// Attributes: &attributesBytesStr,
|
participants = append(participants, participant)
|
||||||
// }
|
|
||||||
// participants = append(participants, participant)
|
for _, sess := range p.Sessions {
|
||||||
//
|
mediaEndpointStatsBytes, err := json.Marshal(sess.MediaEndpointStats)
|
||||||
// for _, sess := range p.Sessions {
|
if err != nil {
|
||||||
// mediaEndpointStatsBytes, err := json.Marshal(sess.MediaEndpointStats)
|
mediaEndpointStatsBytes = nil
|
||||||
// if err != nil {
|
}
|
||||||
// mediaEndpointStatsBytes = nil
|
|
||||||
// }
|
metricsBytes, err := json.Marshal(sess.Metrics)
|
||||||
//
|
if err != nil {
|
||||||
// metricsBytes, err := json.Marshal(sess.Metrics)
|
metricsBytes = nil
|
||||||
// if err != nil {
|
}
|
||||||
// metricsBytes = nil
|
|
||||||
// }
|
session := models.DBSession{
|
||||||
//
|
Ani: sess.ANI,
|
||||||
// session := models.DBSession{
|
Direction: sess.Direction,
|
||||||
// Ani: sess.ANI,
|
Dnis: sess.DNIS,
|
||||||
// Direction: sess.Direction,
|
EdgeId: sess.EdgeId,
|
||||||
// Dnis: sess.DNIS,
|
Id: fmt.Sprintf("%s_%s", p.ParticipantId, sess.SessionId),
|
||||||
// EdgeId: sess.EdgeId,
|
MediaEndpointStats: string(mediaEndpointStatsBytes),
|
||||||
// Id: fmt.Sprintf("%s_%s", p.ParticipantId, sess.SessionId),
|
MediaType: sess.MediaType,
|
||||||
// MediaEndpointStats: string(mediaEndpointStatsBytes),
|
Metrics: string(metricsBytes),
|
||||||
// MediaType: sess.MediaType,
|
ParticipantId: p.ParticipantId,
|
||||||
// Metrics: string(metricsBytes),
|
ProtocolCallId: sess.ProtocolCallId,
|
||||||
// ParticipantId: p.ParticipantId,
|
Provider: sess.Provider,
|
||||||
// ProtocolCallId: sess.ProtocolCallId,
|
Recording: sess.Recording,
|
||||||
// Provider: sess.Provider,
|
RemoteNameDisplayable: sess.RemoteNameDisplayable,
|
||||||
// Recording: sess.Recording,
|
SessionDnis: sess.SessionDnis,
|
||||||
// RemoteNameDisplayable: sess.RemoteNameDisplayable,
|
}
|
||||||
// SessionDnis: sess.SessionDnis,
|
sessions = append(sessions, session)
|
||||||
// }
|
|
||||||
// sessions = append(sessions, session)
|
for idx, seg := range sess.Segments {
|
||||||
//
|
|
||||||
// for _, seg := range sess.Segments {
|
segmentStart, err := time.Parse(time.RFC3339, seg.SegmentStart)
|
||||||
//
|
if err != nil {
|
||||||
// segmentStart, err := time.Parse(time.RFC3339, seg.SegmentStart)
|
segmentStart = time.Now()
|
||||||
// if err != nil {
|
}
|
||||||
// segmentStart = time.Now()
|
|
||||||
// }
|
segmentEnd, err := time.Parse(time.RFC3339, seg.SegmentEnd)
|
||||||
//
|
if err != nil {
|
||||||
// segmentEnd, err := time.Parse(time.RFC3339, seg.SegmentEnd)
|
segmentEnd = time.Now()
|
||||||
// if err != nil {
|
}
|
||||||
// segmentEnd = time.Now()
|
|
||||||
// }
|
q850ResponseCodesBytes, err := json.Marshal(seg.Q850ResponseCodes)
|
||||||
//
|
if err != nil {
|
||||||
// q850ResponseCodesBytes, err := json.Marshal(seg.Q850ResponseCodes)
|
q850ResponseCodesBytes = nil
|
||||||
// if err != nil {
|
}
|
||||||
// q850ResponseCodesBytes = nil
|
|
||||||
// }
|
segment := models.DBSegment{
|
||||||
//
|
Id: fmt.Sprintf("%s_%s_%d", session.Id, seg.SegmentType, idx),
|
||||||
// segment := models.DBSegment{
|
Conference: seg.Conference,
|
||||||
// Id: fmt.Sprintf("%s_%s", session.Id, seg.SegmentType),
|
DisconnectType: seg.DisconnectType,
|
||||||
// Conference: seg.Conference,
|
Q850ResponseCodes: string(q850ResponseCodesBytes),
|
||||||
// DisconnectType: seg.DisconnectType,
|
SegmentEnd: segmentEnd,
|
||||||
// Q850ResponseCodes: string(q850ResponseCodesBytes),
|
SegmentStart: segmentStart,
|
||||||
// SegmentEnd: segmentEnd,
|
SegmentType: seg.SegmentType,
|
||||||
// SegmentStart: segmentStart,
|
SessionId: sess.SessionId,
|
||||||
// SegmentType: seg.SegmentType,
|
WrapUpCode: seg.WrapUpCode,
|
||||||
// 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