Changeset 654bb6066f0a41076097ffd2498c04805e4d7276

Show
Ignore:
Timestamp:
08/26/10 21:50:23 (18 months ago)
Author:
Antti-Juhani Kaijanaho <antti-juhani@…>
Children:
19a2630635324aeed23f74061133ba433a639cd4
Parents:
62c7c77e091368d89d5f9699dd6185177dd37f4b
git-committer:
Antti-Juhani Kaijanaho <antti-juhani@…> (08/26/10 21:50:23)
Message:

[http::article,threads] Fixes for pagination

Signed-off-by: Antti-Juhani Kaijanaho <antti-juhani@…>

Location:
http
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • http/article.cc

    r43f5212 r654bb60  
    115115                        tlate::thread_value::ptr tv 
    116116                                (new tlate::thread_value(tn, u)); 
     117                        size_t tvl = tv->size(); 
    117118                        tv->slice_window(start, length); 
    118119                        am->insert("thread", tv); 
    119120 
    120121                        tlate::data_model::ptr pg(new tlate::data_model); 
    121                         pg->insert("first", start); 
     122                        pg->insert("first", start + 1); 
    122123                        pg->insert("last", start + tv->size()); 
    123124                        pg->insert("size", tv->size()); 
    124125                        pg->insert("max_size", length); 
     126                        pg->insert("total", tvl); 
    125127 
    126                         if (length > tv->size()) 
     128                        if (start + length < tvl) 
    127129                        { 
    128130                                ::uri u = req->get_uri(); 
  • http/threads.cc

    r43f5212 r654bb60  
    110110 
    111111                        size_t cur = 0; 
    112                         bool more = false; 
     112                        size_t total = 0; 
    113113                        for (std::list<db::thread_node::ptr>::const_iterator 
    114114                                     it = thrs.begin(); 
    115115                             it != thrs.end(); it++) 
    116116                        { 
     117                                total++; 
     118                                if (cur >= start + length) continue; 
    117119                                cur++; 
    118                                 if (cur >= start + length) 
    119                                 { 
    120                                         more = true; 
    121                                         break; 
    122                                 } 
    123120                                if (cur > start) 
    124121                                        tl->push_back 
     
    128125 
    129126                        tlate::data_model::ptr pg(new tlate::data_model); 
    130                         pg->insert("first", start); 
    131                         pg->insert("last", cur - 1); 
     127                        pg->insert("first", start + 1); 
     128                        pg->insert("last", cur); 
    132129                        pg->insert("size", cur - start); 
    133130                        pg->insert("max_size", length); 
    134  
    135                         if (more) 
     131                        pg->insert("total", total); 
     132                        if (cur < total) 
    136133                        { 
    137134                                ::uri u = req->get_uri();