mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 05:09:54 +05:00
Revert "PartialRecordsCache with MergePartialCDR method"
This reverts commit a36812f063.
Conflicts:
cdrc/partial_cdr.go
This commit is contained in:
@@ -19,15 +19,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package cdrc
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"reflect"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
<<<<<<< HEAD
|
||||
const (
|
||||
PartialRecordsSuffix = ".partial"
|
||||
)
|
||||
@@ -61,9 +65,13 @@ func (prc *PartialRecordsCache) dumpPartialRecords(originID string) {
|
||||
}
|
||||
csvWriter := csv.NewWriter(fileOut)
|
||||
csvWriter.Comma = prc.csvSep
|
||||
for _, rec := range prc.partialRecords[originID].originalRecords {
|
||||
if err := csvWriter.Write(rec); err != nil {
|
||||
utils.Logger.Err(fmt.Sprintf("<Cdrc> Failed writing partial CDR record %v to file: %s, error: %s", rec, dumpFilePath, err.Error()))
|
||||
for _, cdr := range prc.partialRecords[originID].cdrs {
|
||||
expRec, err := cdr.AsExportRecord(prc.partialRecords[originID].cacheDumpFields, 0, prc.roundDecimals, prc.timezone, prc.httpSkipTlsCheck, 0, "", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := csvWriter.Write(expRec); err != nil {
|
||||
utils.Logger.Err(fmt.Sprintf("<Cdrc> Failed writing partial CDR %v to file: %s, error: %s", cdr, dumpFilePath, err.Error()))
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -105,15 +113,12 @@ func (prc *PartialRecordsCache) uncachePartialCDR(pCDR *PartialCDRRecord) {
|
||||
}
|
||||
|
||||
// Returns PartialCDR only if merge was possible
|
||||
func (prc *PartialRecordsCache) MergePartialCDRRecord(pCDR *PartialCDRRecord) (*engine.CDR, error) {
|
||||
func (prc *PartialRecordsCache) MergePartialCDR(pCDR *PartialCDRRecord) (*engine.CDR, error) {
|
||||
if pCDR.Len() == 0 || pCDR.cdrs[0].OriginID == "" { // Sanity check
|
||||
return nil, nil
|
||||
}
|
||||
originID := pCDR.cdrs[0].OriginID
|
||||
pCDRIf, err := prc.guard.Guard(func() (interface{}, error) {
|
||||
if _, hasIt := prc.partialRecords[originID]; !hasIt && pCDR.Len() == 1 && !pCDR.cdrs[0].Partial { // Special case when not a partial CDR and not having cached CDRs on same OriginID
|
||||
return pCDR, nil
|
||||
}
|
||||
cachedPartialCDR := prc.cachePartialCDR(pCDR)
|
||||
var final bool
|
||||
for _, cdr := range pCDR.cdrs {
|
||||
@@ -131,13 +136,11 @@ func (prc *PartialRecordsCache) MergePartialCDRRecord(pCDR *PartialCDRRecord) (*
|
||||
return pCDRIf.(*engine.CDR), err
|
||||
}
|
||||
|
||||
=======
|
||||
>>>>>>> parent of a36812f... PartialRecordsCache with MergePartialCDR method
|
||||
// PartialCDRRecord is a record which can be updated later
|
||||
// different from PartialFlatstoreRecordsCache which is incomplete (eg: need to calculate duration out of 2 records)
|
||||
type PartialCDRRecord struct {
|
||||
cdrs []*engine.CDR // Number of CDRs
|
||||
originalRecords [][]string // Keep here the original records so we can dump when needed
|
||||
cdrs []*engine.CDR // Number of CDRs
|
||||
cacheDumpFields []*config.CfgCdrField // Fields template to use when dumping from cache on disk
|
||||
}
|
||||
|
||||
// Part of sort interface
|
||||
@@ -213,5 +216,3 @@ func (partCDR *PartialCDRRecord) MergeCDRs() *engine.CDR {
|
||||
}
|
||||
return retCdr
|
||||
}
|
||||
|
||||
//func (partCDR *PartialCDRRecord) AsString() *engine.CDR {
|
||||
|
||||
Reference in New Issue
Block a user