From 774e0b3737d51b70bb141f4e13c6c111208847c0 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 20 May 2009 06:10:14 +0000 Subject: Avoid complex inserts in available_tasks() to make admin/maintenance run faster. This fixes ticket #235. Incidentally, refactor exif and search to use the same patterns overall so that if you understand one, you understand the other and they generally use the same strings for localization. --- modules/exif/helpers/exif.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'modules/exif/helpers/exif.php') diff --git a/modules/exif/helpers/exif.php b/modules/exif/helpers/exif.php index ab5dff71..c488bbd4 100644 --- a/modules/exif/helpers/exif.php +++ b/modules/exif/helpers/exif.php @@ -133,4 +133,35 @@ class exif_Core { } return self::$exif_keys; } + + static function stats() { + $missing_exif = Database::instance() + ->select("items.id") + ->from("items") + ->join("exif_records", "items.id", "exif_records.item_id", "left") + ->where("type", "photo") + ->open_paren() + ->where("exif_records.item_id", null) + ->orwhere("exif_records.dirty", 1) + ->close_paren() + ->get() + ->count(); + + $total_items = ORM::factory("item")->where("type", "photo")->count_all(); + if (!$total_items) { + return array(0, 0, 0); + } + return array($missing_exif, $total_items, + round(100 * (($total_items - $missing_exif) / $total_items))); + } + + static function check_index() { + list ($remaining) = exif::stats(); + if ($remaining) { + site_status::warning( + t('Your EXIF index needs to be updated. Fix this now', + array("url" => url::site("admin/maintenance/start/exif_task::update_index?csrf=__CSRF__"))), + "exif_index_out_of_date"); + } + } } -- cgit v1.2.3