[Spce-user] Billing fee selection by rate-o-mat

Rene Krenn rkrenn at sipwise.com
Wed May 11 08:39:56 EDT 2016


sry, didnt want to shock anyone;

i just looked at the code again; the corresponding logic in rate-o-mat
is covered by the query below:

"SELECT id, source, destination, ".
		"onpeak_init_rate, onpeak_init_interval, ".
		"onpeak_follow_rate, onpeak_follow_interval, ".
		"offpeak_init_rate, offpeak_init_interval, ".
		"offpeak_follow_rate, offpeak_follow_interval, ".
		"billing_zones_history_id, use_free_time ".
		"FROM billing.billing_fees_history WHERE billing_profile_id = ? ".
		"AND bf_id IS NOT NULL AND type = ? ".
		"AND direction = ? AND ? REGEXP(source) AND ? REGEXP(destination) ".
		"ORDER BY LENGTH(destination) DESC, LENGTH(source) DESC LIMIT 1"

so it sorts by pattern stringlength and picks the first (longest) fee
that matches the sip uri.

for Jons example, i.e. 34677705188 will match

1. ^34[6-7][0-9]+ (the longest regexp that matches, longer than
^34677705188 !)
2. if 1. wouldn't exist it would take ^34677705188
3. if 2. wouldn't exist it would take .*

the reason why it still happens that the third .* is applied by come
from the source match pattern of the fee - as you see in the query both
have to match.

Jon, can you give complete examples of your 3 fee records?

regards, rene






More information about the Spce-user mailing list