I'm in the process of developing an app that manages the inventory in a shop. I assume that there could be potentially more than one user working with the app and therefore a scenario where both could reserver for checkout the same item (but for two different recipients is a likely one.
Are there any gems that or techniques someone could recommend that could help with this?
When the users create a new order they get the list of objects that are not reserved (this is a rental shop) but if one leaves the form open for a bit, without making the reservation, someone else still sees the item as available.
Can anyone offer advice about this? Hope the question is not too vague.
Is callbacks the way to go, by creating a before_save validation?
Thank you!
You can use a gem like delayed_job where you can schedule a job to be run at certain time, in this case, after a certain timeout.
You can then schedule a job which removes the reservation status on an item. If the user is successful in reserving the item, the delayed job needs to be deleted.
To delete the item from this activerecord table, you can find it based on the table attributes specified here.
Related
This is an overall general design question around data integrity. I have an app that takes in user data and stores it in a DB. It is then "processed" via SSIS (SQL Service Integration Services). From this point the results are returned to the user and each record now has a Parent HASHID and it's own ID associated to it.
At this stage the user can add additional details to these records (comments, status updates etc) via an HTML form.
My question is what is the 'standard' process for tracking such changes. Create a new table for 'comments', one for 'status updates' with hashid references to the original record? OR, Update the original records and append each update to the same record (messy in my eyes)?
In the long term the app could get more complex or simplified so having a good frame-work will definitely keep things manageable for major changes. Just looking to get some general guidance.
I'm happy to add more detail but want to keep it non-specific as my question is quite broad.
Thank you.
I want to create an on-demand process of some kind in Dynamics CRM 2013 that will run on multiple records of the same type. The process will create an equal number of records of another type, and all will relate to the same parent record. I can imagine how a workflow would be used to create the new child records but I am not sure how I could create the parent record and associate it with the child records.
If you're running on multiple records, then I presume your are starting from a gridview of some sort. If that's the case, then the solution is easy. Just create a custom ribbon button that accepts the selected records as a parameter, and runs a custom javascript. That will accomplish what you need in a nice elegant solution.
Because it's running javascript, you will have full control to be able to do everything you need. One of the features of ribbon buttons, is they can receive the selected records in a parameter as an array.
But if you don't want to do all the work in javascript, you can have the script pass the parameters to a custom Workflow or Action.
As its already been mentioned, a workflow won't be able to do this alone, because it can only run on a single record, and cannot accept multiple records as an input parameter.
Jason I think the point here is to automate the process. Lee you are correct in your assessment that creating the work order with a workflow step is easy to do while creating the child work order items is either difficult or impossible. Even if you managed to hack this together with several workflows triggered by different events during the process the end result would be a UX/maintenance nightmare.
The simplest and best solution is to have piece of plugin logic that you trigger with your workflow. This plugin code would create a new work order and associated work order items based on the context of the service you run the workflow against. If you would like for this action to be triggered by a database operation instead of manually triggered this would be simple to do as well.
You aren't going to be able to do this via a CRM dialog because it can only run against one record. You can accomplish this fairly easily by leveraging existing CRM functionality:
If it doesn't already exist, create a field in your service entity (the Work Order Item) called new_MasterWorkOrder (or something similar) which is link to a Master Work Order entity.
Create your master record - this would be your Overall Work Order.
From your Work Order Item record entry listing, select all the items you want to add to the Master Work Order record created in the previous step. Alternately, you could use an Advanced Find to locate the target records.
Click the Edit button to initiate the CRM bulk/multi-record edit form.
In the new_MasterWorkOrder field, select the Overall Work Order previously created.
Save.
Once the process complete, all of the Work Order Items you selected will now be linked to your Overall Work Order.
It sounds like you might a need a step before this to create a Work Order Item from selected Service entities. You should be able to accomplish this easily by having a workflow which runs takes in a Service entity as a parameter and builds a Work Order Item from it. Once you have these built you can link them to an Overall Work Order using the process above.
I am currently working on a client project requires the admins to setup some daily recurring tasks for users of the system. to take temperature measurements of food
the user then fill out the task ( usually around 5 fields of data ) and if the temperatures validates the system creates a "report" on that given task. and it disappears from the users overview. the task is just not showen cause the same task is gonna pop up gain later on the week etc.
then today it stroke me that if a admin changes the control temperature values on a task it will reflect on all filled out tasks cause of my relations. and that is a no go i have to be able to change the values (they are laws regulated) and not affect the already completed reports.
What is a good approach for this ? my current one is to have the report table include all the nessaary data fields from a task and replicate em over so i can recreated the report based on the task at that give time.
or should i make the values not ediable after they are created and tell the administrators to disable the task and create a new one ? that way i allways have old task ids i can fetch values from
Hope i make sens :) ells ill be happy to explain more and make some diagrams.
I have just started using RavenDB on a personal project and so far inserting, updating and querying have all been very easy to implement. However, I have come across a situation where I need a GetOrCreate method and I'm wondering what the best way to achieve this is.
Specifically I am integrating with OpenID and once authentication has taken place the user is redirected to my site. At this point I'd either like to retrieve their user record from Raven (by querying on the ClaimsIdentifier property) or create a new record. The user's ID is currently being set by Raven.
Obviously I can write this in two statements but without some sort of transaction around the select and the create I could potentially end up with two user records in the database with the same claims identifier.
Is there anyway to achieve this kind of functionality? Possibly even more importantly is do you think I'm going down the wrong path. I'm assuming even if I could create a transaction it would make scaling out to multiple servers difficult and in anycase could add a performance bottle-neck.
Would a better approach be to have the Query and Create operations as separate statements and check for duplicates when the user is retrieved and merge at that point. Or do something similar but on a scheduled task?
I can't help but feel I'm missing something obvious here so any advice on this problem would be greatly appreciated.
Note: while scaling out to multiple servers may seem unnessecary for a personal project, I'm using it as an evaluation of Raven before using it in work.
Dan, although RavenDB has support for transactions, I wouldn't go that way in your case. Instead, you could just use the users ClaimsIdentifier as the user documents id, because they are granted to be unique.
Alternatively, you can also stay with user ids being generated by Raven (HiLo btw) and use the new UniqueConstraintsBundle, which lets you attribute certain properties to be unique. Internally it will create an additional document that has the value of your unique property as its id.
Is it possible to restrict write access to a Perforce depot, but still allowing particular changelists? Basically, instead of spending lots of time managing users in a write-enabled group during a code lock (add user, wait for check-in, remove user) I'd rather just have a list I add approved changelist numbers to.
You can create a trigger script to do it. I do the same thing using JIRA. When someone types in a comment, they include the Jira number. My trigger queries the Jira, and makes sure there is the appropriate comment in the Jira before allowing them to submit.
You can't really do it on changelists since you don't know the changelist number until the actual submit happens.