This quite frankly is driving me up the wall. (connecting to a node.js server that needs the order id)
The post id is whats actually used when using the /wp-json/wc/v3/orders/
So something like = /wp-json/wc/v3/orders/259992?customer_key ... Works but using the "number" item which is connected to this (the order number) it errors. For example's sake we will say the order number linked with the order post id I used above (259992) = 99794
I've been trying to get the result by order number.
If I run /wp-json/wc/v3/orders?customer_key ... it lists all the orders no problems. However if I attempt to run /wp-json/wc/v3/orders?select?q=number:99794?consumer_key= ... I get the following error (i have also tried this with ?search?q=number:99794?) no no avail
Which is daft because i know you can list resources. I just did it with /wp-json/wc/v3/orders?customer_key ...
I just need it to return the json for the order id not the post id. Is this at all possible?
Have also tried: /wp-json/wc/v3/orders?filter[number]=99798?customer_key ... Same error
Related
I am trying to add a run with the add_run endpoint, but in my automation code I only have the test cases ids but not the project id (which according the the docs is mandatory).
Right now I am doing:
get all projects with /get_projects
get all cases /get_cases/{project_id}
Then I loop over the cases I get and add the project_id to the case so I could create an add_run with the proper project_id.
This seems like the wrong way to do it.
Anybody has a better solution?
Also is there a way to create a run without a project_id? for example if I have a sanity run that includes cases from many projects.
Any help is appreciated.
You can do the following to get the parent project ID:
get the case by ID and capture value of the suite_id field
get the parent suite by the value of the suite_id field and capture value of the project_id field <--- here you have your project ID and can use it for creating runs.
I have an array of post codes coming from an input:
$postCodes = collect(["BK13TV", "BK14TV", "BK15TV", "BK16TV"]);
In my database I already have two of the post codes - "BK13TV", "BK16TV".
So I would like to run something like this:
$postCodeModels = PostCode::findManyOrCreate($postCodes->map($postCode) {
return ['code' => $postCode]
})
My initial approach was to load all the post codes, then diff them against the postCodes from the input like so:
PostCode::createMany($postCodes->diff(PostCode::all()->pluck('code')))
However, here it means that I am loading the entire content of post_codes table, which just seems wrong.
In the ideal case, this would return all post code models matching the passed post codes as well as would create entries for post codes that did not exist in the database.
First I need to retrieve existing postcodes:
$existingPostCodes = PostCode::whereIn('code', $postCodes)->get();
The find all the post codes in the input, that are not stored yet in database:
$newPostCodes = $postCodes->diff($existingPostCode->pluck('code'));
Finally retrieve all the new post codes as models:
$postCodeModels = PostCode::whereIn('code', $postCodes)->get();
Admittedly, this still takes three queries, but does eliminate the crazy stuff of loading an entire table worth of data.
I am working on a rails 4.2.5.1 application where I am using a custom scope :
scope :listing_search_cities, ->{group(:city).count}
I was using this scope to create facets and filters. Everything was working fine on MYSQL. When I pushed this to Heroku, due to PG I got the error that created_at must be added to the group function.
I did that, the error went away and my scope is now:
scope :listing_search_cities, -> {group('city, created_at').count}
However, this gives a hash of created_at time and count like:
{2018-10-10....UTC => 2}
and not city name and count which is what I want(and the query gives this in MYSQL)like
{ "tempe" => 2}
I just want the city name and count of that selection(search results) I provide to the scope.
How can I do it in PG where on a search result on listings, I can get the city names and count of each city in a hash using group and count?
I read elsewhere about people using unscoped? How to use that?
Nevermind! For those who face the same problem: Just reverse the order of group:
scope :listing_search_cities, -> {group('created_at, city').count}
and you are good to go.
I have two tables, one called Company and the other called User, each user is related to one company using ForeignKey. So I can use reverse relation in Django to get all users for specific company (e.g. company.users)
In my case, I'm building ListAPIView which return multiple companies, and I'd like to return latest created user. My problem is that I don't want to use prefetch_related or select_related so it will load all the users, as we might end up having thousands of users per each company! Also I don't want to load each latest user in a separate query so we end up having tens of queries per API request!
I've tried something like this:
users_qs = models.User.objects.filter(active=True).order_by('-created')
company_qs = models.Company.objects.prefetch_related(
Prefetch('users', queryset=users_qs[:1], to_attr='user')
).order_by('-created')
In this case, prefetch_related failed as we can't set limit on the Prefetch's queryset filter (it gives this error "Cannot filter a query once a slice has been taken.")
Any ideas?
I think you are providing an object instead of a queryset Prefetch('users', queryset=users_qs[:1], to_attr='user')
Using the Box 1.0 REST API, I am trying to work with the functions in SOAP UI.
The API doc for get_managed_users with user_id=12345 (internal id retrieved with get_user_id call correctly) is returning all the users. The docs say that would be the case if you do not specify a user_id value. But my full command is: (Token and API key changed to protect the clueless)
https://www.box.com/api/1.0/rest?user_id=27360&auth_token=blahbalhblah1234&action=get_managed_users&api_key=someKeyYouShouldNotSee
Now I could work with the complete result list, but that won't scale as we get thousands of users into the system.
I can make a call with edit_managed_user, using the same user_id value and the change is reflected in the UI, and in the next get_managed_users call. Thus I do have the correct user_id value, I would so assume.
I tried testuser#gmail.com as the user_id value as well, and get the entire list back. This leads me to believe that somehow I am sending user_id wrong, but I just do not see it.
Any hints? Why, with what seems like a valid user_id value is it acting like it is absent or incorrect?
Most likely you have either called this method with an invalid user_id, or one that is not in your set of managed users. Can you double check that the user comes back in your list of already managed users?