(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: largest_pages.ml,v 1.4 2006/03/27 18:09:46 rich Exp $
+ * $Id: largest_pages.ml,v 1.5 2006/03/28 13:20:00 rich Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* approximation of the final size of the page. Also, we are not taking
* into account images.
*)
- let sth =
- dbh#prepare_cached
+ let rows =
+ PGSQL(dbh)
"select p.id, p.url, p.title, sum (length (c.content))
from pages p, contents c
- where p.hostid = ? and p.url is not null and p.redirect is null
+ where p.hostid = $hostid and p.url is not null and p.redirect is null
and c.pageid = p.id group by 1, 2, 3 order by 4 desc" in
- sth#execute [Some hostid];
let table =
- sth#map
- (function [Some pageid; Some page; Some title; Some size] ->
+ List.map
+ (function [pageid; page; title; Some size] ->
+ let size = Int32.to_int size in
let download_time = overhead + size / modem_speed in (* seconds *)
let download_time =
if download_time <= 4 then "<= 4 s"
"title", Template.VarString title;
"size", Template.VarString size;
"download_time", Template.VarString download_time ]
- | _ -> assert false) in
+ | _ -> assert false) in
template#table "pages" table;
q#template template