I am developing an application which needs the events to be set on daily basis , hourly basis , weekly event or on the particular day event.
I am using the fullcalendar plugin but I am not been able to set the events on daily basis.
Is there any ways to set the event on daily basis? If yes then How?
If not possible through the fullcalendar please suggest me some other jquery plugin.
You mean set like Lunch M-F 1200-1300?
Events need to have dates, so you may want to use events function, and generate them from start by adding day offsets and setting the hours. Check arshaw's xdate.
You can do daily events by specifying the day of week.
{
title: timecondition.name,
start: moment(),
end: moment(),
color: '#' + timecondition.color,
dow: [0, 1, 2, 3, 4, 5, 6],
allDay: false,
}
Related
I'm using Laravel 5.8 and I like to auto-generate Invoices should be generated auto from Monday - Sunday.
every Sunday night at 23:59:00
Let's say I have
"23:59:00 according to the region time zone".
Every store is related to a region, from the region table you'll find the time zone.
Questions
How should I set the CRON JOB so I can generate invoices automatically according to the list of timezone I will get from the table?.
I have two suggestions;
if you want it to be static, define each command with the corresponding timezone from your database. Different timezones may have same time such as Europe/Amsterdam and Europe/Berlin
$schedule->command('generate:report')->timezone('one-of-the-timezone')->at('23:59');
$schedule->command('generate:report')->timezone('another-timezone')->at('23:59');
$schedule->command('generate:report')->timezone('yet-another-timezone')->at('23:59');
$schedule->command('generate:report')->timezone('some-other-timezone')->at('23:59');
If you want it to be dynamic, make it run every 59. min hourly and try to match it with the timezones via using hour.
$schedule->command('generate:report')->hourlyAt(59);
Inside your command class;
public function handle(TimezoneRepository $timezoneRepository)
{
$timezones = $timezoneRepository->getUniqueTimezones(); // the unique timezones in your database - cache if you want
foreach ($timezones as $timezone) {
$date = Carbon::now($timezone); // Carbon::now('Europe/Moscow'), Carbon::now('Europe/Amsterdam') etc..
if ($date->hour === 23) { // you are in that timezone
$currentTimezone = $date->getTimezone();
dispatch(new ReportMaker($currentTimezone)); // dispatch your report maker job
}
}
}
With the dynamic one, you will hit to multiple timezones at one iteration(when generate:report is executed) as i said at then beginning.
one of the possible flaw may be; if the execution of getting timezones etc takes more than 1 minute you may be in 00:00 instead of 23:59. It is better to calculate your report asynchronous and cache the list of timezones to not face problems while executing this loop.
Another possible flaw;
According to wiki;
A few zones are offset by 30 or 45 minutes (e.g. Newfoundland Standard Time is UTC−03:30, Nepal Standard Time is UTC+05:45, Indian Standard Time is UTC+05:30 and Myanmar Standard Time is UTC+06:30).
If you want to cover any of these, then it is better to execute the command like this
$schedule->command('generate:report')->cron('14,29,44,59 * * * *');
and make both hour and minute comparison such as;
$date->hour === 23 && $date->hour === 59
You can use the timezone() method in your task Schedulding
Using the timezone method, you may specify that a scheduled task's
time should be interpreted within a given timezone:
$schedule->command('report:generate')
->timezone('America/New_York')
->at('02:00')
I have an incoming stream of events, each of which already has an associated sessionId from another process.
All I wish to do is combine these events into a single session object using a custom CombineFn.
During development, I'm using a bounded dataset that reads from a file and the following code seems to work:
input.apply(ParDo.named("ParseEvent").of(new ParseEventFn()))
.setCoder(KvCoder.of(StringUtf8Coder.of(), AvroCoder.of(Event.class)))
.apply(GroupByKey.<String, Event>create())
.apply(Combine.groupedValues(new SessionAccumulator()))
The above code (with input/output handling) will output a series of sessions with multiple events in each.
{sessionId: 1, events: [event1,event2,event3]}
{sessionId: 2, events: [event4,event5]}
But in order for this to work on an unbounded dataset, I need to apply a Windowing function, which in this case is a SessionWindow.
input.apply(ParDo.named("ParseEvent").of(new ParseEventFn()))
.setCoder(KvCoder.of(StringUtf8Coder.of(), AvroCoder.of(Event.class)))
.apply(Window.<KV<String, Event>>into(Sessions.withGapDuration(Duration.standardMinutes(30))))
.apply(GroupByKey.<String, Event>create())
.apply(Combine.groupedValues(new SessionAccumulator()))
In that case the only new code is the Windowing function, and rather than rolling up the events, I get each event in it's own session, like this:
{sessionId: 1, events: [event1]}
{sessionId: 1, events: [event2]}
{sessionId: 1, events: [event3]}
{sessionId: 2, events: [event4]}
{sessionId: 2, events: [event5]}
Any idea why this is happening?
EDIT: I should add, the ParseEventFn is applying a timestamp to the PCollection using context.outputWithTimestamp(), and that timestamp seems to be correct.
Digging into it further, in my case the issue was that my core assumption that the timestamps were correct, was wrong.
The timestamps I was applying before the windowing were wrong.
The Windowing was doing exactly what it should, but I had set my timestamps too far apart and it was creating separate sessions for each event.
Oops
In your case, you could possibly write your own WindowFn. If you set the keys to be the session IDs then a large gap duration also works, but it doesn't reflect the nature of your data and computation quite as well.
The ingredients to your WindowFn would be:
your own subclass of BoundedWindow, in this case you would make a window type that contained the session ID in a field
assignWindows, where you would assign each element to a window identified by the session ID. The length of the window still matters, as it controls when the window expires and is garbage collected.
mergeWindows, where you would merge all windows that have the same session ID. They wouldn't have to fall within any particular gap duration.
Another thing you'll need to be careful of is that the watermark that governs the garbage collection of these windows is determined by the source of your unbounded stream of events. So setting the timestamps in your ParDo.of(new ParseEventFn()) will be too late to influence the watermark. You may have data dropped that you'd like to keep.
I'm trying to copy a subset of events from one calendar to another, ignoring any recurrences.
Doing a pure AppleScript solution makes it hard to parse recurrent events, but Automator sees through the recurrence to see the event instances that match the filter parameters, so this is the approach I was taking.
How would I create copies of the events outputted from "Filter Calendar Events" and add them to a given calendar? (Don't worry about adding duplicates)
I don't know if or how an applescript action can handle the data objects passed from the Calendar actions.
You didn't specify what you're wanting to do with the event data, but a solution I suggest is add a "Event Summary"action after the "Filter Calendar Events" action. This will pass a string with all the event details, that looks like this:
"TOTAL EVENTS: 2
EVENT 1 OF 2
Summary: PTO Meeting
Status: none
Date: 1/11/17 to 1/11/17
Time: 8:30:00 AM to 9:30:00 AM
EVENT 2 OF 2
Summary: MW Board Meeting
Status: none
Date: 1/11/17 to 1/11/17
Time: 1:00:00 PM to 2:00:00 PM
"
So, your script action that follows can parse the data:
on run {input}
set eventSummary to input as text -- or item 1 of input
-- parse the string
return
end run
Again, you didn't specify what you'd like to do with the returned events, so can't suggest what string parsing you need, but should be easy to figure out.
Currently, the users for my app set a specific date and time for a single reminder (using the Chronic gem).
I have a cron job which runs every 10 minutes and checks if the time in the reminder is < Time.now at which point, it sends the reminder and marks that reminder as sent.
However, I want them to be able to specify recurring reminders. The customer should be able to say, "Every other day at 10am".
I can use ice_cube for the recurring part it seems. Then I use Chronic to come up with the start time which will have the day and recurring time.
But I don't have a good way to make it recurring since these are not separate events in the data base.
Here is what I have tried:
```
reminder = response.body['results'] #array of recurring reminders with start_epoch and 'via'
d {reminder}
reminder.count.times do |i|
schedule = IceCube::Schedule.new(now = Time.at(reminder[i]['value']['start_epoch'])) # get the initial start day and time
schedule.add_recurrence_rule(IceCube::Rule.daily) #makes this a daily recurring, but how can I allow this to be customizable?
if schedule.next_occurrence(Chronic.parse('today at 12:01AM')) < Time.now # Check if today's occurence has happened yet
bot_response = BotResponse.get_bot_response(bot_client_id, reminder[i]['value']['bot_input_keyword'])
if reminder[i]['value']['via'] == 'slack'
slack_response = BotMessage.send_slack(reminder[i]['value']['slack_channel'],
bot_response[:bot_response])
d {slack_response}
end #if
end #if
end #do
```
Questions:
Is there a way to tell when a reminder has been sent without writing each specific daily reminder to a database?
Is there a more elegant way for the user in a text string to define the recurrence?
Have you considered trying the whenever gem to implement recurring tasks through cron jobs? I think you should be able to set the schedule times dynamically in the whenever schedule.rb file, see related issue here: Rails - Whenever gem - Dynamic values
Banging my head against the wall with this one. Trying to dynamically add jobs with resque-scheduler. What's the syntax for creating a monthly job? For example, the code below will set up a job to run every minute.
config[:class] = "job_name"
config[:args] = "arg"
config[:every] = "1m"
config[:persist] = true
What would the syntax here be for every month? Would it be config[:every] = "1 month"? I can't seem to find any answers on the resque-scheduler docs for this.
Thanks.
For dynamic schedules resque-scheduler uses rufus-scheduler, as it is explained on the documentation, which handles not only the actual scheduling business but also the parse of the :every option.
You can see that when resque-scheduler runs it basically loads all schedule information from redis and then passes on to rufus.
The supported letter/durations are documented on rufus here as a map between letters and durations in seconds and you can see more complex rules on the specs for duration parsing.
For one month, you can use 1M or you can also use 4w, there's also 30d...