00001 <?php
00002
00006 abstract class SDRServiceStats extends SObject {
00007
00017 public static function countCatalogItems($type = null, $passedConstraints = array()) {
00018 $constraints = array();
00019 $from = 'SDRResource';
00020 switch($type) {
00021 case 'live':
00022 $constraints = array('releaseFlag' => 1);
00023 break;
00024 case 'pending':
00025 $from = 'view_numpendingversions';
00026 break;
00027 case 'dev':
00028 $from = 'view_numdevversions';
00029 break;
00030 case 'approved':
00031 $from = 'view_numliveversions';
00032 break;
00033 case 'fields':
00034 $from = 'SDRField';
00035 break;
00036 case 'values':
00037 $from = 'SDRValue';
00038 break;
00039 case 'cachedValues':
00040 $from = 'SDRValueCache';
00041 break;
00042 case 'cachedResources':
00043 $from = 'SDRResourceCache';
00044 break;
00045 case 'cachedSearchTerms':
00046 $from = 'SDRSearchWord';
00047 break;
00048 default:
00049 if(count($passedConstraints))
00050 $constraints = array_merge($constraints, $passedConstraints);
00051 break;
00052 }
00053 $DBI = SDRService::getDBI();
00054 $result = $DBI->select($from, DBI2::NUM_RESULTS, $constraints);
00055 return $result;
00056 }
00057
00065 public static function projectsAndResourceCounts() {
00066 $from = 'view_sdrresourcesperproject';
00067 $constraints = array();
00068 $DBI = SDRService::getDBI();
00069 $result = $DBI->select($from, array('id', 'name', 'count'), $constraints);
00070 $output = array();
00071 foreach($result as $r) {
00072 $output[$r['id']] = array('name' => $r['name'], 'count' => $r['count']);
00073 }
00074 return $output;
00075 }
00076 }
00077 ?>