Repeated events in Eventbrite API - api

I noticed that when I search future events via event_search method, sorted by date, that first events in result-set have start date from past. Problem with these events is that they are repeatable events (e.g. weekly), but API does not return events' recurrence type (daily, weekly, monthly, other). Method should at least return next event start date and recurrance type.

Hidden feature:
Add "display=repeat_schedule" to your API requests to reveal a series of start_date, end_date pairs for each repeating instance.

Unfortunately, Eventbrite's "repeating events" feature (available on their website) is not totally compatible with their API services:
Most storage models have an associated identifier or 'handle' to reference each asset or resource. In REST-speak these identifiers are known as 'resource ids'.
Eventbrite's repeating events share a single event id, and they include a string that describes the schedule when they repeat.
The head of the chain of repeating events is returned, with a "repeats" attribute that is set to "yes". And, the "repeat_schedule" attribute should now be present on all repeating events.
The string that is revealed will have a different format depending how the event is configured to repeat:
Daily repeating events:
"daily-4-07/26/2012" - every fourth day, from the date/time of the
start_date until 2012-07-26.
"daily-mf-07/26/2012" - every Monday
through Friday, from the start_date day/time until "2012-07-26"
Weekly repeating events:
"weekly-3-Y,N,N,N,N,N,N-09/16/2012" - every 3rd week, on each day marked with a "Y" until "2012-09-16"
Monthly repeating events:
"monthly-2-10-06/30/2012" - every second month, on the 10th day of the month until "2012-06-30"
"monthly-2-second/sat-06/30/2012" - every second month, on the second Saturday of that month, until "2012-06-30".
Custom repeat schedule (not fully supported):
"custom-3199915" - This format is really rare. Unfortunately, these events can not be easily summarized using a single string.

This bug needs to be fixed by EventBrite
However Would this work has a temp workaround? I would work in some examples I have seen.
I make request for events on March 17, 2012
I get back a past date
<repeats>yes</repeats>
<start_date>2011-12-04 09:30:00</start_date>
<end_date>2011-12-04 10:30:00</end_date>
Can I assume this is a repeating event that occcurs on March 17, 2012
at the same times?

There's a new endpoint that can be used to fetch all the events that are part of a series, the only values required are: OAuth Token and the event_series_id which is the parent event ID or the ID of the event where the series was created.
This is the endpoint:
GET - https://www.eventbriteapi.com/v3/series/{event_series_id}/events/
Replace {event_series_id} with your event series ID.
More details at: https://www.eventbrite.com/platform/api#/reference/event/list/list-events-by-series

Related

Laravel where clause based on conditions from value in database

I am building an event reminder page where people can set a reminder for certain events. There is an option for the user to set the amount of time before they need to be notified. It is stored in notification_time and notification_unit. notification_time keeps track of the time before they want to be notified and notification_unit keeps track of the PHP date format in which they selected the time, eg. i for minutes, H for hours.
Eg. notification_time - 2 and notification_unit - H means they need to be notified 2 hours before.
I have Cron jobs running in the background for handling the notification. This function is being hit once every minute.
Reminder::where(function ($query) {
$query->where('event_time', '>=', now()->subMinutes(Carbon::createFromFormat('i', 60)->diffInMinutes() - 1)->format('H:i:s'));
$query->where('event_time', '<=', now()->subMinutes(Carbon::createFromFormat('i', 60)->diffInMinutes())->format('H:i:s'));
})
In this function, I am hard coding the 'i', 60 while it should be fetched from the database. event_time is also part of the same table
The table looks something like this -
id event_time ... notification_unit notification_time created_at updated_at
Is there any way to solve this issue? Is it possible to do the same logic with SQL instead?
A direct answer to this question is not possible. I found 2 ways to resolve my issue.
First solution
Mysql has DATEDIFF and DATE_SUB to get timestamp difference and subtract certain intervals from a timestamp. In my case, the function runs every minute. To use them, I have to refactor my database to store the time and unit in seconds in the database. Then do the calculation. I chose not to use this way because both operations are a bit heavy on the server-side since I am running the function every minute.
Second Solution
This is the solution that I personally did in my case. Here I did the calculations while storing it in the database. Meaning? Let me explain. I created a new table notification_settings which is linked to the reminder (one-one relation). The table looks like this
id, unit, time, notify_at, repeating, created_at, updated_at
The unit and time columns are only used while displaying the reminder. What I did is, I calculated when to be notified in the notify_at column. So in the event scheduler, I need to check for the reminders at present (since I am running it every minute). The repeating column is there to keep track of whether the reminder is repeating or not. If it is repeating I re-calculate the notify_at column at the time of scheduling. Once the user is notified notify_at is set to null.

Get the latest events of a specific type from a specific device

Is there a way to get the latest event of a specific type from a specific device? So far I queried all events via myURL/event/events?source=<<ID>>&type=<<type>>.
Or is there a way to get a collection of events ordered by their creationTime? This could solve my problem too
In the documentation I only found parameters like dateFrom and dateTo. But what if I don't know the time range of the last event?
The syntax is: /event/events?type={type}&source={source}.
For more information on the available endpoints:
GET /platform
Answer from the support-team:
currently there is no way to revert the order of events. Besides
dateFrom and dateTo you can also use creationFrom and creationTo. This
will take the creationTime (server side timestamp when event was
created) instead of the time (that is send within the event) But the
order will still be oldest -> newest.
Best approach currently would be to use a good estimated time range
(so you don't end up with 0 events in the response) where the
dateTo/creationTo is in the future. If you add to the query params
withTotalPages=true the result will give you the total pages in the
statistics part.
Knowing the total pages you can you can do the query again but with
currentPage=XX instead of withTotalPages=true and take the last
element.
We have this functionality on measurements and audits where you can
add the parameter revert=true. I will add an improvement that we
extend this to the other APIs but at the moment you are limited to the
workaround.
You can just only set the dateFrom parameter and the pageSize to 1 like so: &pageSize=1&dateFrom=1970-01-01. As of September 2017, this returns the most recent event.

How to Extend the End Date in a SQL Calendar Table?

I have a report that, according to users, started miscalculating dates in one field in November 2015. After some digging around, I found that one of the tables the field referenced seemed to have an end date on 2015-10-31.
The "D" field seems to represent the day of the week, with Sunday being day 1 and Saturday being 7.
Is there a way to extend the calendar so that it ends further into the future, for example 2049-12-31?
Our calendar table, for a variety of reasons, goes the the end of the current year. We have written a query that adds a new year to this table. This query takes care of most of the fields in that table. It does not touch the holiday field. That is updated manually through a web page.
We send ourselves reminders. Starting in March, we send monthly reminders that we should think about adding another year. After ensuring that the database segment has space, and that none of the definitions, such as fiscal periods, have changed, we run the query that adds a year.
Later in the year we start mailing ourselves reminders about the holidays. Then we check to see if HR has declared them, and if so, update the records accordingly.
This meets our business requirements. Yours will be different of course.

Qlikview line chart with multiple expressions over time period dimension

I am new to Qlikview and after several failed attempts I have to ask for some guidance regarding charts in Qlikview. I want to create Line chart which will have:
One dimension – time period of one month broke down by days in it
One expression – Number of created tasks per day
Second expression – Number of closed tasks per day
Third expression – Number of open tasks per day
This is very basic example and I couldn’t find solution for this, and to be honest I think I don’t understand how I should setup my time period dimension and expression. Each time when I try to introduce more then one expression things go south. Maybe its because I have multiple dates or my dimension is wrong.
Here is my simple data:
http://pastebin.com/Lv0CFQPm
I have been reading about helper tables like Master Callendar or “Date Island” but I couldn’t grasp it. I have tried to follow guide from here: https://community.qlik.com/docs/DOC-8642 but that only worked for one date (for me at least).
How should I setup dimension and expression on my chart, so I can count the ID field if Created Date matches one from dimension and Status is appropriate?
I have personal edition so I am unable to open qwv files from other authors.
Thank you in advance, kind regards!
My solution to this would be to change from a single line per Call with associated dates to a concatenated list of Call Events with a single date each. i.e. each Call will have a creation event and a resolution event. This is how I achieve that. (I turned your data into a spreadsheet but the concept is the same for any data source.)
Calls:
LOAD Type,
Id,
Priority,
'New' as Status,
date(floor(Created)) as [Date],
time(Created) as [Time]
FROM
[Calls.xlsx]
(ooxml, embedded labels, table is Sheet1) where Created>0;
LOAD Type,
Id,
Priority,
Status,
date(floor(Resolved)) as [Date],
time(Resolved) as [Time]
FROM
[Calls.xlsx]
(ooxml, embedded labels, table is Sheet1) where Resolved>0;
Key concepts here are allowing QlikView's auto-conatenate to do it's job by making the field-names of both load statements exactly the same, including capitalisation. The second is splitting the timestamp into a Date and a time. This allows you to have a dimension of Date only and group the events for the day. (In big data sets the resource saving is also significant.) The third is creating the dummy 'New' status for each event on the day of it's creation date.
With just this data and these expressions
Created = count(if(Status='New',Id))
Resolved = count(if(Status='Resolved',Id))
and then
Created-Resolved
all with full accumulation ticked for Open (to give you a running total rather than a daily total which might go negative and look odd) you could draw this graph.
For extra completeness you could add this to the code section to fill up your dates and create the Master Calendar you spoke of. There are many other ways of achieving this
MINMAX:
load floor(num(min([Date]))) as MINTRANS,
floor(num(max([Date]))) as MAXTRANS
Resident Calls;
let zDateMin=FieldValue('MINTRANS',1);
let zDateMax=FieldValue('MAXTRANS',1);
//complete calendar
Dates:
LOAD
Date($(zDateMin) + IterNo() - 1, '$(DateFormat)') as [Date]
AUTOGENERATE 1
WHILE $(zDateMin)+IterNo()-1<= $(zDateMax);
Then you could draw this chart. Don't forget to turn Suppress Zero Values on the Presentation tab off.
But my suggestion would be to use a combo rather than line chart so that the calls per day are shown as discrete buckets (Bars) but the running total of Open calls is a line

NSPredicate with NSDate and repeats (like Calendar app)

I have an entity "Event" witch contains two properties: date (NSDate) and repeat (NSInteger - 0 = NONE, 1 = DAILY, 2 = WEEKLY, 3 = MONTHLY, ...).
Does anyone knows how can I filter events by repeats passing a date ?
Example:
First event: 01-01-2010 / weekly
Second event: 10-02-2010 / monthly
Current date: 10-06-2010
Request:
Get all events where Event.date == "Current date" OR Event.date.day == "Current date".day if Event.repeat == monthly
Returned event:
Second event
I hope someone understand what I'm trying to explain :s
The problem here is that NSDate doesn't have a day (or any other similar) property. If it did, your predicate would work as written.
Data and time programming is deceptively complex under the hood. For example, in common usage, the phrase "same date" means the exact same calendar day. However, from the codes perspective it also means the same week, month and year because days are no more significant to code than any other arbitrary calendar division. Even in ordinary usage, "day" can refer to a specific range of hours e.g. Saturday, August 21 2010 or it can refer to any arbitrary range of 24 hours as in, "within a day." Which one do you need for this app?
NSDate is really an object wrapper around a microsecond accurate timestamp. It has methods for converting to strings and for creating and comparing timestamps but it doesn't understand calendar attributes such seconds, minutes, hours, days, weeks, month, or years. That is what NSCalendar is for and Core Data does not innately support that class as a data type as doing so for all possible calendars would be to complex.
If calendar attributes are required in a model, you need to create an custom entity that models a calendar date. Set the entities attributes to calendar attributes you need to model and then a relationship to the object that needs the calendar date as a property e.g.
CalendarDate{
date:NSDate
minute:int
hour:int
day:int
month:int
year:int
events<--(required,nullify)-->>Event.date
}
You can create a custom class for the entity and provide a method that automatically populates the object based on the passed NSDate and any calendar you choose.
Now your predicate is easy.
NSPredicate *myPred;
myPred=[NSPredicate predicateWithFormat:#"(date.date==%# or date.day==%i) AND repeat=%i", currentDate, 45, kMonthly];
This seems like it is cumbersome but it is required owing to the true complexity of calendar dates. There simply isn't an easy way to handle date and time calculations and comparisons for all uses.
I am not certain this can be done at the SQLite level. It certainly can be done once your events are pulled into memory but that, I suspect, defeats your goal.
There might be some clever way to de-normalize the data and thereby create a situation that can be filtered.
For example, if you had the day of month and month pulled out into integer fields you might be able to devise a way to determine based on those if things align. It is not coming to me directly but I would definitely look in that direction for a solution.
Another alternative, one that calendars tend to use, is to create dependent events for the specific dates coming up. When the event is created you create all of the dependent events so that you are just filtering on a date. Nasty to be sure.
Last option is to pull all events into memory and calculate from there.