日期区间和 ... 操作符
2016-12-01 本文已影响11人
焉知非鱼
use v6;
my $insert = "insert into `ald_stay_logs` (`id`, `app_key`, `day`, `day_after`, `new_people_left`, `people_left`) values";
my @app_key = <2323423dsfds 21e689e6bb76 f05883cf4dd8 7c8ccee05d025>; # 要遍历的 app_key
my @date = Date.new('2016-11-22') .. Date.new('2016-11-28'); # 上一周
my @day_after = 0..30; # 多少天以后的数据, 最大查看30天的数据
my @init_nums = <5500 5800 8000 9500>; # 新增用户的起始值
#my @init_peoples = <6000 7000 8000 9000>; # 活跃用户的起始值
for @app_key.kv -> $idx, $app_key {
my $init = @init_nums[$idx];
#my $start = @init_peoples[$idx];
my @step = 15, 20, 40;
my @new_people_left = lazy $init, $init-$init*0.15, $init-$init*0.20, $init-$init*0.40, {$^a - @step.pick} ... 0;
#my @people_left = lazy $start, $start-$start*0.15, $start-$start*0.20, $start-$start*0.40, {$^a - @step.pick} ... 0;
for @date -> $day {
for @day_after.kv -> $idx, $day_after {
say $insert, "(null,'$app_key', '$day', '$day_after', '@new_people_left[$idx]', '')";
}
}
}
2018 年哪些日子是周六:
enum DoW < Sunday Monday Tuesday Wednesday Thursday Friday Saturday >;
say (Date.new("2018-01-01")..Date.new("2018-12-31")).grep( *.day-of-week == Saturday );