We've 1 book left in the inventory. and two people are trying to get the same book ( say person x and person y ). Person x has added book to the cart and about to make payment and person y has also added book to the cart. How would you solve this concurrency problem ?
Based on your description, Looks like you are allowing users to add last item to cart that mean there is no hold on item while its in cart, Now you can add check during check out, checking for item availability like database constraint that stock can not be less than 0 in this case your database transaction will fail and would return error. You can reply back with message saying item out of stock.
Related
Our organization runs a daily transaction list (via saved search) to forecast our opportunity pipeline. For this saved search, we set the customer mainline to false to eliminate duplicate values in our search.
I've built a saved search text formula that references the customer sales team, which I understand is a sublist. This sublist doesn't play nicely with my transaction report and results in duplicate values.
What I want to have happen is for the transaction line item to pull in the name of the sales team member who has a sales team role of "team lead". If there isn't a sales team member with the team lead role, then I want the result to be blank. We do not have any sales teams where there are two team leads, so we will never run up against this.
The problem I'm getting is duplicate values. The report interprets my code to mean if a customer has a sales team member with the team lead role, then duplicate that line item as many times are there are sales team members. As an example, I have a customer with 8 sales team members. My code results in 8 duplicate line items and one line item has the name of the team lead while the rest are blank.
Thoughts on how to resolve? Thank you in advance. My code looks like this:
I cannot change customer main line to false, as this is makes it even more complicated. Leaving customer main line as false displays exactly what I need currently, with exception of the name of the team lead.
CASE
WHEN {customer.salesteamrole} = 'Team Lead'
THEN {customer.salesteammember}
ELSE NULL
END
What I'm looking for is one line item for each transaction and simply the name of the team lead on that transaction. Perhaps the answer is to create a custom field, but I'd like to think the solution can be accomodated in a transaction report.
You can set a filter in the Criteria tab to make sure only the lines that you want are returned. In the Criteria tab under Filter, select the Formula (Numeric) option, and set the Formula to be:
CASE WHEN {customer.salesteamrole} = 'Team Lead' THEN 1 ELSE 0 END
then choose 'equal to' in the operator field and put 1 for the value.
I've been following this tutorial to build a rating system.
Which suggests the following collections:
Movies:
uid
title
Users
uid
name
Stars
movieId
userId
value
Now, suppose I wanted to display only pending movies to be rated by users.
How could this query be written?
If you think you'll actually have a small number of pending and not an imdb sized list you could
Get all movies
Get all movies rated by this user
Use the two collections to firm a list of movies they need to review
Or
1. Add a sub collection to user called unrated movies
1. every time a niche is added to the db add it to every user's collection
1. When a user reviews a movie delete from collection
Or have a value in the stars db of - 1 to represent unrated, add that for all users and all movies, then query by user ID and value is - 1
How can I view all Products that a Customer has purchased using the Stripe API? Is there a specific event that is sent out when a purchase occurs? I'm seeing that there is an Orders item as well, but am not sure that Products can only be purchased as part of Orders.
Sample query for getting all Orders by a Customer:
from stripe import Order
Order.list(customer=customer_1['data'][0].id)
Basically I want to get all non-subscription-based items that the user has purchased -- will querying the API for Orders this way give me all non-subscription-based items, since a Product must necessarily each be tied to an Order, or is there a different/better way of doing this?
You can retrieve all orders for a customer with the list all orders method and the customer parameter.
You can then go through the order's items attribute to find the SKUs included in the order.
Finally, you can use a SKU's product attribute to retrieve the product associated to the SKU.
In Python, you could do something like this:
customer_id = "cus_..."
products = [] # list of products ordered at least once by the customer
orders = stripe.Order.list(customer=customer_id)
for order in orders.auto_paging_iter():
for item in order.items.auto_paging_iter():
if item.type == "sku":
sku = stripe.SKU.retrieve(item.parent)
if sku.product not in products:
products.append(product)
The above code is not very efficient as it would send a SKU retrieve request for every item of type "sku". In practice, you'd likely want to cache the results and only retrieve each SKU once.
In Netsuite, how is the practice of including a free item done? Let's say there will be a free item A for a sales order which exceeds $1000. How do you record this in the system?
Thanks.
There are a few ways. One is just to add the free item with a price level of "Free". The item can be added via script, or by a person like the approver or fulfiller.
For managing the free item price you can also create a 100% discount coupon code that would be applied to the free item when it is added to an order over $1000.
Suppose, I have 1000 sellers (S1.....S1000) of Apparels listed on my site. Since all the sellers are paying some amount to me, I am giving them equal weight-age, and the results are shown based on relevancy.
Now, I am planning to start with premium service, where I am thinking to list one supplier on top for each keywords in search results. Let say, S1 has been given premium search for keywords 'Jeans', so if a user searches 'jeans', I first wants to display this supplier on the top, then display other supplier based on relevancy. Plus, this premium service is for only for one month. So, another supplier say S2 can avail this service in next month and so on.
Is there any plugin, wherein I can store which supplier should be shown for which keyword. I am even OK with making 2 queries to meet the desire results.
Please suggest
I think the Query Elevation Component is your friend, you can configure which documents (and hence which suppliers) come first for any given query, see
https://wiki.apache.org/solr/QueryElevationComponent
If that's too much work, you could also add a new boolean field in your documents, indicating whether the document is to be promoted or not, and in the query, sort by this field first (so promoted documents come on top), and by score next (so most relevant documents come right after the promoted ones).
You can maybe also use the reRanking Componant :
https://cwiki.apache.org/confluence/display/solr/Query+Re-Ranking
With using a query like this :
q=jean&rq={!rerank reRankQuery=$rqq reRankDocs=1000 reRankWeight=3}&rqq=(brand:S1)
The top 1000 of results from query jean will be re-ranking thanks to the boost (of 3) add to the documents which contain the field brand with the value S1.
It can be useful, but in your case I think the QueryElevationComponent is the best.
Be careful, reRanking is only available since version 4.9.