I want to know at WHAT TIME mostly my events happens during a period of time, so for example:
Event : Initiate Checkout
time 00:00 ~ 01:00 = 80 events
time 01:00 ~ 02:00 = 145 events
time 02:00 ~ 03:00 = 300 events
...
time 23:00 ~ 24:00 = 20 events
between date range: 1 nov ~ 30 nov 2018
Note : the results shouldn't be 720 (30*24) time fragments, but 24 time fragments.
How to do that using facebook analytics ?
You can go to "Events" section, choose "Initiate Checkout", on the charts choose "Time Interval" as "Hourly". For date range, you can choose 1 nov ~ 30 nov on the top left corner.
Related
I am developing a subscription based application using Laravel. I want to change the state of the user to expire after 75 days of subscribing to the package. I want to exclude Sundays from these 75 days.
Consider a scenario where user's account is verified today and he has only access to the premium functionalities for 75 days(without Sundays). After the 75 days, the user needs to resubscribe to get access to the premium functionalities of the application.
I will then set up a middleware which will check if the user's subscription is expired or not.
I have two scenarios to check for expiration:
Save the expiration date column in the users table.
Verify each user's request based on verified_at (datetime) column and prevent premium access if the user subscription is over more than 75 days without Sundays.
I want to achieve this using Laravel Carbon or any other alternative library/functionality.
After 75 Days from Today(11 June) is August 25 π
ββοΈ
After 75 Days from Today(11 June - Excluding Sundays) is September 07 π
Reference: https://getcalc.com/75business-days-after-today.htm
If 75 is fixed, than you could easily calculate the number of Sundays in the period, and so then you just need adding those days to the 75:
$period_in_days = 75;
if($user->verified_at->dayOfWeek > 2)
$period_in_days += 11;
else
$period_in_days += 10;
The point is, in 75 days there could either 10 or 11 Sundays, and so in order to decide whether there are 10 or 11, we need to check which day is the first day.
Let's say is Monday the first day, so the 75 days should looks like this
1 - Monday
2 - Tuesday
...
71 - Monday
72 - Tuesday
73 - Wednesday
74 - Thursday
75 - Friday
Let's say is Tuesday the first day, so the 75 days should looks like this
1 - Tuesday
2 - Wednesday
...
71 - Tuesday
72 - Wednesday
73 - Thursday
74 - Friday
75 - Saturday
Let's say is Wednesday the first day, so the 75 days should looks like this
1 - Wednesday
2 - Thursday
...
71 - Wednesday
72 - Thursday
73 - Friday
74 - Saturday
75 - Sunday
So if the first day is not neither Monday and Tuesday, then there will be 11 Sundays (10 + the 1 that appears in the [71- 75]), otherwise there will be only 10 Sundays
I can count next 75 days excluding Sundays using the following PHP function
function Next75Days($StartingDate){
// Count Next 75 Days excluding Sundays
$Days = 75;
$d = new DateTime($StartingDate);
$t = $d->getTimestamp();
// Loop for 75 days
for($i=0; $i<$Days; $i++){
// Add 1 day to timestamp
$addDay = 86400;
// Get date of next day
$nextDay = date('w', ($t+$addDay));
// if it's Sunday, do $i--1
if($nextDay == 0) {
$i--;
}
// modify timestamp, add 1 day
$t = $t+$addDay;
}
$d->setTimestamp($t);
return $d->format('d M Y');
}
d3.timeParse can parse the time format, but no matter how the format is set, the result contains the year, month, day, hour, minute, and second.
Like this: Sat Jan 01 2020 00:00:00
It can't only correspond to the month and day, if i want to use d3.scaleTime () to scale to compare data of different years, how can I implement it?
For example:
===axis=======
x-axis: 12 month 366 day
y-axis: [max(value), mim(value)]
===data=======
data 1: 2016 = [{ date:2016/01/01,value=18},{ date:2016/01/02,value=199},...,{ date:2016/12/31,value=27}] (366 day)
data 2: 2017 = [{ date:2017/01/01,value=58},{ date:2017/01/02,value=9},...,{ date:2017/12/31,value=217}] (365 day)
data 3: 2018 (365 day)
.
.
data n: 2020 (366 day)
I would like my watcher to run from Monday to Friday only. So I'm trying to use this schedule:
"trigger": {
"schedule" : { "cron" : "0 0 0/4 * * MON-FRI" }
},
"input": {
...
However, I'm getting
Error
Watcher: [parse_exception] could not parse [cron] schedule
when I'm trying to save the watcher. Removing MON-FRI does helps but I need it.
This expression works:
0 0 0/4 ? * MON-FRI
But I'm not sure I understand why ? is required for either the day_of_week or day_of_month
Thank you!
I believe this is what you are looking for:
"0 0 0/4 ? * MON-FRI"
You can use croneval to check your cron expressions 1:
$ /usr/share/elasticsearch/bin/x-pack/croneval "0 0 0/4 ? * MON-FRI"
Valid!
Now is [Mon, 20 Aug 2018 13:32:26]
Here are the next 10 times this cron expression will trigger:
1. Mon, 20 Aug 2018 09:00:00
2. Mon, 20 Aug 2018 13:00:00
3. Mon, 20 Aug 2018 17:00:00
4. Mon, 20 Aug 2018 21:00:00
5. Tue, 21 Aug 2018 01:00:00
6. Tue, 21 Aug 2018 05:00:00
7. Tue, 21 Aug 2018 09:00:00
8. Tue, 21 Aug 2018 13:00:00
9. Tue, 21 Aug 2018 17:00:00
10. Tue, 21 Aug 2018 21:00:00
For the first expression you'll get following java exception:
java.lang.IllegalArgumentException: support for specifying both a day-of-week AND a day-of-month parameter is not implemented.
You can also use Crontab guru to get human readable descriptions like:
At every minute past every 4th hour from 0 through 23 on every day-of-week from Monday through Friday.
The question mark means 'No Specific value'. From the documentation on Quartz's website:
? (βno specific valueβ) - useful when you need to specify something in one of the two fields in which the character is allowed, but not the other. For example, if I want my trigger to fire on a particular day of the month (say, the 10th), but donβt care what day of the week that happens to be, I would put β10β in the day-of-month field, and β?β in the day-of-week field. See the examples below for clarification.
http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/crontrigger.html
I suppose since you want your schedule to run every 4 hours, mon-fri, the actual day of the month is irrelevant, so the ? specifies that. * on teh other hand would be 'all values' which would not make sense since you are specifying only mon-fri for day of the week.
Hope that helps!
I recently started learning Hadoop,
I found this data set http://stat-computing.org/dataexpo/2009/the-data.html - (2009 data),
I want some suggestions as what type of patterns or analysis can I do in Hadoop MapReduce, i just need something to get started with, If anyone has a better data set link which I can use for learning, help me here.
The attributes are as:
1 Year 1987-2008
2 Month 1-12
3 DayofMonth 1-31
4 DayOfWeek 1 (Monday) - 7 (Sunday)
5 DepTime actual departure time (local, hhmm)
6 CRSDepTime scheduled departure time (local, hhmm)
7 ArrTime actual arrival time (local, hhmm)
8 CRSArrTime scheduled arrival time (local, hhmm)
9 UniqueCarrier unique carrier code
10 FlightNum flight number
11 TailNum plane tail number
12 ActualElapsedTime in minutes
13 CRSElapsedTime in minutes
14 AirTime in minutes
15 ArrDelay arrival delay, in minutes
16 DepDelay departure delay, in minutes
17 Origin origin IATA airport code
18 Dest destination IATA airport code
19 Distance in miles
20 TaxiIn taxi in time, in minutes
21 TaxiOut taxi out time in minutes
22 Cancelled was the flight cancelled?
23 CancellationCode reason for cancellation (A = carrier, B = weather, C = NAS, D = security)
24 Diverted 1 = yes, 0 = no
25 CarrierDelay in minutes
26 WeatherDelay in minutes
27 NASDelay in minutes
28 SecurityDelay in minutes
29 LateAircraftDelay in minutes
Thanks
I have the following code which creates an array of users depending on the "global" weekdays and times.
def current_time
# server_time = Time.now
server_time = Time.local(2013,8,19,8,30) # for time simulation
local_offset = (2 * 60 * 60)
local_time = server_time + local_offset
end
def hours_mon_to_thurs?(date)
["Monday", "Tuesday", "Wednesday", "Thursday"].include?(date.strftime("%A")) && ("08:30"..."17:00").include?(date.strftime("%H:%M"))
end
def hours_fri?(date)
["Friday"].include?(date.strftime("%A")) && ("08:30"..."15:00").include?(date.strftime("%H:%M"))
end
def hours_lunch?(date)
!("12:00"..."13:00").include?(date.strftime("%H:%M"))
end
if hours_mon_to_thurs?(current_time) && hours_lunch?(current_time)
p "[USER1, USER2]"
elsif hours_fri?(current_time) && hours_lunch?(current_time)
p "USER2"
else
p "no users"
end
This code works, but I would like to change how the array is created, so that each user has workdays and times as attributes and if they are available then they should be added to the array. Let me provide an example.
User 1 - Office Hours
Monday
08:30 - 12:00,
13:00 - 17:00
Tuesday
08:30 - 12:00,
13:00 - 17:00
Wednesday
08:30 - 12:00,
13:00 - 17:00
Thursday
08:30 - 12:00,
13:00 - 17:00
User 2 - Office Hours
Tuesday
08:30 - 12:00,
13:00 - 17:00
Thursday
08:30 - 12:00,
13:00 - 17:00
Friday
08:30 - 12:00,
13:00 - 15:00
With each user's office hours defined I want to have a similar method as in my example above. Something like this:
for each user
if current time is within user's office hours
add user to array
else if current time is not within users' office hours
array is empty
I'm not using a database at the moment and I don't know the best way to structure each user's office hours in such a way as to match if the current time is within a user's time range and then add them to an array.