fix bug calc shard id(same usec); add in config day limit

This commit is contained in:
0x42 2021-06-07 14:37:33 +03:00
parent c1aa30005f
commit d6561f9ddf
No known key found for this signature in database
GPG Key ID: AB0CF4321FCCF431
2 changed files with 11 additions and 2 deletions

View File

@ -415,8 +415,8 @@ marshal_timestamp(DateTime) ->
calculate_shard_id(Timestamp, Config) ->
StartedAt = started_at(Config),
ShardSize = shard_size(Config),
{StartDateTime, USec} = lim_range_codec:parse_timestamp(StartedAt),
{CurrentDateTime, USec} = lim_range_codec:parse_timestamp(Timestamp),
{StartDateTime, _USec0} = lim_range_codec:parse_timestamp(StartedAt),
{CurrentDateTime, _USec1} = lim_range_codec:parse_timestamp(Timestamp),
case time_range_type(Config) of
{calendar, Range} ->
Units = calculate_time_units(Range, CurrentDateTime, StartDateTime),

View File

@ -62,6 +62,15 @@ handle_function_('Get', {LimitID}, LimitContext, _Opts) ->
woody_error:raise(business, #limiter_cfg_LimitConfigNotFound{})
end.
mk_limit_config(<<"ShopDayTurnover">>) ->
{ok, #{
processor_type => <<"TurnoverProcessor">>,
type => turnover,
scope => {scope, shop},
shard_size => 12,
context_type => payment_processing,
time_range_type => {calendar, day}
}};
mk_limit_config(<<"ShopMonthTurnover">>) ->
{ok, #{
processor_type => <<"TurnoverProcessor">>,