What I want to do
Hello everyone,
Weird genres in this context are the ones that have only one movie.
Get all the weird genres ordered by the number of genres of the movie.
{
weirdGenres(func: eq(count(~genre), 1), orderdesc: val(numGenres)) @cascade{
genre_name: name@en
movie: ~genre {
name: name@en
numGenres as count(genre)
}
}
}
This is not getting my weird genres sorted by the number of genres of the film.
What I did
I used a support function (max, avg, sum) to move the variable one level up and be able to sort.
{
wierdGenres as var(func: eq(count(~genre), 1)) @cascade {
~genre {
numGenres as count(genre)
}
temp as max(val(numGenres))
}
ordered(func: uid(wierdGenres), orderdesc: val(temp)) @cascade {
weirdGenre:name@en
movie:~genre {
name:name@en
genres: val(numGenres)
}
}
}
Expected output
"ordered": [
{
"weirdGenre": "ShĹŤjo manga",
"movie": [
{
"name": "Adolescence of Utena",
"genres": 15
}
]
},
{
"weirdGenre": "C-Movie",
"movie": [
{
"name": "Ken Russell's Fall of the Louse of Usher",
"genres": 11
}
]
},
{
"weirdGenre": "Erotic Science Fiction",
"movie": [
{
"name": "Flesh Gordon",
"genres": 11
}
]
},
{
"weirdGenre": "Edupunk",
"movie": [
{
"name": "Internet Rising",
"genres": 8
}
]
},
]