// Find the highest rank of a Sound Recording on a Chart and create a PEAKED_ON relationship
MATCH
    (sr:SoundRecording {isrc: 'BE8HR1900016'}),
    (c:Chart {platform: 'spotify', target: 'track', country: 'FR', type: 'regional', frequency: 'daily'}),
    (sr)-[ro:RANKED_ON]->(c)
WITH sr, c, ro
ORDER BY ro.position ASC
LIMIT 1
MERGE (sr)-[po:PEAKED_ON]->(c)
    SET
        po.timestamp = ro.timestamp,
        po.position = ro.position

// Make sure it worked
MATCH
    (sr:SoundRecording {isrc: 'BE8HR1900016'}),
    (c:Chart {platform: 'spotify', target: 'track', country: 'FR', type: 'regional', frequency: 'daily'}),
    (sr)-[po:PEAKED_ON]->(c)
RETURN po
