-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the execution time can span 24 hours. #184
Conversation
…the next day 1:00
modules/hbs/db/strategy.go
Outdated
"select %s from strategy as s where (s.run_begin='' and s.run_end='') or (s.run_begin <= '%s' and s.run_end > '%s')", | ||
"select %s from strategy as s where (s.run_begin='' and s.run_end='') "+ | ||
"or (s.run_begin <= '%s' and s.run_end > '%s')"+ | ||
"or (run_begin > run_end and !(run_begin > '%s' and run_end < '%s'))", |
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.
run_begin > run_end
成立的话,run_begin > '%s' and run_end < '%s'
其实就自然不会成立了- 这里不需要加上
s.
吗?
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.
1 可以不加s ,sql中只有一张表没必要起别名。不过这里确实写法不统一
2 给你举个例子 run_begin 03:00 ,run_end: 01:00 . run_begin > run_end没错吧。 now是 02:00 。 run_begin: 03:00> now: 02:00 并且 run end 01:00 < now 02:00不成立么? 只有now在非 01:01~03:00的时间段才成立。所以实现了一天中排除一段时间不执行这个需求。需求见issus
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.
我原本的困惑来自于原本不存在 run_begin 大于 run_end 的情况。
谢谢补充说明。我懂了,用了稍微取巧的方式实现 排除一段时间不执行
的需求。
s.
的写法还是统一吧,没有其他问题了,谢谢您的 PR,:)
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.
谢谢review,已改。顺便提一下这里还有个坑,我发现了没改的。
就是run_begin和run_end必须要写全。03:00不能写成3:00。因为数据库中存的是字符串,比较的时候按照字符串的大小比较,3:00会小于02:00。起码页面校验或者提示一下吧。
反应的问题记录在 issue 中了,谢谢 |
策略生效时间支持某段时间不执行,例如每天1点到5点不执行就可以写成run_begin: 05:00 run_end: 1:00
#182