From 3d20c99f647fa5a14e825f2ed9cf98601fb78d91 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Sat, 3 Oct 2015 00:28:03 +0300 Subject: [PATCH 1/4] added account info to balance from action --- engine/account.go | 1 + engine/balances.go | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/engine/account.go b/engine/account.go index 009723680..6f8a6ef5b 100644 --- a/engine/account.go +++ b/engine/account.go @@ -110,6 +110,7 @@ func (ub *Account) debitBalanceAction(a *Action, reset bool) error { if b.IsExpired() { continue // just to be safe (cleaned expired balances above) } + b.account = ub if b.MatchFilter(a.Balance) { if reset { b.SetValue(0) diff --git a/engine/balances.go b/engine/balances.go index 147a8220e..69ea789c5 100644 --- a/engine/balances.go +++ b/engine/balances.go @@ -312,27 +312,27 @@ func (b *Balance) SetValue(amount float64) { accountId := "" allowNegative := "" disabled := "" - if b.account != nil { + if b.account != nil { // only publish modifications for balances with account set accountId = b.account.Id allowNegative = strconv.FormatBool(b.account.AllowNegative) disabled = strconv.FormatBool(b.account.Disabled) + Publish(CgrEvent{ + "EventName": utils.EVT_ACCOUNT_BALANCE_MODIFIED, + "Uuid": b.Uuid, + "Id": b.Id, + "Value": strconv.FormatFloat(b.Value, 'f', -1, 64), + "ExpirationDate": b.ExpirationDate.String(), + "Weight": strconv.FormatFloat(b.Weight, 'f', -1, 64), + "DestinationIds": b.DestinationIds, + "RatingSubject": b.RatingSubject, + "Category": b.Category, + "SharedGroup": b.SharedGroup, + "TimingIDs": b.TimingIDs, + "Account": accountId, + "AccountAllowNegative": allowNegative, + "AccountDisabled": disabled, + }) } - Publish(CgrEvent{ - "EventName": utils.EVT_ACCOUNT_BALANCE_MODIFIED, - "Uuid": b.Uuid, - "Id": b.Id, - "Value": strconv.FormatFloat(b.Value, 'f', -1, 64), - "ExpirationDate": b.ExpirationDate.String(), - "Weight": strconv.FormatFloat(b.Weight, 'f', -1, 64), - "DestinationIds": b.DestinationIds, - "RatingSubject": b.RatingSubject, - "Category": b.Category, - "SharedGroup": b.SharedGroup, - "TimingIDs": b.TimingIDs, - "Account": accountId, - "AccountAllowNegative": allowNegative, - "AccountDisabled": disabled, - }) } func (b *Balance) DebitUnits(cd *CallDescriptor, ub *Account, moneyBalances BalanceChain, count bool, dryRun bool) (cc *CallCost, err error) { From b99f3baf39c155364a09c8eb33eb4d14a3becb65 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Sat, 3 Oct 2015 00:30:02 +0300 Subject: [PATCH 2/4] added cgrid in primary key and started indexes --- data/storage/cassandra/create_cdrs_tables.cql | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/data/storage/cassandra/create_cdrs_tables.cql b/data/storage/cassandra/create_cdrs_tables.cql index e3dfb7a79..d3ffcef19 100644 --- a/data/storage/cassandra/create_cdrs_tables.cql +++ b/data/storage/cassandra/create_cdrs_tables.cql @@ -6,7 +6,7 @@ drop table if exists cgrates.cdrs_primary; create table cgrates.cdrs_primary ( id uuid, - cgrid ascii, + cgrid text, tor text, accid text, cdrhost text, @@ -26,7 +26,7 @@ create table cgrates.cdrs_primary ( disconnect_cause text, created_at timestamp, deleted_at timestamp, - PRIMARY KEY (id), + PRIMARY KEY (id, cgrid), ); -- @@ -36,11 +36,11 @@ create table cgrates.cdrs_primary ( DROP TABLE IF EXISTS cgrates.cdrs_extra; CREATE TABLE cgrates.cdrs_extra ( id uuid, - cgrid ascii, + cgrid text, extra_fields text, created_at timestamp, deleted_at timestamp, - PRIMARY KEY (id), + PRIMARY KEY (id, cgrid), ); -- @@ -50,7 +50,7 @@ CREATE TABLE cgrates.cdrs_extra ( DROP TABLE IF EXISTS cgrates.cost_details; CREATE TABLE cgrates.cost_details ( id uuid, - cgrid ascii, + cgrid text, runid text, tor text, direction text, @@ -65,7 +65,7 @@ CREATE TABLE cgrates.cost_details ( created_at timestamp, updated_at timestamp, deleted_at timestamp, - PRIMARY KEY (id), + PRIMARY KEY (id, cgrid), ); -- @@ -74,7 +74,7 @@ CREATE TABLE cgrates.cost_details ( DROP TABLE IF EXISTS cgrates.rated_cdrs; CREATE TABLE cgrates.rated_cdrs ( id uuid, - cgrid ascii, + cgrid text, runid text, reqtype text, direction text, @@ -94,5 +94,29 @@ CREATE TABLE cgrates.rated_cdrs ( created_at timestamp, updated_at timestamp, deleted_at timestamp, - PRIMARY KEY (id), + PRIMARY KEY (id, cgrid), ); + + DROP TABLE IF EXISTS cgrates.string_index; + CREATE TABLE cgrates.string_index ( + field text, + value text, + id uuid, + PRIMARY KEY((field, value), id) + ); + + DROP TABLE IF EXISTS cgrates.decimal_index; + CREATE TABLE cgrates.decimal_index ( + field text, + value decimal, + id uuid, + PRIMARY KEY((field, value), id) + ); + + DROP TABLE IF EXISTS cgrates.time_index; + CREATE TABLE cgrates.time_index ( + field text, + value timestamp, + id uuid, + PRIMARY KEY((field, value), id) + ); From 0a2d60c01a735af9ded8fcd294cf5ff69edac192 Mon Sep 17 00:00:00 2001 From: kjcsb1 Date: Sat, 3 Oct 2015 13:08:57 +1300 Subject: [PATCH 3/4] Correct links --- docs/csv_tpdestinationrates.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/csv_tpdestinationrates.rst b/docs/csv_tpdestinationrates.rst index 32f73165a..8e7a6240c 100644 --- a/docs/csv_tpdestinationrates.rst +++ b/docs/csv_tpdestinationrates.rst @@ -25,8 +25,8 @@ Index 2 - *RatesTag* References profile defined in Rates.csv_. -.. _Destinations.csv: csv_tpdestinations.html -.. _Rates.csv: csv_tprates.html +.. _Destinations.csv: csv_tpdestinations.rst +.. _Rates.csv: csv_tprates.rst From bd249b84419bb8d26f6589be8d31aa3329b85325 Mon Sep 17 00:00:00 2001 From: kjcsb1 Date: Sun, 4 Oct 2015 07:13:41 +1300 Subject: [PATCH 4/4] Added contributor --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 099bf3142..8289f9683 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -37,6 +37,7 @@ information, please see the [`CONTRIBUTING.md`](CONTRIBUTING.md) file. | @danbogos | Dan Christian Bogos | | @eloycoto | Eloy Coto Pereiro | | @nikbyte | Nick Altmann | +| @kjcsb1 | Cameron Beattie |