Merge branch 'cc-5709-airtime-analyzer' of github.com:sourcefabric/Airtime into cc-5709-airtime-analyzer

This commit is contained in:
Albert Santoni 2014-04-23 14:18:08 -04:00
commit f98dabcc02
1 changed files with 25 additions and 28 deletions

View File

@ -34,56 +34,53 @@ class PluploadController extends Zend_Controller_Action
public function recentUploadsAction() public function recentUploadsAction()
{ {
if (isset($_GET['uploadFilter'])) { $request = $this->getRequest();
$filter = $_GET['uploadFilter'];
} else { $filter = $request->getParam('uploadFilter', "all");
$filter = "all"; $limit = intval($request->getParam('iDisplayLength', 10));
} $rowStart = intval($request->getParam('iDisplayStart', 0));
$limit = isset($_GET['iDisplayLength']) ? $_GET['iDisplayLength'] : 10; $recentUploadsQuery = CcFilesQuery::create();
$rowStart = isset($_GET['iDisplayStart']) ? $_GET['iDisplayStart'] : 0; //old propel 1.5 to reuse this query item (for counts/finds)
$recentUploadsQuery->keepQuery(true);
$recentUploadsQuery = CcFilesQuery::create()->filterByDbUtime(array('min' => time() - 30 * 24 * 60 * 60)) $numTotalRecentUploads = $recentUploadsQuery->count();
->orderByDbUtime(Criteria::DESC); $numTotalDisplayUploads = $numTotalRecentUploads;
$numTotalRecentUploads = $recentUploadsQuery->find()->count();
if ($filter == "pending") { if ($filter == "pending") {
$recentUploadsQuery->filterByDbImportStatus(1); $recentUploadsQuery->filterByDbImportStatus(1);
$numTotalDisplayUploads = $recentUploadsQuery->count();
} else if ($filter == "failed") { } else if ($filter == "failed") {
$recentUploadsQuery->filterByDbImportStatus(2); $recentUploadsQuery->filterByDbImportStatus(2);
$numTotalDisplayUploads = $recentUploadsQuery->count();
//TODO: Consider using array('min' => 200)) or something if we have multiple errors codes for failure. //TODO: Consider using array('min' => 200)) or something if we have multiple errors codes for failure.
} }
$recentUploads = $recentUploadsQuery->offset($rowStart)->limit($limit)->find(); $recentUploads = $recentUploadsQuery
->orderByDbUtime(Criteria::DESC)
$numRecentUploads = $limit; ->offset($rowStart)
//CcFilesQuery::create()->filterByDbUtime(array('min' => time() - 30 * 24 * 60 * 60)) ->limit($limit)
->find();
//$this->_helper->json->sendJson(array("jsonrpc" => "2.0", "tempfilepath" => $tempFileName));
$uploadsArray = array(); $uploadsArray = array();
$utcTimezone = new DateTimeZone("UTC");
$displayTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
foreach ($recentUploads as $upload) foreach ($recentUploads as $upload)
{ {
$upload = $upload->toArray(BasePeer::TYPE_FIELDNAME); $upload = $upload->toArray(BasePeer::TYPE_FIELDNAME);
//TODO: $this->sanitizeResponse($upload)); //TODO: $this->sanitizeResponse($upload));
$utcTimezone = new DateTimeZone("UTC");
$displayTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
$upload['utime'] = new DateTime($upload['utime'], $utcTimezone); $upload['utime'] = new DateTime($upload['utime'], $utcTimezone);
$upload['utime']->setTimeZone($displayTimezone); $upload['utime']->setTimeZone($displayTimezone);
$upload['utime'] = $upload['utime']->format('Y-m-d H:i:s'); $upload['utime'] = $upload['utime']->format('Y-m-d H:i:s');
//$this->_helper->json->sendJson($upload->asJson());
//TODO: Invoke sanitization here //TODO: Invoke sanitization here
array_push($uploadsArray, $upload); array_push($uploadsArray, $upload);
} }
$this->view->sEcho = intval($request->getParam('sEcho'));
$this->view->sEcho = intval($this->getRequest()->getParam('sEcho')); $this->view->iTotalDisplayRecords = $numTotalDisplayUploads;
$this->view->iTotalDisplayRecords = $numTotalRecentUploads; $this->view->iTotalRecords = $numTotalRecentUploads;
//$this->view->iTotalDisplayRecords = $numRecentUploads; //$r["iTotalDisplayRecords"]; $this->view->files = $uploadsArray;
$this->view->iTotalRecords = $numTotalRecentUploads; //$r["iTotalRecords"];
$this->view->files = $uploadsArray; //$r["aaData"];
} }
} }