I am trying to build a query that returns a list of consecutive Olympic games gold medalists. the consecutive part is what I'm struggling with. I'm not sure how to build a list where only dates separated by 4 years are counted to make a win streak.
e.g. this list jumps from 1936 to 1948.
[1932, 1936, 1948, 1948, 1952, 1956, 1960]
so i want
[1932, 1936]
and
[1948, 1952, 1956, 1960]
this is my current query
|| MATCH (a:Player)-[r:COMPETED]->(e:sport)-[r2:COMPETED_AT]->(g:Olympic)|
|---|---|
|| WHERE r.medal = Gold|
|| ORDER BY g.year, a.name ASC|
|| WITH a, collect(r.medal) as results, collect(g.year) as years|
|| CALL apoc.coll.split(results, false) YIELD value as winStreak|
|| WITH a, max(size(winStreak)) as longestStreak, results, years|
|| RETURN a.name as teamName, longestStreak, results, years|
|| ORDER BY longestStreak DESC|
||limit 100|
This works to create a list like the one bellow but im not sure how to only return consectuive int seperated by 4 :
"Aladr Gerevich (-Gerei)" 7 ["Gold", "Gold", "Gold", "Gold", "Gold", "Gold", "Gold"] [1932, 1936, 1948, 1948, 1952, 1956, 1960]
please note i am using int not year as my dates go back before 1900.