blob: 9a77c84eb56a37dfcef62a68835c5b3a52cc3450 [file] [log] [blame]
buyingyi2fd7fa62014-11-24 19:31:55 -08001declare function calculate($events){
2from $event in $events
3from $sponsor in $event.sponsoring_sigs
4with $es := { "event": $event, "sponsor": $sponsor }
5group by $sig_name := $sponsor.sig_name with $es
6with $sig_sponsorship_count := count($es)
7with $by_chapter :=
8 from $e in $es
9 group by $chapter_name := $e.sponsor.chapter_name with $es
10 select { "chapter_name": $chapter_name, "escount" : count($es) }
11order by $sig_sponsorship_count desc
12limit 5
13select { "sig_name": $sig_name, "total_count": $sig_sponsorship_count, "chapter_breakdown": $by_chapter }
14}
15
16with $result := calculate(dataset('Events'))
17select $result