I'm looking for an example where + autoupdatingCurrentCalendar would be used instead of + currentCalendar. More specifically where the values based on the calendar are automatically changed when the calendar changes. Do I need bindings for this or something like that?
The docs state:
Note that if you cache values based on
the calendar or related information
those caches will of course not be
automatically updated by the updating
of the calendar object.
Thanks in advance
currentCalendar returns cached version of current system calendar, while autoupdatingCurrentCalendar always returns most recent version of system calendar.
That is important, when you are presenting data based on the various parameters of a calendar like number of days in a month, number of a weeks in year or number of hours in a day.
To be honest, I don't know why Apple gives you an opportunity to get outdated value by using currentCalendar.
It looks like they have internal API that allows you to manipulate caches of NSCalendar, so you can achieve better performance. But since it is not public, there is no reason to use currentCalendar.
That is, always use autoupdatingCurrentCalendar.
Well, on OS X you can be running multiple processes simultaneous. One could be your process that uses the autoupdatingCurrentCalendar. The other could be System Preferences.
System Preferences allows you to customize your calendar settings. You can choose the first day of the week to be something other than the default (Sunday). Or you can choose a whole different calendar altogether. If you use the autoupdatingCurrentCalendar, these changes will be picked up automatically. If you don't use it, they won't.
I guess that it is only usefull if you store the calendar in memory for further use. Doing that way, if the calendar settings change, your stored calendar will take account of those changes if you used autoupdatingCurrentCalendar. If you only used currentCalendar, it wil stay at the state it was at your first call.
Related
I want to display a list of US ScheduleState changes, but not all of them, only the latest change. And not only Accepted, but the current state.
I tried using ValidTo > Current, but this is not always the case, other changes might have occured, so that the ValidTo on the latest ScheduleState change is in the past.
So, is it possible to retrieve only the latest revision/ScheduleState change "automatically" via the loopback API - or do I need to do this "manually" after the load of all ScheduleState changes?
The LBAPI uses the date 9999-01-01 to indicate that the change is last one for the set of things you have asked about. So, if you ask for information on two fields, you will get two records with a date like that. You will then have to work out what you want to know next: the last change on each field, on the last change of either field on the artefact (by looking at the _ValidFrom field).
If you want to know the current state, that's done differently with the __At field in a 'find'. But then, that doesn't tell you what/when the last changes were.
I am trying to show in my application the steps that the user walked per day in real time but I am not able to. I tried to get the steps using TYPE_STEP_COUNT_CUMULATIVE but I am able to get all the steps from the day that user started using the application.
When I tried to use other type, for example DELTA, it's not working. Not sure if I am missing something. I am able to get the daily steps from HISTORY API but I cannot use them for real time because UI does not allow to use await().
Any suggestions?
The com.google.step_count.cumulative data type represents step count data as a sum since the start of the count. So this is not the one that you need.
From this documentation, it is stated here that Google Fit also provides simple access to the daily total of a specified data type. Use the [HistoryApi.readDailyTotal()](https://developers.google.com/android/reference/com/google/android/gms/fitness/HistoryApi#readDailyTotal(com.google.android.gms.common.api.GoogleApiClient, com.google.android.gms.fitness.data.DataType)) method to retrieve the data type that you specify as of midnight of the current day in the device's current timezone. For example, pass in the TYPE_STEP_COUNT_DELTA data type to this method to retrieve the daily total steps. You may pass in an instantaneous data type that has an aggregate daily total.
But, if you want a real time data, you need to use the Sensors API together with the Recording API. Source: Record Fitness Data
For more information, check this related SO question:
Get current day's steps during datapointListener google Fit
I would like to, via OneSignal REST API :
filter the push to users in a certain location (as in the doc) but it lacks sample code/relevant routes. The steps would be :
store tags for users (documented here, this is fine)
creating a segment (I don't see this in the docs)
push by filtering by segment (this is covered here)
Similarly I would like to be able to filter the push to users that visited a location in a certain date range (ex. last week, last month...). I am not completely sure this is possible using only OneSignal.
The minimum I would need is how to create a segment with OneSignal.
Edit : looks like there is a way in the dashboard, but I need to do it programmatically.
(I help work on OneSignal) OneSignal does not support programmatically targeting by a location at this time but we're planning on adding support for this in the near future.
One way to do some of this until then would be to provide the name or position of a location as tags. For instance you could use the tags lat=41.123, lon=55.331, then target users programmatically where the tags are greater than and less than the ranges you specify.
OneSignal does not provide built-in functionality to target by historical locations and we do not plan to add support for this, but you may be able to use tags to achieve your desired result.
Note that OneSignal does allow you to target by Player ID, so you could always store your users' Player IDs in your own system and do the calculation of who should receive a notification on your own.
I'm building a system that needs to store/manage different types of events. For simplicity, I will focus on designing a calendar (I'm building something slightly different, but calendar is a good analogy and it's easy to reason about). I'd like to hear about possible database/schema design ideas.
Problem Description
I have a calendar with different types of events (for simplicity sake, say there is only 1 type of event: Task). User can add new event for a particular date, edit (change some details, like title or move to another date) or delete. There can be one-time events and recurring events (with different types of recurrence: every X days, every 15th day of the month, every week on Monday; kind of like simple cron). When user moves recurring event, all other instances of this event are moved in the same manner (e.g: +3 days). Important part: recurring events can have exceptions. So, for example, let's say I have an recurring event A which is repeated every 7 days. But I want to change it's date for next week, so instead of Tuesday, it's be assigned to Friday, after that it'll still occur on Tuesday. This "exception" event shouldn't be affected when "parent" event is moved.
Also, every recurring event can have additional info, that is related only to 1 particular instance, e.g: I have the same recurring event A repeated every 7 days, I want to add a note for this week instance that says "X", and I want to add another note for the event A next month that says "Y" - those fields are only visible to that single instances.
Ideas
System with regular, one-time events is pretty straightforward so I won't discuss that and focus only on recurring events.
1. One possible solution is the one that resembles OOP: I can have an Event "class" with fields such as start_date, end_date (can be null), recurrence_type (something like enum with possible values of EVERY_X_DAYS, DAY_OF_WEEK, DAY_OF_MONTH) and recurrence_value (say 7). When user adds new recurring event, I just create such Event in the database. When user wants to change 1 occurrence of this event, I add new entry to the DB of the type/class MovedEvent that "inherits" from Event with different date and has additional field related_to that points to the ID (or UUID, if you will) of the Event that it's related to. But at the same time, I need to keep track of all the MovedEvents (otherwise I'd have 2 events displayed in the same week), so I need to have an array moved_events of IDs that point to all MovedEvents.
Disadvantage: every time I want to display the calendar I need to get Event and select all events from the moved_events, which is not optimal if I'll have a lot of moved events.
2. Another idea is to store every event as a separate record. IMO it's a terrible idea, but I just mentioning it because it's a possibility. Disadvantages: every time I want to edit the main event (e.g: I want to change the event from occurring "every 7 days" to "every 9 days") I need to change every single occurrence of the event. "Exceptions" (changing single instance) is easier, though.
SQL/NoSQL? Scale details
I'm using PostgreSQL in my project, but I have basic knowledge in NoSQL databases and if they are better suited for this kind of a problem, I can use it.
Scale: Let's say I have 5k users, and each will have on average 150 events/week, 40% of which can be "exceptions". Therefore I want to design this system to be efficient.
Similar Questions & Other Resources
I've just started reading Martin Fowler's "Recurring Events for Calendars" (http://martinfowler.com/apsupp/recurring.pdf) but I'm not sure if it applies to my problem and if so, how one would design database schema according to this document (suggestions are welcome).
There are similar questions, but I didn't see any mention of "exceptions" (changing 1 event instance without affecting other), but maybe someone will find these links useful:
Design question: How would you design a recurring event system?
Optimal design for a Database with recurring event
Design option for 'recurring tasks'
Calendar Recurring/Repeating Events - Best Storage Method
What is the best way to represent "Recurring Events" in database?
Sorry for a long question, I wanted to describe the problem well. Yet, I feel that's pretty chaotic, so if you have additional questions, I will happily provide more details. Again, I'd like to hear about possible database/schema design ideas plus any other suggestions. Thank you!
Use iCalendar RRules and ExDates
If it's a recurring event, just store the start/end datetimes and RRules and ExDates for the event.
Use a Materialized View to pre-calculate upcoming actual events, say for the next 30 days or 365 days.
As you are using Postgres, you can use existing python, perl, or javascript RRule libraries (such as dateutil) inside pg function for calculating future events based on the rrules and exdates
UPDATE: check out pg_rrule extension: https://github.com/petropavel13/pg_rrule
I am using HP Project and Portfolio Management(PPM) tool and I am adding a custom field in my request type which has date as value. Now my requirement is to send the email notifications to the users once the date mentioned in the custom field crosses the system date.
I had tried to set the notification for field level from Notification tab but not getting the custom fields in the list. All the fields, which is available, are pre-configured fields.
So, can anyone suggest me how to implement this requirement? And also where the changes need to be done If any required to implement this?
Please answer in detail and also reply soon.
Thanks in advance!!
PPM notifications can be configured on pre-defined events, like a certain transition, or timeout etc...
One possible solution for this scenario is to have timeouts on your decision step. Time out goes to an execution step, which checks for the date condition. If the condition is met it fires the notification. Else it just returns to the original decision step.
The downside of this work around is that there will be transaction details added once daily. Also the last update date of the request keeps updating daily, which is not ideal if you want to track what was the last time an end user update the request.
It is a workaround cause of the restrictions around notification events.
And if you have a large workflow, I would not recommend this work around.