I am trying to grab vertices connecting a Request vertex to each Card vertex. The card-to-request relationship is one-to-many (each card has many requests).
A card may be connected to a request with the property "Status"
: "In Use"
if the card is being used. Each card will also be connected to many requests with the properties "Status"
: "Future Use"
or "Past Use"
.
I am trying to create a table that displays the most recent use of each card.
Thus, I want to return a request if the edge connecting it to the card has the property "Status"
: "In Use"
.
If the card is not currently in use, I look for the request that most recently used the card ("Status"
: "Past Use"
).
If the card has never been used, I look for the soonest upcoming request that will use the card ("Status"
: "Future Use"
).
I have attempted to use coalesce
:
.coalesce(
select('request')
.outE().hasLabel('AssignedTo}').has('Status', 'In Use'),
select('request')
.outE().hasLabel('AssignedTo').has('Status', 'Past Use').order().by('Timestamp', decr).limit(1),
select('request')
.outE().hasLabel('AssignedTo').has('Status', 'Future Use').order().by('Timestamp', incr).limit(1)
).as('status')
But this only returns a single record (In Use). Another version:
.coalesce(
select('card')
.inE().hasLabel('AssignedTo}').has('Status', 'In Use'),
select('card')
.inE().hasLabel('AssignedTo').has('Status', 'Past Use').order().by('Timestamp', decr).limit(1),
select('card')
.inE().hasLabel('AssignedTo').has('Status', 'Future Use').order().by('Timestamp', incr).limit(1)
).as('status')
This only returned two records (both In Use).
I tried choose
awhile ago and couldn't get that to work either (don't recall what happened exactly).
Expected:
Get back a single vertex that has an edge with the property "Status"
: "In Use"
.
If this edge doesn't exist, get the most recent vertex that has an edge with the property "Status"
: "Past Use"
.
If there are no edges that qualify, get the soonest upcoming vertex that has an edge with the property "Status"
: "Future Use"
.