diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-05-20 06:10:14 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-05-20 06:10:14 +0000 |
commit | 774e0b3737d51b70bb141f4e13c6c111208847c0 (patch) | |
tree | 8f367c99a16c1d4d3419838aec420a29a320bc3b /modules/exif/helpers/exif.php | |
parent | 54fe2c600e6930c2885f3f6048221710637a142f (diff) |
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.
Diffstat (limited to 'modules/exif/helpers/exif.php')
-rw-r--r-- | modules/exif/helpers/exif.php | 31 |
1 files changed, 31 insertions, 0 deletions
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. <a href="%url" class="gDialogLink">Fix this now</a>', + array("url" => url::site("admin/maintenance/start/exif_task::update_index?csrf=__CSRF__"))), + "exif_index_out_of_date"); + } + } } |