How does HKWorkoutActivityType contribute to a HKWorkout? - healthkit

When creating a HKWorkoutSession we need to provide a HKWorkoutConfiguration with a HKWorkoutActivityType.
There are many HKWorkoutActivityType available to use, but I don't find what is the application of it.
Does different type of activityType contribute different amount of totalEnergyBurned during the workout? or is it only used in querying the HealthKit for particular type of workout?
I am creating a general workout watchApp by which a user can just start and stop a workout to complete its rings. But I am confused by HKWorkoutActivityType. Will there be any difference in TotalEnergyBurned if I use different HKWorkoutActivityType, because it is contributing to close the red ring.

As far as I can tell, HealthKit needs to know the HKWorkoutActivityType so that the workout is listed properly in Apple Health. It does not automatically calculate the totalEnergyBurned or any other quantities used to characterize the workout:
Your app should always provide data for the workout’s duration,
totalDistance, and totalEnergyBurned properties when the data is both
available and relevant to the workout. In addition, you should provide
a set of associated samples that sum up to these totals.
From: https://developer.apple.com/documentation/healthkit/hkworkout
I do not know whether HealthKit validates whether a quantity is appropriate for a given type of workout, e.g. wheelchair "pushes" when swimming.

Related

Advice for templatized timeslots for events in a day

Hello FullCalendar team,
I am looking to build a feature that would limit the type of events that could go into a specific timeslot.
For example, I would like to indicate to a front-desk end-user that only a certain type of appointment was allowed to be entered into the timeslot. Perhaps the timeslot only takes meeting types that are tagged "check-ins" and "follow-ups" arbitrarily set by some higher up admin.
What would be the best way to go about building this limitation and displaying it to the user? I saw that there is an overlap function I might be able to use along with background-events. The higher-up admin might be able to create background-events that if they overlap with another requested event then limits the type. THen it would be very clear that any certain color-coded event set by the higher-admin would indicate that only certain types could be added.
But am I missing a very obvious way to do this? I was hoping there might be an easier way to templatize the day for end-users. Appreciate the advice.

Netting transactions in quantstrat

Let's say I have a strategy with multiple rules that generates multiple orders on the same symbol at the same timestamp. For example, on 2012-05-23 one rule might buy 10 shares of IBM while another rule sells 5 shares of IBM. In production, a reasonable system would use netting and execute one order to buy 5 shares, rather than one order to buy 10 shares and another order to sell 5 shares.
Is there a way to get this behaviour in quantstrat? From my experiments, quantstrat does not do netting, and for example will add transaction fees for both opposing orders as if two separate orders were executed.
If quantstrat cannot net orders then it should still be possible to obtain the desired PnL in backtesting by using a custom TxnFees function. If this is the correct way to go, how would one go about defining a custom function to net the transaction fees?
A 'reasonable system' would likely do no such thing. My experience of simultaneous execution on tick data is basically zero for aggressive orders.
On bar data, yes, internal netting would make sense, and would be handled by a production order management system. Or, for example, internalizing resting internal limit orders against other signals asking for aggressive orders on the other side, or netting positions. Does any investor of non-trivial size use bar data?
That seems to miss the point of what quantstrat is for. You are looking to figure out (in research) some strategy that makes good predictions and evaluate the quality of those predictions by writing a backtest.
Backtests aren't reality.
Further, netting would completely muddle any ability to figure out if your signal process has predictive power.
The account in blotter will net P&L automatically, so it will have the same result as your order netting, in the absence of fees. So I don't think you would need a separate TxnFees function to understand the possible impact of netting, pre-fees.

modeling scenario with mostly semi-additive facts

Im learning dimensional modeling and Im trying to create a model. I was thinking about a social media platform which rates hotels. The platform has following data:
hotel information: name and address
a user can rate hotels (1-5 points)
a user can write comments
platform stores the date of the comments
hotel can answer via comment and it stores the date of it
the platform stores the total number of each rating level (i.e.: all rates with 1 point, all rates with 2 point etc.)
platform stores information of the user: sex, name, total number of votes he/she made and address
First, I tried to define which information belongs to a dimension or fact table
(here I also checked which one is additive/semi additive/non-additive)
I realized my example is kind of difficult, because it’s hard to decide if it belongs to a fact table or dimension.
I would like to hear some advice. Would someone agree with my model?
This is how I would model it:
Hotel information -> hotel dimension
User rating -> additive fact – because I can aggregate them with all dimensions
User comment -> semi additive? – because I can aggregate them with the date dimension (I don’t know if my argument is correct, but I know I would have new comments every day, which is for me a reason to store it in a fact table
Answer as comment -> same handling like with the user comments
Date of comment-> dimension
Total Number of all votes (1/2/3/4/5) -> semi-additive facts – makes no sense to aggregate them, since its already total but I would get the average
User information sex and name, address -> user-dimension
User Information: total number of votes -> could be dimension or fact. It depends how often it changes. If it changes often, I store it in a fact. If its not that often, then dimension
I still have question, hope someone can help me:
My Question: should I create two date dimensions, or can I store both information in one date dimension?
2nd Question: each user and hotel just have one address. Are there arguments, to separate the address dimension in a own hierarchy? Can I create a 1:1 relationship to a user dimension and address dimension?
For your model, it looks well considered, but here are some thoughts:
User comment (and answers to comments): they are an event to be captured (with new ones each day, as you mention) so are factual, with dimensionality of the commenter, type of comment, date, and the measure is at least a 'count' which is additive. But you don't want to store big text in a fact so you would put that in a dimension by itself which is 1:1 with the fact, for situations where you need to query on the comment itself.
Total Number of all votes (1/2/3/4/5) are, as you say, already aggregates, mostly for performance. Totals should be easy from the raw data itself so maybe not worthwhile to store them at all. You might also consider updating the hotel dimension with columns (hotel A has 5 '1' votes and 4 '2' votes) that you'd update as you go on, for easy filtering and categorisation.
User Information: total number of votes: it is factual information about a user (dimension) and it depends on whether you always just want to 'find it out' about a person or whether you are likely to use it to filter other information (i.e. show me all reviews for users who have made 10-20 votes). In that case you might store the total in the user dimension (and/or a banding, like 'number of reviews range' with 10-20, 20-30). You can update dimensions often if you need to, but you're right, it could still just live as a fact only.
As for date dimensions, if the 'grain' is 'day' then you only need one dimension, that you refer to from multiple facts.
As for addresses, you're right that there are arguments on both sides! Many people separate addresses into their own dimension, referred to from the other dimensions that use them. Kimball suggests you can do that behind the scenes if necessary, but prefers for each dimension to have its own set of address columns(but modelled as consistently as possible).

Database relations query

I have two database tables
this is a sample database of a Ticketing system.
Figure 1: Sample table of air ticket.
Figure 2: Sample table of tax.
Requirement:
When ticket is made from the interface, it has multiple taxes of different names every time.
How can I store this information i.e. 'n' number of taxes for each ticket with different names every time.
I have tried to make many to many relationship but the problem is:
For each ticket if the tax is not setup, then need to add the tax first.
Any optimal solution for this?
"the problem is: For each ticket if the tax is not setup, then need to
add the tax first."
This is not a real-life problem. In real life governments declare taxes well in advance of collecting them, This gives organizations sufficient time to amend their systems which need to handle taxes. Tax is never a surprise.
"But this is very tiring solution for the end user.... to make bunch
of tax setup for each ticket"
This sort of thing is reference data, and is the duty of the system developer (hint: that's you) to populate the reference data tables. Or at least provide a screen where the user can create or amend various taxes. This is a different function from defining a ticket type.
The Ticket Creation screen should have a drop-down list (or similar widget) displaying all the existing taxes, which allows the user to pick the relevant one(s). If you reall think it's necessary you can include a link to the Create Tax screen, but that really is a very confusing workflow.
If the commentators are correct, and this is a ticket purchasing function, then your design is seriously wrong. Sales taxes must be included automatically to the cost of the purcahse as part of the transaction. Otherwise nobody would pay any tax.

Is that possible to filter the next activity based on the user group and show in the drop down box?

I have a scenario as given in the below workflow diagram using core service.
First step is manual step author will create/edit content and finish the activity and it is assigned to everyone.
In the second step, I want to do filter the users based on their groups.
In the third step, couple of scenario
a. If the user belongs to group "A" I want to list out all the next 3 available activities, User A can choose any one of these 3 activities.
b. If the user belongs to group "B", I want to list out "Reviewer" and "Approver" activity as next activity, user b can select any one of these 2.
Can any one give some idea to achieve this?
You should turn your problem around. Yes, it is possible, but the amount of knowledge required will be a huge barrier for you to implement.
So, instead think about it differently.
Change your "Filter Next activity" automated activity to an automatic decision, and have your code that determines the group membership also determine which activity should be next
have 2 forward paths from there - 1 for the users of Group A, other for the users of group B
on each forward path, have different selection options. You may try having links to the same activity from 2 different manual decisions, I don't know if that works though.
Worst case scenario you'll have repeated activities (not in name, but in function), and you saved yourself about 2 months of headaches trying to cope with the learning curve of doing CME extensions.
The simple answer to your initial question is: "no, this functionality is not out of the box".
But of course many things are possible by implementing critical parts yourself.
You'd probably need a GUI extension of some sorts to allow the user to pick from a list.
You'd need to store the information between phases of your custom solution.
And you'd then need some code in an automated workflow activity to implement the picking of the next activity.
Most of these steps have been covered in other questions already. Did you have a look for each of these? If so, you might want to share how far you already got and where you are stuck.

Resources