github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

arunthampi / icanhazthread

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 7
    • 2
  • Source
  • Commits
  • Network (2)
  • Issues (1)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Tree: 98575f2

click here to add a description

click here to add a homepage

  • Branches (1)
    • master
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

The CouchApp powering http://i.canhazthread.com — Read more

  cancel

http://i.canhazthread.com

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Add Atom feed for each thread 
arunthampi (author)
Tue Aug 25 00:38:12 -0700 2009
commit  98575f2d370aa9676da7c6022bce7ee0754952ee
tree    4d264ad7aa09f25fef76df99c5f6f0e14e457e39
parent  f7107a5e03e82621efb4a6498a87f3b8ac0a19a3
icanhazthread / views / threads_with_num_replies / reduce.js views/threads_with_num_replies/reduce.js
100644 53 lines (44 sloc) 1.495 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function(keys, values, rereduce) {
  var result = { num_replies: 0, last_reply: 0, text: "", time_created: 0, screen_name: "" };
 
  if(rereduce) {
    for(idx = 0; idx < values.length; idx++) {
      result.num_replies += values[idx].num_replies;
 
      if(values[idx].text != "") {
        result.text = values[idx].text;
      }
    
      if(values[idx].screen_name != "") {
        result.screen_name = values[idx].screen_name;
      }
      
      if(values[idx].time_created != 0) {
        result.time_created = values[idx].time_created;
      }
 
      if(values[idx].last_reply != 0) {
        if(result.last_reply == 0) {
          result.last_reply = values[idx].last_reply;
        } else {
          if(result.last_reply < values[idx].last_reply) {
            result.last_reply = values[idx].last_reply;
          }
        }
      }
    }
  } else {
    
    for(idx = 0; idx < values.length; idx++) {
      if(values[idx].type == 'thread') {
        result.text = values[idx].text;
        result.screen_name = values[idx].screen_name;
        result.time_created = values[idx].time_created;
        
      } else if(values[idx].type == 'reply') {
        result.num_replies += 1;
        
        if(result.last_reply == 0) {
          result.last_reply = values[idx].time_created;
        } else {
          if(result.last_reply < values[idx].time_created) {
            result.last_reply = values[idx].time_created;
          }
        }
      }
    }
  }
  
  return result;
}
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server