New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
freat: add date_to_unix_ts/3 function to the rule engine #10392
freat: add date_to_unix_ts/3 function to the rule engine #10392
Conversation
8435571
to
695f86a
Compare
695f86a
to
d3ccd8a
Compare
Pull Request Test Coverage Report for Build 4719918024
馃挍 - Coveralls |
ArgsOffset = [<<"second">>, <<"+08:00">>, <<"%y-%m-%d-%H:%M:%S%Z">>], | ||
?FORALL( | ||
S, | ||
erlang:system_time(second), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is called only once for all tests. I tried locally with nanosecond
and printing the value, it's always the same.
To achieve the desired generation of values, I think one way is to do:
erlang:system_time(second), | |
?LAZY(erlang:system_time(second)), |
Not sure if the most correct way to produce values, but does produce different values.
Also, note that the generation is very fast: it produces several values in a second. So, even with ?LAZY
, this will basically always return the same value.
Perhaps we could instead define a range of epoch values? Like
erlang:system_time(second), | |
range(0, 4000000000), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I think this problem existed in the other test cases in the same function as well. Will try to fix them too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thalesmg thanks for spotting this. I have updated the test case in the latest commit.
Co-authored-by: Thales Macedo Garitezi <thalesmg@gmail.com>
Fixes https://emqx.atlassian.net/browse/EMQX-9245
Summary
馃 Generated by Copilot at 8435571
Add a new rule engine function
date_to_unix_ts/3
to convert date strings to unix timestamps and a test case for it inemqx_rule_funcs_SUITE.erl
.PR Checklist
Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:
changes/{ce,ee}/(feat|perf|fix)-<PR-id>.en.md
files