What is a good URI design for creating a new resource? - reactjs

I currently have:
/exercises, which lists all exercises
And /exercises/1, which shows exercise with id 1
One exercise can have zero or many runs:
/runs Shows all runs across all exercises
/runs/1 Shows run with is 1
So how can I have a page that allows you to create a run for an exercise?
Options I thought of are:
/exercises/1/run-wizard
/runs/wizard?exerciseId=1
What do you think?

It's really up to you. One way to go would be:
/exercises/:id1/run/add <-- ADD RUN TO EXERCISE id1
/exercises/:id1/run/:id2 <-- ACCESS RUN id2 ON EXERCISE id1

Related

How to add sets and reps to Exercise collection in Firebase Firestore

Perhaps, I am not asking the correct question, this has been the issue for me (not fully understanding the problem), and Im not actually sure what it is that Im trying to ask or solve exactly, but I will explain my thoughts as best I can.
I am currently trying to create a fitness tracker app. I am currently using firestore database. To keep it simple I just want to be able to select an Exercise (i.e bench press), and then have sets attached, with reps and the amount of weight inside the reps category. Currently I am thinking about it as...
Collection: "Exercises"
Documents:
Field: Name: Bench Press
Field: Muscle Group: Chest
I would like to be able to select the Exercise name, and then prompt the user to individual sets that have fields that accept a number for the weight (lbs) and reps. I would like the numerical fields to have default values of null or 0 since the application is awaiting on that data to be entered by the user. Any help would be greatly appreciated as this is my first web app project I am building in React.

How can I combine nominal data on SPSS?

I am doing my dissertation about brand recall. I created on spss a variable with the brands that the respondents recalled first (eg: 1 = "Facebook", 2="Instagram" and so on). I also created a variable with the brands that the respondents recalled in second place (1= "Facebook" and so on). I want to combine those two variables into one, in order to have only one variable called "brand recall". However, I don't know how to do it. Basically, when I sent the questionnaire to the respondents they mentioned more than one brand in their answers. I don't know how to combine all those answers into one in spss.
You can't do this because you will alter the data. From what I read you have a ranking question or a multiple answear question.
The first variables is for the FIRST brand recalled
The second variables if for the SECOND brand recalled.
Imagine that you want the answer gave in second variable aka second brand to be moved in the first variable. How will you make difference what was the first brand recalled and second brand recalled.
Another thing. If a respondent selected Facebook as first brand(in the first variable) in the second option Facebook was showed/you have the possibility to select it again? If that's the case this is not ok. Imagine that I can select Facebook in first brand recalled and also in the second one.
Give more details and maybe I can help you
Well if it's an open-ended question you can do a basic coding of that OE question and it goes like this:
1.run a basic frequency of the open-end question. example: fre [Open-end question].
2.after you see what answers you have like Facebook, Twitter etc. will have an overview of what brands were mentioned.
Create a numeric variable named brands. example: numeric brands (f2.0) assuming that you have more than 10 individual brands mentioned in the open-end. In case you have more than 100 brands mentioned write (f3.0).
Add value labels for the newly created brands variable. example:
value labels brands
1"Facebook"
2"Instagram"
3"Twitter"
4"[Any other brands mentioned".(very important to have . at the last value label code added)
after you created the variable and added all the brands as value labels/answear options the recode part start:
if [Open-end question]="the exact wording" brands=[select what answear option].
exe.
Example:
if [open-end question]="IG" brands=2. Respondent referred to Instagram.
if [open-end question]="Faaacebook" brands=1. Respondent referred to Facebook.
.
.
.
exe. (do not forget to add at the end .exe in order to run the syntax code)
After you populated the brand variable run a simple frequency to see how many mentions you have.
Hope this answers helps.

How to make a primary key with 2 columns being secure without autoincrement?

I have a table named [Purpose] and another one named [PurposeMoviment].
Each Time a Purpose is edited (values​​, products, services, deadline, etc.), the PurposeMoviment will be generated.
Can I have PurposeMoviment with 2 pk columns (Purpose_ID, PurposeMoviment_ID) where PurposeMoviment is manually created by my system?
When I say manually created, is a simple GetLastPurposeMoviment + 1.
Its safe?
I'm asking because I want to show the actual number of moviments, like 1, 2, 3 ... Using identity, the moviment number will be 1 ... 4 ... 193.
Where I'm wrong?
Thanks
EDIT
I'm new to big environments and afraid about many peoples press the button to insert purpose at same time and make my manual-increment fails.
I'm using MVC5, Entity Framework 6 and Repository Pattern.
Thanks guys

How to make datastore keys mapreduce-friendly(-er)?

Edit: See my answer. Problem was in our code. MR works fine, it may have a status reporting problem, but at least the input readers work fine.
I ran an experiment several times now and I am now sure that mapreduce (or DatastoreInputReader) has odd behavior. I suspect this might have something to do with key ranges and splitting them, but that is just my guess.
Anyway, here's the setup we have:
we have an NDB model called "AdGroup", when creating new entities
of this model - we use the same id returned from AdWords (it's an
integer), but we use it as string: AdGroup(id=str(adgroupId))
we have 1,163,871 of these entities in our datastore (that's what
the "Datastore Admin" page tells us - I know it's not entirely
accurate number, but we don't create/delete adgroups very often, so
we can say for sure, that the number is 1.1 million or more).
mapreduce is started (from another pipeline) like this:
yield mapreduce_pipeline.MapreducePipeline(
job_name='AdGroup-process',
mapper_spec='process.adgroup_mapper',
reducer_spec='process.adgroup_reducer',
input_reader_spec='mapreduce.input_readers.DatastoreInputReader',
mapper_params={
'entity_kind': 'model.AdGroup',
'shard_count': 120,
'processing_rate': 500,
'batch_size': 20,
},
)
So, I've tried to run this mapreduce several times today without changing anything in the code and without making changes to the datastore. Every time I ran it, mapper-calls counter had a different value ranging from 450,000 to 550,000.
Correct me if I'm wrong, but considering that I use the very basic DatastoreInputReader - mapper-calls should be equal to the number of entities. So it should be 1.1 million or more.
Note: the reason why I noticed this issue in the first place is because our marketing guys started complaining that "it's been 4 days after we added new adgroups and they still don't show up in your app!".
Right now, I can think of only one workaround - write all keys of all adgroups into a blobstore file (one per line) and then use BlobstoreLineInputReader. The writing to blob part would have to be written in a way that does not utilize DatastoreInputReader, of course. Should I go with this for now, or can you suggest something better?
Note: I have also tried using DatastoreKeyInputReader with the same code - the results were similar - mapper-calls were between 450,000 and 550,000.
So, finally questions. Is it important how you generate ids for your entities? Is it better to use int ids instead of str ids? In general, what can I do to make it easier for mapreduce to find all of my entities mapping them?
PS: I'm still in the process of experimenting with this, I might add more details later.
After further investigation we have found that the error was actually in our code. So, mapreduce actually works as expected (mapper is called for every single datastore entity).
Our code was calling some google services functions that were sometimes failing (the wonderful cryptic ApplicationError messages). Due to these failures, MR tasks were being retried. However, we have set a limit on taskqueue retries. MR did not detect nor report this in any way - MR was still showing "success" in the status page for all shards. That is why we thought that everything is fine with our code and that there is something wrong with the input reader.

How to store keywords for an article

In SOLR, I have a document that has id, words (indexed), raw_text fields. I want to search just words field this way:
Words are infinitives of an article (or say keywords). For parsing and lemmatization(stemming) I use another tool, so that's not the point of the question.
E.g.: for these two articles(texts) words would be:
1 Yesterday I didn't go to work, because it was holiday.
words: yesterday go work because holiday
2 Tommorrow I am going to work in the morning and in the evening I am going shopping.
words: tommorrow go work morning evening go shop
3 words: go tommorrow work
In a search for "go " I want to have 2 retreived first (be more relevant) because of having more "go"-s than 1. Also I want to use longer queries with a bunch of words and have retrieved articles containig most of them most times.
E.g: search for: "go tommorrow work" would return 2 more relevant than 3 because there are two "go"-s contrary to only one in 3
So the question: how should I store words? multiValued or just single ? What field type should be used?
Thank you!
(Single-valued) text would suit you.
The text comes with tokenization, stemming and stop word analyzers.
Stemming uses heuristics to derive the root of a word. Among other things, it would find the root of your articles even in infinitive form :-)
Trying it out for your samples (with a few additions):
Original: Yesterday [yesterday's] I didn't go to work [working, workable], because it was holiday [holidays].
Stemmed: Yesterdai yesterdai s I didn t go to work work workabl becaus it wa holidai holidai
Original: Tommorrow I am going [go,going,gone] to work in the morning [mornings] and in the evening I am going shopping [shoppers, shops].
Stemmed: Tommorrow I am go go go gone to work in the morn morn and in the even I am go shop shopper shop
Because it uses heuristics, "workable" does not share roots with "work" and "gone" doesnt share roots with "go". But its a tradeoff that works much simpler and faster while not diminishing the result quality.
And "didnt" and "I" are stop words according to this list, so they are automatically eliminated.
If you ever observe unacceptable results too often, take the trouble to implement Wordnet. They have lemma, part of speech and other natural language goodies.

Resources