public static function getTopBands($number_of_results = self::NUMBER_OF_TOP_TO_DISPLAY, $rand = true)
 {
     if (self::$s_top_list_cache == NULL) {
         self::$s_top_list_cache = new myCache("topList", self::TOP_LIST_EXPIRY_IN_SECONDS);
     }
     $top_list_name = "kshowBands";
     //get_class( $cls );
     $top_list_full = self::$s_top_list_cache->get($top_list_name);
     if ($top_list_full == NULL) {
         $featuredIds = array(26404, 42551, 31401, 31554, 12913, 18309, 13411, 11931, 15789, 13948, 13380, 13929, 21944, 23057);
         //$top_list_full = kshowPeer::retrieveByPks($featuredIds);
         $c = new Criteria();
         $c->add(kshowPeer::ID, $featuredIds, Criteria::IN);
         $top_list_full = kshowPeer::doSelectJoinkuser($c);
         self::$s_top_list_cache->put($top_list_name, $top_list_full);
     }
     //if ( $number_of_results < 1 ) $number_of_results = self::NUMBER_OF_TOP_TO_DISPLAY;
     if ($rand) {
         // shuffle the array and return the first  $number_of_results
         if (is_array($top_list_full)) {
             shuffle($top_list_full);
         }
     }
     if (count($top_list_full) > $number_of_results) {
         $top_list_full = array_slice($top_list_full, 0, $number_of_results);
     }
     return $top_list_full;
 }
Example #2
0
 /**
 	 * 
 select kshow.id,concat('http://www.kaltura.com/index.php/browse/bands?band_id=',indexed_custom_data_1),concat('http://profile.myspace.com/index.cfm?fuseaction=user.viewpr
 ofile&friendID=',indexed_custom_data_1) ,  kuser.screen_name , indexed_custom_data_1  from kshow ,kuser where kshow.partner_id=5 AND kuser.id=kshow.producer_id AND kshow.
 id>=10815  order by kshow.id ;
 ~
 */
 public function execute()
 {
     //	$this->forceSystemAuthentication();
     $from = $this->getRequestParameter("from", null);
     $to = $this->getRequestParameter("to", null);
     $limit = $this->getRequestParameter("limit", 100);
     $c = new Criteria();
     $c->setLimit($limit);
     $c->add(kshowPeer::PARTNER_ID, 5);
     // myspace
     $c->addAscendingOrderByColumn(kshowPeer::ID);
     if (!empty($from)) {
         $c->addAnd(kshowPeer::ID, $from, Criteria::GREATER_EQUAL);
     }
     if (!empty($to)) {
         $c->addAnd(kshowPeer::ID, $to, Criteria::LESS_EQUAL);
     }
     $this->band_list = kshowPeer::doSelectJoinkuser($c);
 }
 private static function getCachedKshowList($config_param_name, $fallback = NULL)
 {
     return array();
     self::init();
     // becuase the $config_param_name is unique in the config - use it in the cache too
     $cached_show_list = self::$s_cache->get($config_param_name);
     if ($cached_show_list == NULL) {
         // read the ids from config
         $id_list = self::$s_config->getList($config_param_name);
         if ($id_list == NULL && !$fallback) {
             $id_list = self::$s_config->getList($fallback);
         }
         if ($id_list == NULL) {
             throw new Exception("Cannot find featured list in app.yml (key=" . $config_param_name . ")");
         }
         $c = new Criteria();
         $c->add(kshowPeer::ID, $id_list, Criteria::IN);
         // fetch the real kshows from the DB
         $kshow_list = kshowPeer::doSelectJoinkuser($c);
         // create stub objects with only the minimum data from the real kshow
         $cached_show_list = array();
         $temp_array = array();
         // the order is not the one we had in the $id_list - it's sorted by the DB
         foreach ($kshow_list as $kshow) {
             $temp_array[$kshow->getId()] = new kshowStub($kshow);
         }
         $i = 0;
         foreach ($id_list as $id) {
             if (key_exists($id, $temp_array)) {
                 $cached_show_list[$i] = $temp_array[$id];
                 ++$i;
             }
         }
         // store the stub list in the cache for next time
         self::$s_cache->put($config_param_name, $cached_show_list);
     }
     return $cached_show_list;
 }
 /**
  * Gives a system applicative snapsot
  */
 public function execute()
 {
     myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3;
     $this->forceSystemAuthentication();
     $partner_id = $this->getRequestParameter('partner_id', -1);
     if ($partner_id >= 0) {
         myPartnerUtils::applyPartnerFilters($partner_id);
     }
     $this->partner_id = $partner_id;
     $limit = $this->getRequestParameter('limit', '30');
     if ($limit > 300) {
         $limit = 300;
     }
     $bands_only = $this->getRequestParameter("bands", false) != null;
     $modified_only = $this->getRequestParameter("modified", false) != null;
     $this->bands_only = $bands_only;
     $this->modified_only = $modified_only;
     $this->kshows_with_new_entries = $modified_only ? dashboardUtils::getUpdatedKshows() : null;
     $yesterday = mktime(0, 0, 0, date("m"), date("d") - 1, date("Y"));
     $lastweek = mktime(0, 0, 0, date("m"), date("d") - 7, date("Y"));
     $query_esterday = date('Y-m-d', $yesterday);
     $query_lastweek = date('Y-m-d', $lastweek);
     $modified_band_ids = $modified_only ? array_keys($this->kshows_with_new_entries) : null;
     if ($modified_only) {
         // TODO - this chunk was copied from the code bellow with minor changes - generalize !
         $c = new Criteria();
         // 			$c->add ( kshowPeer::ID , $modified_band_ids , Criteria::IN ); // search only the given IDs
         $this->bandsOnly($bands_only, $modified_band_ids, $c, kshowPeer::PARTNER_ID);
         $this->kshow_count = kshowPeer::doCount($c);
         $criterion = $c->getNewCriterion(kshowPeer::CREATED_AT, $query_esterday, Criteria::GREATER_EQUAL);
         $c->add($criterion);
         $this->kshow_count1 = kshowPeer::doCount($c);
         $criterion = $c->getNewCriterion(kshowPeer::CREATED_AT, $query_lastweek, Criteria::GREATER_EQUAL);
         $c->add($criterion);
         $this->kshow_count7 = kshowPeer::doCount($c);
         $c->setLimit($limit);
         //$c->hints = array(kshowPeer::TABLE_NAME => "created_at_index");
         $c->addDescendingOrderByColumn(kshowPeer::CREATED_AT);
         $c->remove(kshowPeer::CREATED_AT);
         $c->addJoin(kshowPeer::PRODUCER_ID, kuserPeer::ID, Criteria::LEFT_JOIN);
         $this->kshows = kshowPeer::doSelectJoinkuser($c);
         $this->bands_only = $bands_only;
         $this->entry_count = 0;
         $this->entry_count1 = 0;
         $this->entry_count7 = 0;
         $this->entries = array();
         $this->kuser_count = 0;
         $this->kuser_count1 = 0;
         $this->kuser_count7 = 0;
         $this->kusers = array();
         dashboardUtils::updateKshowsRoughcutCount($this->kshows);
         return sfView::SUCCESS;
     }
     $c = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $c, kshowPeer::PARTNER_ID);
     $this->kshow_count = kshowPeer::doCount($c);
     $d = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $d, kshowPeer::PARTNER_ID);
     $criterion = $c->getNewCriterion(kshowPeer::CREATED_AT, $query_esterday, Criteria::GREATER_EQUAL);
     $d->add($criterion);
     $this->kshow_count1 = kshowPeer::doCount($d);
     $e = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $e, kshowPeer::PARTNER_ID);
     $criterion = $c->getNewCriterion(kshowPeer::CREATED_AT, $query_lastweek, Criteria::GREATER_EQUAL);
     $e->add($criterion);
     $this->kshow_count7 = kshowPeer::doCount($e);
     //$this->kshow_count = kshowPeer::doCount( $c );
     $c->setLimit($limit);
     //$c->hints = array(kshowPeer::TABLE_NAME => "created_at_index");
     $c->addDescendingOrderByColumn(kshowPeer::CREATED_AT);
     $c->addJoin(kshowPeer::PRODUCER_ID, kuserPeer::ID, Criteria::LEFT_JOIN);
     $this->kshows = kshowPeer::doSelectJoinkuser($c);
     $c = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $c, entryPeer::PARTNER_ID);
     $this->entry_count = entryPeer::doCount($c);
     $d = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $d, entryPeer::PARTNER_ID);
     $criterion = $c->getNewCriterion(entryPeer::CREATED_AT, $query_esterday, Criteria::GREATER_EQUAL);
     $d->add($criterion);
     $this->entry_count1 = entryPeer::doCount($d);
     $e = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $e, entryPeer::PARTNER_ID);
     $criterion = $c->getNewCriterion(entryPeer::CREATED_AT, $query_lastweek, Criteria::GREATER_EQUAL);
     $e->add($criterion);
     $this->entry_count7 = entryPeer::doCount($e);
     $c->setLimit($limit);
     //$c->hints = array(entryPeer::TABLE_NAME => "created_at_index");
     $c->addDescendingOrderByColumn(entryPeer::CREATED_AT);
     $c->add(entryPeer::TYPE, entryType::MEDIA_CLIP);
     // we don't want entries that
     //		$c->addJoin(entryPeer::KUSER_ID, kuserPeer::ID, Criteria::INNER_JOIN);
     //	    $c->addJoin(entryPeer::KSHOW_ID, kshowPeer::ID, Criteria::INNER_JOIN);
     $this->entries = entryPeer::doSelectJoinAll($c);
     $c = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $c, kuserPeer::PARTNER_ID);
     $d = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $d, kuserPeer::PARTNER_ID);
     $criterion = $c->getNewCriterion(kuserPeer::CREATED_AT, $query_esterday, Criteria::GREATER_EQUAL);
     $d->add($criterion);
     $this->kuser_count1 = kuserPeer::doCount($d);
     $e = new Criteria();
     $this->bandsOnly($bands_only, $modified_band_ids, $e, kuserPeer::PARTNER_ID);
     $criterion = $c->getNewCriterion(kuserPeer::CREATED_AT, $query_lastweek, Criteria::GREATER_EQUAL);
     $e->add($criterion);
     $this->kuser_count7 = kuserPeer::doCount($e);
     $this->kuser_count = kuserPeer::doCount($c);
     $c->setLimit($limit);
     $c->addDescendingOrderByColumn(kuserPeer::CREATED_AT);
     $this->kusers = kuserPeer::doSelect($c);
     dashboardUtils::updateKusersRoughcutCount($this->kusers);
     dashboardUtils::updateKshowsRoughcutCount($this->kshows);
     return sfView::SUCCESS;
 }