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

Jon Bonilla (Manwe) manwe at sipdoc.net
Wed May 11 10:55:15 EDT 2016


El Wed, 11 May 2016 14:39:56 +0200
Rene Krenn <rkrenn at sipwise.com> escribió:

> 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 .*
> 

Thank you Rene. This has sense. I was thinking on longest match and not longest
regexp. 

I will check but I'm currently in a training and I've reseted the instance.



cheers,

Jon


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Firma digital OpenPGP
URL: <http://lists.sipwise.com/pipermail/spce-user_lists.sipwise.com/attachments/20160511/a46fa93b/attachment-0001.sig>


More information about the Spce-user mailing list