Hi team I am stuck in one situation please help me out in this one
I have a segment vertex and different types of segment vertex separately, what I mean here is we don’t have Segment Vertex which is connected as an undirected edge to Segment Types, we have approx. 12 types of separate vertex in our schema , below image is a sub part of my schema
TYPEDEF Tuple <STRING label, STRING id> custom_def;
ListAccum<custom_def> @childSegments;
SumAccum<INT> @segmentCount;
start = {segment_types.*};
results = select s from start:s-(:ee)-:tt ACCUM s.@childSegments += custom_def(tt.label, tt.id) ORDER BY s.id ASC;
#z = select s from results:s ACCUM
#foreach res in s.@childSegments DO
#if res.outdegree() > 0
#End
#end;
Output:
"results": [
{
"attributes": {
"@childSegments": [
{
"id": "Purchased in the Past 1 year",
"label": "Purchased in Past 1 year"
},
{
"id": "Purchased in the Past 6 Months",
"label": "Purchased in Past 6 Months"
}],
"id": "Purchase Transaction",
"label": "Purchase Transactions"
},
{
"attributes": {
"@childSegments": [
{
"id": "Cart Abandoners",
"label": "Cart Abandoners"
}],
"id": "Session Segments",
"label": "Session Segments"
}
So here the situation where i am stuck is I want count variable in @childSegments {
“id”: “Cart Abandoners”,
“label”: “Cart Abandoners”,
“count”: 45
}
i want count SUMACCUM@localaccumulator something like this. This is for Count the number of Profiles in that segment
Requirement: tt.outdegree() > 0 don’t want to pass the edge type Because some childSegments not connected directly to profile. some are categorical based etc.
If someone can guide me this logic in Global Accumulator array of objects this would be really helpful and improves my understanding towards GSQL an otherwise in the backend I need to take out the data from attributes object and store it into the parent object which will be very time consuming process of for loop.