This commit is contained in:
alin104n
2017-02-27 00:50:25 +02:00
72 changed files with 2325 additions and 1095 deletions

View File

@@ -133,31 +133,42 @@
// "users_conns": [], // address where to reach the user service, empty to disable user profile functionality: <""|*internal|x.y.z.y:1234>
// "aliases_conns": [], // address where to reach the aliases service, empty to disable aliases functionality: <""|*internal|x.y.z.y:1234>
// "cdrstats_conns": [], // address where to reach the cdrstats service, empty to disable stats functionality<""|*internal|x.y.z.y:1234>
// "cdr_replication":[
// // { // sample replication, not configured by default
// // "transport": "*amqp_json_map", // mechanism to use when replicating
// // "address": "http://127.0.0.1:12080/cdr_json_map", // address where to replicate
// // "attempts": 1, // number of attempts for POST before failing on file
// // "cdr_filter": "", // filter the CDRs being replicated
// // "content_fields": [ // template of the replicated content fields
// // {"tag": "CGRID", "type": "*composed", "value": "CGRID", "field_id": "CGRID"},
// // {"tag":"RunID", "type": "*composed", "value": "RunID", "field_id": "RunID"},
// // {"tag":"TOR", "type": "*composed", "value": "ToR", "field_id": "ToR"},
// // {"tag":"OriginID", "type": "*composed", "value": "OriginID", "field_id": "OriginID"},
// // {"tag":"RequestType", "type": "*composed", "value": "RequestType", "field_id": "RequestType"},
// // {"tag":"Direction", "type": "*composed", "value": "Direction", "field_id": "Direction"},
// // {"tag":"Tenant", "type": "*composed", "value": "Tenant", "field_id": "Tenant"},
// // {"tag":"Category", "type": "*composed", "value": "Category", "field_id": "Category"},
// // {"tag":"Account", "type": "*composed", "value": "Account", "field_id": "Account"},
// // {"tag":"Subject", "type": "*composed", "value": "Subject", "field_id": "Subject"},
// // {"tag":"Destination", "type": "*composed", "value": "Destination", "field_id": "Destination"},
// // {"tag":"SetupTime", "type": "*composed", "value": "SetupTime", "layout": "2006-01-02T15:04:05Z07:00", "field_id": "SetupTime"},
// // {"tag":"AnswerTime", "type": "*composed", "value": "AnswerTime", "layout": "2006-01-02T15:04:05Z07:00", "field_id": "AnswerTime"},
// // {"tag":"Usage", "type": "*composed", "value": "Usage", "field_id": "Usage"},
// // {"tag":"Cost", "type": "*composed", "value": "Cost", "field_id": "Cost"},
// // ],
// // },
// ]
// "online_cdr_exports":[], // list of CDRE profiles to use for real-time CDR exports
// },
// "cdre": {
// "*default": {
// "export_format": "*file_csv", // exported CDRs format <*file_csv|*file_fwv|*http_post|*http_json_cdr|*http_json_map|*amqp_json_cdr|*amqp_json_map>
// "export_path": "/var/spool/cgrates/cdre", // path where the exported CDRs will be placed
// "cdr_filter": "", // filter CDRs exported by this template
// "synchronous": false, // block processing until export has a result
// "attempts": 1, // Number of attempts if not success
// "field_separator": ",", // used field separator in some export formats, eg: *file_csv
// "usage_multiply_factor": {
// "*any": 1 // multiply usage based on ToR field or *any for all
// },
// "cost_multiply_factor": 1, // multiply cost before export, eg: add VAT
// "header_fields": [], // template of the exported header fields
// "content_fields": [ // template of the exported content fields
// {"tag": "CGRID", "type": "*composed", "value": "CGRID"},
// {"tag":"RunID", "type": "*composed", "value": "RunID"},
// {"tag":"TOR", "type": "*composed", "value": "ToR"},
// {"tag":"OriginID", "type": "*composed", "value": "OriginID"},
// {"tag":"RequestType", "type": "*composed", "value": "RequestType"},
// {"tag":"Direction", "type": "*composed", "value": "Direction"},
// {"tag":"Tenant", "type": "*composed", "value": "Tenant"},
// {"tag":"Category", "type": "*composed", "value": "Category"},
// {"tag":"Account", "type": "*composed", "value": "Account"},
// {"tag":"Subject", "type": "*composed", "value": "Subject"},
// {"tag":"Destination", "type": "*composed", "value": "Destination"},
// {"tag":"SetupTime", "type": "*composed", "value": "SetupTime", "layout": "2006-01-02T15:04:05Z07:00"},
// {"tag":"AnswerTime", "type": "*composed", "value": "AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
// {"tag":"Usage", "type": "*composed", "value": "Usage"},
// {"tag":"Cost", "type": "*composed", "value": "Cost", "rounding_decimals": 4},
// ],
// "trailer_fields": [], // template of the exported trailer fields
// },
// },
@@ -227,39 +238,6 @@
// ],
// "cdre": {
// "*default": {
// "cdr_format": "csv", // exported CDRs format <csv>
// "field_separator": ",",
// "data_usage_multiply_factor": 1, // multiply data usage before export (eg: convert from KBytes to Bytes)
// "sms_usage_multiply_factor": 1, // multiply data usage before export (eg: convert from SMS unit to call duration in some billing systems)
// "mms_usage_multiply_factor": 1, // multiply data usage before export (eg: convert from MMS unit to call duration in some billing systems)
// "generic_usage_multiply_factor": 1, // multiply data usage before export (eg: convert from GENERIC unit to call duration in some billing systems)
// "cost_multiply_factor": 1, // multiply cost before export, eg: add VAT
// "export_directory": "/var/spool/cgrates/cdre", // path where the exported CDRs will be placed
// "header_fields": [], // template of the exported header fields
// "content_fields": [ // template of the exported content fields
// {"tag": "CGRID", "type": "*composed", "value": "CGRID"},
// {"tag":"RunID", "type": "*composed", "value": "RunID"},
// {"tag":"TOR", "type": "*composed", "value": "ToR"},
// {"tag":"OriginID", "type": "*composed", "value": "OriginID"},
// {"tag":"RequestType", "type": "*composed", "value": "RequestType"},
// {"tag":"Direction", "type": "*composed", "value": "Direction"},
// {"tag":"Tenant", "type": "*composed", "value": "Tenant"},
// {"tag":"Category", "type": "*composed", "value": "Category"},
// {"tag":"Account", "type": "*composed", "value": "Account"},
// {"tag":"Subject", "type": "*composed", "value": "Subject"},
// {"tag":"Destination", "type": "*composed", "value": "Destination"},
// {"tag":"SetupTime", "type": "*composed", "value": "SetupTime", "layout": "2006-01-02T15:04:05Z07:00"},
// {"tag":"AnswerTime", "type": "*composed", "value": "AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
// {"tag":"Usage", "type": "*composed", "value": "Usage"},
// {"tag":"Cost", "type": "*composed", "value": "Cost", "rounding_decimals": 4},
// ],
// "trailer_fields": [], // template of the exported trailer fields
// },
// },
// "sm_generic": {
// "enabled": false, // starts SessionManager service: <true|false>
// "listen_bijson": "127.0.0.1:2014", // address where to listen for bidirectional JSON-RPC requests

View File

@@ -57,7 +57,7 @@
"cdre": {
"*default": {
"export_dir": "/tmp/cgrates/cdr/cdrexport/csv", // path where the exported CDRs will be placed
"export_path": "/tmp/cgrates/cdr/cdrexport/csv", // path where the exported CDRs will be placed
}
},

View File

@@ -0,0 +1,88 @@
{
// CGRateS Configuration file
//
// Used in apier_local_tests
// Starts rater, cdrs and mediator connecting over internal channel
"general": {
"log_level": 7,
"poster_attempts": 1,
},
"rals": {
"enabled": true, // enable Rater service: <true|false>
},
"cdrs": {
"enabled": true, // start the CDR Server service: <true|false>
"store_cdrs": false, // store cdrs in storDb
"online_cdr_exports": ["http_localhost", "amqp_localhost", "http_test_file", "amqp_test_file"],
},
"cdre": {
"http_localhost": {
"export_format": "*http_post",
"export_path": "http://127.0.0.1:12080/cdr_http",
"cdr_filter": "RunID(*default);OriginID(httpjsonrpc1)",
"content_fields": [ // template of the exported content fields
{"tag": "CGRID", "type": "*composed", "value": "CGRID", "field_id": "CGRID"},
{"tag":"RunID", "type": "*composed", "value": "RunID", "field_id": "RunID"},
{"tag":"TOR", "type": "*composed", "value": "ToR", "field_id": "ToR"},
{"tag":"OriginID", "type": "*composed", "value": "OriginID", "field_id": "OriginID"},
{"tag":"OriginHost", "type": "*composed", "value": "OriginHost", "field_id": "OriginHost"},
{"tag":"RequestType", "type": "*composed", "value": "RequestType", "field_id": "RequestType"},
{"tag":"Direction", "type": "*composed", "value": "Direction", "field_id": "Direction"},
{"tag":"Tenant", "type": "*composed", "value": "Tenant", "field_id": "Tenant"},
{"tag":"Category", "type": "*composed", "value": "Category", "field_id": "Category"},
{"tag":"Account", "type": "*composed", "value": "Account", "field_id": "Account"},
{"tag":"Subject", "type": "*composed", "value": "Subject", "field_id": "Subject"},
{"tag":"Destination", "type": "*composed", "value": "Destination", "field_id": "Destination"},
{"tag":"SetupTime", "type": "*composed", "value": "SetupTime", "layout": "2006-01-02T15:04:05Z07:00", "field_id": "SetupTime"},
{"tag":"AnswerTime", "type": "*composed", "value": "AnswerTime", "layout": "2006-01-02T15:04:05Z07:00", "field_id": "AnswerTime"},
{"tag":"Usage", "type": "*composed", "value": "Usage", "field_id": "Usage"},
{"tag":"Cost", "type": "*composed", "value": "Cost", "field_id": "Cost"},
],
},
"amqp_localhost": {
"export_format": "*amqp_json_map",
"export_path": "amqp://guest:guest@localhost:5672/?queue_id=cgrates_cdrs",
"attempts": 3,
"cdr_filter": "RunID(*default)",
"content_fields": [ // template of the exported content fields
{"tag": "CGRID", "type": "*composed", "value": "CGRID", "field_id": "CGRID"},
{"tag":"RunID", "type": "*composed", "value": "RunID", "field_id": "RunID"},
{"tag":"TOR", "type": "*composed", "value": "ToR", "field_id": "ToR"},
{"tag":"OriginID", "type": "*composed", "value": "OriginID", "field_id": "OriginID"},
{"tag":"OriginHost", "type": "*composed", "value": "OriginHost", "field_id": "OriginHost"},
{"tag":"RequestType", "type": "*composed", "value": "RequestType", "field_id": "RequestType"},
{"tag":"Direction", "type": "*composed", "value": "Direction", "field_id": "Direction"},
{"tag":"Tenant", "type": "*composed", "value": "Tenant", "field_id": "Tenant"},
{"tag":"Category", "type": "*composed", "value": "Category", "field_id": "Category"},
{"tag":"Account", "type": "*composed", "value": "Account", "field_id": "Account"},
{"tag":"Subject", "type": "*composed", "value": "Subject", "field_id": "Subject"},
{"tag":"Destination", "type": "*composed", "value": "Destination", "field_id": "Destination"},
{"tag":"SetupTime", "type": "*composed", "value": "SetupTime", "layout": "2006-01-02T15:04:05Z07:00", "field_id": "SetupTime"},
{"tag":"AnswerTime", "type": "*composed", "value": "AnswerTime", "layout": "2006-01-02T15:04:05Z07:00", "field_id": "AnswerTime"},
{"tag":"Usage", "type": "*composed", "value": "Usage", "field_id": "Usage"},
{"tag":"Cost", "type": "*composed", "value": "Cost", "field_id": "Cost"},
],
},
"http_test_file": {
"export_format": "*http_post",
"export_path": "http://127.0.0.1:12080/invalid",
"cdr_filter": "OriginID(httpjsonrpc1)",
"content_fields": [
{"tag": "OriginID", "type": "*composed", "value": "OriginID", "field_id": "OriginID"},
],
},
"amqp_test_file": {
"export_format": "*amqp_json_map",
"export_path": "amqp://guest:guest@localhost:25672/?queue_id=cgrates_cdrs",
"content_fields": [
{"tag": "CGRID", "type": "*composed", "value": "CGRID", "field_id": "CGRID"},
],
},
},
}

View File

@@ -1,88 +0,0 @@
{
// CGRateS Configuration file
//
// Used in apier_local_tests
// Starts rater, cdrs and mediator connecting over internal channel
"general": {
"log_level": 7,
"poster_attempts": 1,
},
"rals": {
"enabled": true, // enable Rater service: <true|false>
},
"cdrs": {
"enabled": true, // start the CDR Server service: <true|false>
"store_cdrs": false, // store cdrs in storDb
"cdr_replication":[ // replicate the rated CDR to a number of servers
{
"transport": "*http_post",
"address": "http://127.0.0.1:12080/cdr_http",
"attempts": 1,
"cdr_filter": "RunID(*default)",
"content_fields": [
{"tag": "CGRID", "type": "*composed", "value": "CGRID", "field_id": "CGRID"},
{"tag":"RunID", "type": "*composed", "value": "RunID", "field_id": "RunID"},
{"tag":"TOR", "type": "*composed", "value": "ToR", "field_id": "ToR"},
{"tag":"OriginID", "type": "*composed", "value": "OriginID", "field_id": "OriginID"},
{"tag":"OriginHost", "type": "*composed", "value": "OriginHost", "field_id": "OriginHost"},
{"tag":"RequestType", "type": "*composed", "value": "RequestType", "field_id": "RequestType"},
{"tag":"Direction", "type": "*composed", "value": "Direction", "field_id": "Direction"},
{"tag":"Tenant", "type": "*composed", "value": "Tenant", "field_id": "Tenant"},
{"tag":"Category", "type": "*composed", "value": "Category", "field_id": "Category"},
{"tag":"Account", "type": "*composed", "value": "Account", "field_id": "Account"},
{"tag":"Subject", "type": "*composed", "value": "Subject", "field_id": "Subject"},
{"tag":"Destination", "type": "*composed", "value": "Destination", "field_id": "Destination"},
{"tag":"SetupTime", "type": "*composed", "value": "SetupTime", "layout": "2006-01-02T15:04:05Z07:00", "field_id": "SetupTime"},
{"tag":"AnswerTime", "type": "*composed", "value": "AnswerTime", "layout": "2006-01-02T15:04:05Z07:00", "field_id": "AnswerTime"},
{"tag":"Usage", "type": "*composed", "value": "Usage", "field_id": "Usage"},
{"tag":"Cost", "type": "*composed", "value": "Cost", "field_id": "Cost"},
],
},
{
"transport": "*amqp_json_map",
"address": "amqp://guest:guest@localhost:5672/?queue_id=cgrates_cdrs",
"attempts": 1,
"cdr_filter": "",
"content_fields": [
{"tag": "CGRID", "type": "*composed", "value": "CGRID", "field_id": "CGRID"},
{"tag":"RunID", "type": "*composed", "value": "RunID", "field_id": "RunID"},
{"tag":"TOR", "type": "*composed", "value": "ToR", "field_id": "ToR"},
{"tag":"OriginID", "type": "*composed", "value": "OriginID", "field_id": "OriginID"},
{"tag":"OriginHost", "type": "*composed", "value": "OriginHost", "field_id": "OriginHost"},
{"tag":"RequestType", "type": "*composed", "value": "RequestType", "field_id": "RequestType"},
{"tag":"Direction", "type": "*composed", "value": "Direction", "field_id": "Direction"},
{"tag":"Tenant", "type": "*composed", "value": "Tenant", "field_id": "Tenant"},
{"tag":"Category", "type": "*composed", "value": "Category", "field_id": "Category"},
{"tag":"Account", "type": "*composed", "value": "Account", "field_id": "Account"},
{"tag":"Subject", "type": "*composed", "value": "Subject", "field_id": "Subject"},
{"tag":"Destination", "type": "*composed", "value": "Destination", "field_id": "Destination"},
{"tag":"SetupTime", "type": "*composed", "value": "SetupTime", "layout": "2006-01-02T15:04:05Z07:00", "field_id": "SetupTime"},
{"tag":"AnswerTime", "type": "*composed", "value": "AnswerTime", "layout": "2006-01-02T15:04:05Z07:00", "field_id": "AnswerTime"},
{"tag":"Usage", "type": "*composed", "value": "Usage", "field_id": "Usage"},
{"tag":"Cost", "type": "*composed", "value": "Cost", "field_id": "Cost"},
],
},
{
"transport": "*http_post",
"address": "http://127.0.0.1:12080/invalid",
"cdr_filter": "OriginID(httpjsonrpc1)",
"attempts": 1,
"content_fields": [
{"tag": "OriginID", "type": "*composed", "value": "OriginID", "field_id": "OriginID"},
],
},
{
"transport": "*amqp_json_map",
"address": "amqp://guest:guest@localhost:25672/?queue_id=cgrates_cdrs",
"attempts": 1,
"content_fields": [
{"tag": "CGRID", "type": "*composed", "value": "CGRID", "field_id": "CGRID"},
],
},
],
},
}

View File

@@ -4,6 +4,10 @@
// Used in apier_local_tests
// Starts rater, cdrs and mediator connecting over internal channel
"general": {
"log_level": 7,
},
"stor_db": {
"db_type": "mongo", // stor database type to use: <mysql|postgres>
"db_port": 27017, // the port to reach the stordb

View File

@@ -4,6 +4,11 @@
// Used in apier_local_tests
// Starts rater, cdrs and mediator connecting over internal channel
"general": {
"log_level": 7,
},
"rals": {
"enabled": true, // enable Rater service: <true|false>
},

View File

@@ -9,8 +9,8 @@
"cdre": {
"*default": {
"data_usage_multiply_factor": 1024, // multiply data usage before export (eg: convert from KBytes to Bytes)
"export_dir": "/tmp/cgrates/cdre", // path where the exported CDRs will be placed
"cost_multiply_factor": 1024, // multiply data usage before export (eg: convert from KBytes to Bytes)
"export_path": "/tmp/cgrates/cdre", // path where the exported CDRs will be placed
},
"export1": {
"header_fields": [

View File

@@ -71,7 +71,7 @@
"cdre": {
"CDRE-FW1": {
"cdr_format": "fwv",
"export_format": "*file_fwv",
"field_separator": "",
"header_fields": [
{"tag": "ToR", "type": "constant", "value": "10", "width": 2},

View File

@@ -32,6 +32,7 @@
"resource_limits": {"limit": 10000, "ttl":"0s", "precache": true},
},
"rals": {
"enabled": true,
"cdrstats_conns": [
@@ -52,6 +53,7 @@
"enabled": true,
},
"cdrs": {
"enabled": true,
"cdrstats_conns": [
@@ -59,10 +61,32 @@
],
},
"cdre": {
"TestTutITExportCDR": {
"content_fields": [ // template of the exported content fields
{"tag": "CGRID", "type": "*composed", "value": "CGRID"},
{"tag": "RunID", "type": "*composed", "value": "RunID"},
{"tag":"OriginID", "type": "*composed", "value": "OriginID"},
{"tag":"RequestType", "type": "*composed", "value": "RequestType"},
{"tag":"Tenant", "type": "*composed", "value": "Tenant"},
{"tag":"Category", "type": "*composed", "value": "Category"},
{"tag":"Account", "type": "*composed", "value": "Account"},
{"tag":"Destination", "type": "*composed", "value": "Destination"},
{"tag":"AnswerTime", "type": "*composed", "value": "AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
{"tag":"Usage", "type": "*composed", "value": "Usage"},
{"tag":"Cost", "type": "*composed", "value": "Cost", "rounding_decimals": 4},
{"tag":"MatchedDestinationID", "type": "*composed", "value": "~CostDetails:s/\"MatchedDestId\":.*_(\\w{4})/${1}/:s/\"MatchedDestId\":\"INTERNAL\"/ON010/"},
],
},
},
"cdrstats": {
"enabled": true, // starts the cdrstats service: <true|false>
},
"pubsubs": {
"enabled": true, // starts PubSub service: <true|false>.
},
@@ -88,23 +112,4 @@
"enabled": true, // starts Aliases service: <true|false>.
},
"cdre": {
"TestTutITExportCDR": {
"content_fields": [ // template of the exported content fields
{"tag": "CGRID", "type": "*composed", "value": "CGRID"},
{"tag": "RunID", "type": "*composed", "value": "RunID"},
{"tag":"OriginID", "type": "*composed", "value": "OriginID"},
{"tag":"RequestType", "type": "*composed", "value": "RequestType"},
{"tag":"Tenant", "type": "*composed", "value": "Tenant"},
{"tag":"Category", "type": "*composed", "value": "Category"},
{"tag":"Account", "type": "*composed", "value": "Account"},
{"tag":"Destination", "type": "*composed", "value": "Destination"},
{"tag":"AnswerTime", "type": "*composed", "value": "AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
{"tag":"Usage", "type": "*composed", "value": "Usage"},
{"tag":"Cost", "type": "*composed", "value": "Cost", "rounding_decimals": 4},
{"tag":"MatchedDestinationID", "type": "*composed", "value": "~CostDetails:s/\"MatchedDestId\":.*_(\\w{4})/${1}/:s/\"MatchedDestId\":\"INTERNAL\"/ON010/"},
],
},
},
}

View File

@@ -9,18 +9,20 @@ You can increase or lower the value of step in the line after BEGIN below.
You have to use 'CALL cgrates.migration();' to execute the script. If named other then default use that database name.
*/
DELIMITER //
CREATE PROCEDURE `migration`()
BEGIN
/* Optimize table for performance */
ALTER TABLE cdrs DISABLE KEYS;
SET autocommit=0;
SET unique_checks=0;
SET foreign_key_checks=0;
/* DECLARE variables */
DECLARE max_cdrs bigint;
DECLARE start_id bigint;
DECLARE end_id bigint;
DECLARE step bigint;
/* Optimize table for performance */
ALTER TABLE cdrs DISABLE KEYS;
SET autocommit=0;
SET unique_checks=0;
SET foreign_key_checks=0;
/* You must change the step var to commit every step rows inserted */
SET step := 10000;
SET start_id := 0;
@@ -28,17 +30,39 @@ BEGIN
SET max_cdrs = (select max(id) from rated_cdrs);
WHILE (start_id <= max_cdrs) DO
INSERT INTO
cdrs(cgrid,run_id,origin_host,source,origin_id,tor,request_type,direction,tenant,category,account,subject,destination,setup_time,pdd,answer_time,`usage`,supplier,disconnect_cause,extra_fields,cost_source,cost,cost_details,extra_info, created_at, updated_at, deleted_at)
SELECT cdrs_primary.cgrid,rated_cdrs.runid as run_id,cdrs_primary.cdrhost as origin_host,cdrs_primary.cdrsource as source,cdrs_primary.accid as origin_id, cdrs_primary.tor,rated_cdrs.reqtype as request_type,rated_cdrs.direction, rated_cdrs.tenant,rated_cdrs.category, rated_cdrs.account, rated_cdrs.subject, rated_cdrs.destination,rated_cdrs.setup_time,rated_cdrs.pdd,rated_cdrs.answer_time,rated_cdrs.`usage`,rated_cdrs.supplier,rated_cdrs.disconnect_cause,cdrs_extra.extra_fields,cost_details.cost_source,rated_cdrs.cost,cost_details.timespans as cost_details,rated_cdrs.extra_info,rated_cdrs.created_at,rated_cdrs.updated_at, rated_cdrs.deleted_at
cdrs(cgrid,run_id,origin_host,source,origin_id,tor,request_type,direction,tenant,category,account,subject,destination,setup_time,answer_time,`usage`,supplier,extra_fields,cost,extra_info, created_at, updated_at, deleted_at)
SELECT
cdrs_primary.cgrid,
rated_cdrs.runid as run_id,
cdrs_primary.cdrhost as origin_host,
cdrs_primary.cdrsource as source,
cdrs_primary.accid as origin_id,
cdrs_primary.tor,
rated_cdrs.reqtype as request_type,
rated_cdrs.direction,
rated_cdrs.tenant,rated_cdrs.category,
rated_cdrs.account,
rated_cdrs.subject,
rated_cdrs.destination,
rated_cdrs.setup_time,
rated_cdrs.answer_time,
rated_cdrs.`usage`,
rated_cdrs.supplier,
cdrs_extra.extra_fields,
rated_cdrs.cost,
rated_cdrs.extra_info,
rated_cdrs.created_at,
rated_cdrs.updated_at,
rated_cdrs.deleted_at
FROM rated_cdrs
INNER JOIN cdrs_primary ON rated_cdrs.cgrid = cdrs_primary.cgrid
LEFT JOIN cdrs_extra ON rated_cdrs.cgrid = cdrs_extra.cgrid
INNER JOIN cost_details ON rated_cdrs.cgrid = cost_details.cgrid
INNER JOIN cdrs_primary ON rated_cdrs.cgrid = cdrs_primary.cgrid
LEFT JOIN cdrs_extra ON rated_cdrs.cgrid = cdrs_extra.cgrid
INNER JOIN cost_details ON rated_cdrs.cgrid = cost_details.cgrid
WHERE cdrs_primary.`usage` > '0'
AND not exists (select 1 from cdrs c where c.cgrid = cdrs_primary.cgrid)
AND rated_cdrs.id >= start_id
AND rated_cdrs.id < end_id
GROUP BY cgrid, run_id, origin_id;
AND not exists (select 1 from cdrs c where c.cgrid = cdrs_primary.cgrid)
AND rated_cdrs.id >= start_id
AND rated_cdrs.id < end_id
GROUP BY cgrid, run_id, origin_id;
SET start_id = start_id + step;
SET end_id = end_id + step;
END WHILE;
@@ -48,4 +72,6 @@ BEGIN
SET foreign_key_checks=1;
ALTER TABLE cdrs ENABLE KEYS;
OPTIMIZE TABLE cdrs;
END
END //
DELIMITER ;