Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # map / reduce
- mapFunc = () ->
- days= ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
- now = new Date().valueOf()
- key = "#{this.ts.getFullYear()}-#{this.ts.getMonth()+1}-#{this.ts.getDate()}"
- for i in [-9..0]
- date = new Date(now + i*86400000)
- formatted = "#{date.getFullYear()}-#{date.getMonth()+1}-#{date.getDate()}"
- if formatted is key then emit(formatted, {count: 1, day: days[date.getDay()]})
- else emit(formatted, {count: 0, day: days[date.getDay()]})
- reduceFunc = (key, values) ->
- total = 0
- for value in values
- total += value.count
- day = value.day
- return { count: total, day: day }
- # query
- query = {to:channel}
- params = { out: {inline:1}, query: query, sort: {ts:-1} }
Add Comment
Please, Sign In to add comment