I'm trying to query Google Admin User directory on two parameters: name and orgName. I have tried several variations of the below, which does not work:
var userList = AdminDirectory.Users.list({
customer: 'my_customer',
maxResults: 100,
query: 'name:david AND orgName=hotel',
viewType: 'domain_public',
projection: 'full'
}).users;
... but I think it illustrates what I'm trying to do. My questions are:
1) Is this possible?
2) If I might push my luck, is it possible to query organization location? (I didn't see anything like this in the documentation...)
Have already consulted https://developers.google.com/admin-sdk/directory/v1/guides/search-users, did not find anything there.
The query does not support AND or OR operators, only one search term is allowed.
I'd suggest querying on the more specific (probably name) field and then filtering locally on the additional fields. So in other words, query=name:david and then look for hotel in the orgName field locally.
The query now supports only AND operator.
Multiple clauses are separated by whitespace and are implicitly joined
by an AND operator.
https://developers.google.com/admin-sdk/directory/v1/guides/search-users
Related
My Usecase:
We allow the users of the system to create a list(i.e segment) of contact details based on the variety of the filters from the UI. So they create the segment using a form to select say all people living in a particular state.
So the issue here is that, when the new contacts are added, I want these segments to be updated as well. The solution that I can think of is saving SQL query for each segment and update each segment when new contacts are added using these SQL queries.
I thought of saving only parameters in a json string format but complication in that case is filters available are over multiple tables and there is no way to generate the dynamic SQL query as it involves joins and different filters (i.e. 'in', 'endswith', etc).
I don't think either of them is the best solution. Any better ideas?
Any help would be appreciated, thanks in advance!
Update: JSON parameter and Query I need
{'is_buyer': ['1'], 'is_executive_member': ['1'], 'is_member': ['1'], 'survey_participant': ['1'], 'cluster': ['A'], 'state': ['state1'], 'city': ['ab', 'cd'], 'gender': ['male']}
Expected query output:
SELECT * FROM `contacts` INNER JOIN `contacts_clusters` ON (`contacts`.`KEY` = `contacts_clusters`.`KEY`) WHERE (`contacts`.`IS_BUYER` IN (1) AND `contacts`.`IS_EXECUTIVE_MEMBER` IN (1) AND `contacts`.`IS_MEMBER` IN (1) AND `contacts`.`SURVEY_ID` IS NOT NULL AND `contacts_clusters`.`CLUSTER` IN ('A') AND `contacts`.`STATE` IN ('state1') AND `contacts`.`CITY` IN ('ab', 'cd') AND `contacts`.`GENDER` IN ('male'))
This is just one of the example of segment filter. There are much more parameters and tables which can used for the creation of segment.
I think you'd be better off storing the required parameters for the segment, then when new contacts are added, you'd check if the new contacts match according to the stored segment parameters. If they do, then you'd update the segment.
Can we sort google drive files to show the newest or last modified ones on the top ?? I only can see the list and grid option for showing files in iframe. If not , any advice or alternative solution for this issue that my client is facing it ?
Here is the documentation you needed to list files from the drive.
This method accepts the q parameter, which is a search query combining
one or more search terms. For more information, see the Search for
Files and Team Drives guide.
And you can actually sort it by using the parameter orderBy.
A comma-separated list of sort keys. Valid keys are 'createdTime',
'folder', 'modifiedByMeTime', 'modifiedTime', 'name', 'name_natural',
'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred', and
'viewedByMeTime'. Each key sorts ascending by default, but may be
reversed with the 'desc' modifier. Example usage:
?orderBy=folder,modifiedTime desc,name. Please note that there is a
current limitation for users with approximately one million files in
which the requested sort order is ignored.
You can also test by Try it now.
I've got a custom searchable member page on a WordPress site running s2member and I have a client that wants to use the mutli select box feature for the "category" data listed members can enter. My current code falls down here as the REGEX I currently use to select the category from the meta_value field only works with the single select box.
Here is the data as it appears in the database field:
s:8:"category";a:1:{i:0;s:17:"Business services";}}
Here is my current AND line in my SQL statement:
AND UMS.meta_value REGEXP '.*\"".$_SESSION['searchfield']."\";s:[0-9]+:\".*".$_SESSION['searchvar'].".\".'
How can I modify the above REGEX to work with the new multi option data? I’ve tried a few things but REGEX isn't a strong point of mine.
Thanks in advance!!
We are working on magento database and tables. Magento seems to write a code in table sales_flat_order field protect_code to define if there is a invoice or a shipment done already. It would look something like
01b335 or
a0a243
But there is no key to understand what this protection code means. Is there an explanation of the meaning of these codes and how they are generated?
Where is it generated?
If you look in app/code/core/Mage/Sales/Model/Order.php on around line 2052, you will find the following:
$this->setData('protect_code', substr(md5(uniqid(mt_rand(), true) . ':' . microtime(true)), 5, 6));
This is where protect_code is generated for the order (using a combination of md5, uniqid, and random integer.
What is it used for?
If you look in app/code/core/Mage/Sales/Helper/Guest.php and find the loadValidOrder function. You will see protect_code used in some areas to ensure the order being loaded is the correct one for the guest's cookie value.
It's also used in other areas, such as tracking information comparisons. You can see several instances of the getProtectCode() method being called in the Shipment models to compare the order to the tracking information. An example of a function that uses it is:
public function getTrackingInfoByTrackId()
{
$track = Mage::getModel('sales/order_shipment_track')->load($this->getTrackId());
if ($track->getId() && $this->getProtectCode() == $track->getProtectCode()) {
$this->_trackingInfo = array(array($track->getNumberDetail()));
}
return $this->_trackingInfo;
}
As you can see with $this->getProtectCode() == $track->getProtectCode(), the tracking protect_code must match the Shipment protect_code.
I have a database table that contains URLs in a column. I want to show certain data depending on what page the user is on, defaulting to a 'parent' page if not a direct match. How can I find the columns where the value is part of the submitted URL?
Eg. I have www.example.com/foo/bar/baz/here.html; I would expect to see (after sorting on length of column value):
www.example.com/foo/bar/baz/here.html
www.example.com/foo/bar/baz
www.example.com/foo/bar
www.example.com/foo
www.example.com
if all those URLs are in the table of course.
Is there a built in function or would I need to create a procedure? Googling kept getting me to LIKE and REGEXP, which is not what I need. I figured that a single query would be much more efficient than chopping the URL and making multiple queries (the URLs could potentially contain many path components).
Simple turn around the "Like" operator:
SELECT * FROM urls WHERE "www.example.com/foo/bar/baz/here.html" LIKE CONCAT(url, "%");
http://sqlfiddle.com/#!2/ef6ee/1