blob: 2b24cc0f2b1fd923f494722871e4c1a0492420a0 [file] [log] [blame]
vinayakb38b7ca42012-03-05 05:44:15 +00001declare function calculate($events){
2for $event in $events
3for $sponsor in $event.sponsoring_sigs
4let $es := { "event": $event, "sponsor": $sponsor }
5group by $sig_name := $sponsor.sig_name with $es
6let $sig_sponsorship_count := count($es)
7let $by_chapter :=
8 for $e in $es
9 group by $chapter_name := $e.sponsor.chapter_name with $es
10 return { "chapter_name": $chapter_name, "escount" : count($es) }
11order by $sig_sponsorship_count desc
12limit 5
13return { "sig_name": $sig_name, "total_count": $sig_sponsorship_count, "chapter_breakdown": $by_chapter }
14}
15
16let $result := calculate(dataset('Events'))
17return $result