OrientDB Select query with multiple conditions - select

I am beginner in OrientDB and I have a scenario as below,
I want to select all the permissions "Adrian" has on "Workspace A"
I can see from the graph that "Adrian" will have all the permissions but I am not able to form the Select query in OrientDB for that.
The classes are as below,
I think the query should look like below but it doesn't return any result,
SELECT name, out('isOfType').in('ofType').out('hasA').name as permission
FROM resource
WHERE name = 'Workspace A' and
out('isOfType').in('OfType').in('hasARole').name = 'Adrian'

graph operators return collections, so you have to use CONTAINS instead of =
eg.
SELECT name, out('isOfType').in('ofType').out('hasA').name as permission
FROM resource
WHERE name = 'Workspace A' and
out('isOfType').in('OfType').in('hasARole').name CONTAINS 'Adrian'

Related

How to query datasets by group with CKAN API?

I have managed to create a query to get datasets by tags. For reference I have the following query:
http://localhost/api/3/action/package_search?fq=tags:(my-first-tag%20AND%20my-second-tag)&rows=2
Now, I need to filter these results by the group also. I added a dataset to a group and can see the group as:
http://localhost/api/3/action/group_list
But how can I add the group to the previous query? I can't seem to find anything that works.
You can use the filter query (fq) to search using the group name. For e.g to search the datasets that are in the test group
https://demo.ckan.org/api/3/action/package_search?fq=groups:test-group
To include the two fq, we need to make the query like this:
http://localhost/api/3/action/package_search?fq=tags:(my-tag-1%20AND%20my-tag-2)+groups:my-group-1&rows=2

How to define a tags / value query in Grafana 7.4?

I am having some trouble understanding the concept of Value groups/tags in Grafana 7.4.x with MySQL as a data source.
My main query gets the Countries
SELECT
NAME as __text,
id AS __value
from
countries
The tags query gets the Continents
SELECT
NAME as __text,
id AS __value
from
continents
That works so far, tags are shown in the list, but nothing happens once I click on them.
My tags query:
continents.$tag.*
The tags query seems to be the problem. Any help is greatly appreciated.
3 queries are involved:
The first one is under "Query Options" -> "Query": This one should list all the values (all the countries in your case).
The second query is the "Tags query" under "Value groups/tags": This query should list all the Tags you want (continents).
The third query is "Tag values query": This is where the magic happens, this query should return all the different values matching the selected tags, so, you must add a WHERE clause somewhere that Grafana will use to create a query to get the correct values, ...WHERE continent = '$tag'. <- $tag will automatically be replaced by a list of tags the user has chosen.
Be aware that the official documentation provides examples for InfluxDB datasource, since you are using MySQL, you must use SQL queries everywhere, so continents.$tag.* is invalid.

How to select all nodes of a certain type connected via an Edge?

I am quite new to OrientDB, I have a Node labeled Resource, and i have other nodes labeled User and Administrator connected to it. I know I can Select all the Users who are "HasAccessTo" the Resource, like this:
SELECT in("HasAccessTo") FROM Resource
But how do I write the Query if I want to Select only those who are labeled as User and not Administrator?
Thanks for the help in advance.
Long answer:
SELECT FROM (
SELECT expand(in("HasAccessTo")) FROM Resource
) WHERE #class = "User"
Short answer:
SELECT in("HasAccessTo")[#class = "User"] FROM Resource
or (expanded)
SELECT expand(in("HasAccessTo")[#class = "User"]) FROM Resource

How to count push events on GitHub using BigQuery?

I'm trying to use the public GitHub dataset on BigQuery to count events - PushEvents, in this case - on a per repository basis over time.
SELECT COUNT(*)
FROM [githubarchive:github.timeline]
WHERE type = 'PushEvent'
AND repository_name = "account/repo"
GROUP BY pushed_at
ORDER BY pushed_at DESC
Basically just retrieve the count for a specified repo and event type, group the count by date and return the list. BigQuery validates the following, but then fails the query with a:
Field 'pushed_at' not found.
As far as I can tell from GitHub's PushEvent documentation, however, pushed_at is an available field. Anybody have examples of related queries that execute properly? Any suggestions as to what's being done incorrectly here?
The field is called repository_pushed_at, and you also probably meant to include it in the SELECT list, i.e.
SELECT repository_pushed_at, COUNT(*)
FROM [githubarchive:github.timeline]
WHERE type = 'PushEvent'
AND repository_name = "account/repo"
GROUP BY repository_pushed_at
ORDER BY repository_pushed_at DESC

Use Facebook API to list group members' join date and inviter

I can use the Facebook Graph API to get a list of group members. The simplest way to do this is to go to the Graph API Explorer and do a GET request of the form {group_id}/members. Is there a way to similarly obtain the members' join date and who they were invited by?
The relevant Graph API doc doesn't seem to mention it. But I know the information is stored by Facebook because it is possible to list all of the group members and their inviters through Facebook itself. Is there a way to get this information through the API?
EDIT: Nothing in the FQL group or group_member API either.
While this information is not available on the API, you can get it by using Selenium to scrape the members page.
First, instantiate a driver and use it to get the members page:
driver.gethttps://www.facebook.com/groups/your group number/members
Then, look for the member information:
containers = driver.find_elements_by_tag_name('td')
Finally, iterate through the web elements, extracting text and parsing resulting list for joined date information:
member_info = container.text.split('\n')
name = member_info[0]
member_since = member_info[-1]
You'll still have to map this information to the user ids, which you can do by looking for another element in the container and using REGEX.
`def parse_id(self, container, name):
hovercard = container.find_element_by_link_text(name).get_attribute('data-hovercard')
regex_id = re.compile('php\?id=(\d*)')
member_id = regex_id.search(hovercard).group(1)
return member_id`
It is indeed stored by Facebook and retrieved for use with internal APIs. For the Graph API however it is not possible to get this information.
All the fields available for a group_member are listed at SELECT column_name FROM column WHERE table_name = "group_member"