Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix uses of count_records() and use ORM to count instead.

  • Loading branch information...
commit c50c2d135c5e769e8904e5dc766d27bcd4a1d8b3 1 parent 73aeed8
Bharat Mediratta authored December 25, 2009
12  modules/server_add/controllers/server_add.php
@@ -175,15 +175,15 @@ static function add($task) {
175 175
       // over 10% in percent_complete.
176 176
       $task->set("queue", $queue);
177 177
       $task->percent_complete = min($task->percent_complete + 0.1, 10);
178  
-      $task->status = t2("Found one file", "Found %count files",
179  
-                         db::build()->count_records(
180  
-                           "server_add_files", array("task_id" => $task->id)));
  178
+      $task->status = t2(
  179
+        "Found one file", "Found %count files",
  180
+        ORM::factory("server_add_file")->where("task_id", "=", $task->id)->count_all());
181 181
 
182 182
       if (!$queue) {
183 183
         $task->set("mode", "add-files");
184 184
         $task->set(
185  
-          "total_files", db::build()->count_records(
186  
-            "server_add_files", array("task_id" => $task->id)));
  185
+          "total_files",
  186
+          ORM::factory("server_add_file")->where("task_id", "=", $task->id)->count_all());
187 187
         $task->percent_complete = 10;
188 188
       }
189 189
       break;
@@ -256,7 +256,7 @@ static function add($task) {
256 256
       $task->status = t("Adding photos / albums (%completed of %total)",
257 257
                         array("completed" => $completed_files,
258 258
                               "total" => $total_files));
259  
-      $task->percent_complete = 10 + 100 * ($completed_files / $total_files);
  259
+      $task->percent_complete = $total_files ? 10 + 100 * ($completed_files / $total_files) : 100;
260 260
       break;
261 261
 
262 262
     case "done":

0 notes on commit c50c2d1

Please sign in to comment.
Something went wrong with that request. Please try again.