blob: c9e92310abc1351c3c168e807ad3b612685b0720 [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 }
buyingyi3ca46d02015-01-27 23:22:09 -08005group by $sig_name := $sponsor.sig_name keeping $es
buyingyi2fd7fa62014-11-24 19:31:55 -08006with $sig_sponsorship_count := count($es)
7with $by_chapter :=
8 from $e in $es
buyingyi3ca46d02015-01-27 23:22:09 -08009 group by $chapter_name := $e.sponsor.chapter_name keeping $es
buyingyi2fd7fa62014-11-24 19:31:55 -080010 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