コード例 #1
0
ファイル: Buscador.php プロジェクト: tresemece/monte
 public function __construct()
 {
     parent::__construct();
     $this->titulo = 'Noticias del Peru y del Mundo ,Ollanta Humala,Nadine Heredia,Perumin,Caso Oropeza,Humberto Martínez Morosini,Aylan Kurdi,Donald Trump  | RPP NOTICIAS';
     $this->epl_sec = 'Buscador';
     $SearchPatternBuilder = new SearchPatternBuilder(new \Rpp\Repositorio\Builder\Search\Pattern\Buscador());
     $request = new \Phalcon\Http\Request();
     $this->search_text = urlencode($request->getPost("texto"));
     if (!empty($_GET['q'])) {
         $this->search_text = urlencode($_GET['q']);
     }
     if (empty($this->search_text)) {
         $this->response = null;
     } else {
         $Pattern = $SearchPatternBuilder->addFilter(array('text' => $this->search_text))->build();
         $this->response = json_decode($Pattern->load())->response;
     }
     $this->description = 'RPP Noticias tiene las últimas noticias sobre política, futbol y farándula nacional e internacional. Ediciones regionales y de todo el Peru';
     $this->keywords = 'rppnoticias, noticias del peru y el mundo ,Ollanta Humala,Nadine Heredia,Perumin,Caso Oropeza,Humberto Martínez Morosini,Aylan Kurdi,Donald Trump';
     $this->titulo_social = 'RPP Noticias tiene las últimas noticias sobre política, futbol y farándula nacional e internacional. Ediciones regionales y de todo el Peru';
     $this->img_social = 'http://s.rpp-noticias.io/images/imgshare.jpg';
     $this->url_social = '';
     \Rpp\Services\Get\UrlTrack::$ns_mchannel = 'portada.buscador';
     $this->comscore = 'buscador.' . $this->search_text;
     $this->slug = 'buscar';
 }
コード例 #2
0
 public function urlAction()
 {
     $nid = $this->request->getPost("nid");
     try {
         $this->view->disable();
         $url = false;
         $SearchPatternBuilder = new SearchPatternBuilder(new \Rpp\Repositorio\Builder\Search\Pattern\Nota());
         $Pattern = $SearchPatternBuilder->addFields(array('categoria', 'slug'))->addFilter(array('_id' => (int) $nid, 'estado' => array('$in' => array('publicado', 'despublicado', 'eliminado', 'borrador', 'editado'))))->build();
         $nota = @$Pattern->load();
         $categoria = $nota->categoria;
         if (is_array($categoria)) {
             $categoria = explode("/", $categoria['slug']);
             $url = $this->view->host . "/" . @$categoria[1] . "/" . @$categoria[2] . "/" . $nota->slug . "-noticia-" . $nid;
         }
     } catch (Exception $e) {
         echo $e->getMessage();
     }
     echo json_encode(array('url' => $url));
 }
コード例 #3
0
ファイル: SugeridosTask.php プロジェクト: tresemece/monte
 public function make($user)
 {
     Cache::request()->save('analitica.sugerido.rebuild' . $user, true, Cache::get_conf()->cache_time->analitica_user_recomendados_rebuild);
     $intervalos_timeline = array(12, 24, 36, 48, 60);
     $nids_view = array();
     $tag_rank_timeline = array();
     $nids_by_tag = array();
     $nids_sugeridos_by_tag = array();
     foreach ($intervalos_timeline as $intervalo) {
         $now = $intervalo - 12;
         $notas_muestra = $this->redis->zRangeByScore(user_notas . $user, strtotime("-{$intervalo} hours"), strtotime("-{$now} hours"), array('limit' => array(0, 20)));
         $notas_muestra = array_reverse($notas_muestra);
         foreach ($notas_muestra as $time_nid) {
             $time_nid = explode(":", $time_nid);
             $nids_view[$time_nid[0]] = $time_nid[0];
             $mtags = \Rpp\Services\Get\Content::part($time_nid[0], 'tags');
             if (is_array($mtags)) {
                 foreach ($mtags as $tag) {
                     if (isset($tag_rank_timeline[$tag['slug']])) {
                         $tag_rank_timeline[$tag['slug']]++;
                     } else {
                         $tag_rank_timeline[$tag['slug']] = 1;
                     }
                 }
             }
         }
     }
     arsort($tag_rank_timeline);
     $tag_rank_timeline = array_slice($tag_rank_timeline, 0, 15);
     $notas_by_tops = $this->redis->zRevRangeByScore('notas:views', 10000000, 0, array('withscores' => TRUE, 'limit' => array(0, 60)));
     $notas_by_tops = array_reverse(array_keys($notas_by_tops));
     $notas_by_tops = array_combine($notas_by_tops, $notas_by_tops);
     $notas_by_tops = array_diff($notas_by_tops, $nids_view);
     $SearchPatternBuilder = new SearchPatternBuilder(new \Rpp\Repositorio\Builder\Search\Pattern\Tag());
     foreach ($tag_rank_timeline as $slug => $score) {
         $Pattern = $SearchPatternBuilder->addFields(array("_id"))->addFilter(array("tags.slug" => $slug))->addLimit(30)->build();
         $result = $Pattern->load();
         foreach ($result as $node) {
             $nids_by_tag[$slug][$node->_id] = $node->_id;
         }
         $nids_by_tag[$slug] = array_diff($nids_by_tag[$slug], $nids_view);
     }
     foreach ($nids_by_tag as $slug => $list) {
         $nids_sugeridos_by_tag[$slug] = array_intersect($list, $notas_by_tops);
     }
     $nids_by_secciones = array();
     $menu = new \Phalcon\Config\Adapter\Ini(CONFIG_PATH . DIRS . "ini/menu.ini");
     $secciones = explode(",", $menu->secciones->slug);
     $Pattern = $SearchPatternBuilder->reset(new \Rpp\Repositorio\Builder\Search\Pattern\Seccion());
     foreach ($secciones as $seccion) {
         $Pattern = $SearchPatternBuilder->addFields(array("_id"))->addSlug($seccion)->addLimit(20)->build();
         $result = $Pattern->load();
         foreach ($result as $node) {
             $nids_by_secciones[$seccion][$node->_id] = $node->_id;
         }
         $nids_by_secciones[$seccion] = array_diff($nids_by_secciones[$seccion], $nids_view);
     }
     $nids_sugeridos_by_secciones = array();
     foreach ($nids_by_secciones as $seccion => $list) {
         $nids_sugeridos_by_secciones[$seccion] = array_intersect($list, $notas_by_tops);
     }
     /*----guardando tags------*/
     foreach ($nids_sugeridos_by_tag as $tag => $list) {
         var_dump($tag);
         Cache::request()->save('analitica.sugeridos.tag.' . $tag . '-' . $user, $list, Cache::get_conf()->cache_time->analitica_user_sugeridos);
         var_dump(Cache::request()->get('analitica.sugeridos.tag.' . $tag . '-' . $user));
     }
     foreach ($nids_sugeridos_by_secciones as $seccion => $list) {
         Cache::request()->save('analitica.sugeridos.seccion.' . $seccion . '-' . $user, $list, Cache::get_conf()->cache_time->analitica_user_sugeridos);
         var_dump(Cache::request()->get('analitica.sugeridos.seccion.' . $seccion . '-' . $user));
     }
 }
コード例 #4
0
ファイル: Tag.php プロジェクト: tresemece/monte
 public function get_info($slug)
 {
     $Builder = new SearchPatternBuilder(new \Rpp\Repositorio\Builder\Search\Pattern\Tags());
     $Pattern = $Builder->build();
     return $Pattern->set_slug($slug)->load();
 }
コード例 #5
0
ファイル: RecomendadosTask.php プロジェクト: tresemece/monte
 public function make($user)
 {
     Cache::request()->save('analitica.recomendadas.rebuild' . $user, true, Cache::get_conf()->cache_time->analitica_user_recomendados_rebuild);
     $intervalos_timeline = array(12, 24, 36, 48, 60, 72, 84, 96, 108, 120);
     /*intervalos de timeline*/
     $hot_minimo_numero = 2;
     $nids_view = array();
     $nids_suggested = array();
     $secciones_rank_timeline = array();
     $tag_rank_timeline = array();
     foreach ($intervalos_timeline as $intervalo) {
         $now = $intervalo - 12;
         $notas_muestra = $this->redis->zRangeByScore(user_notas . $user, strtotime("-{$intervalo} hours"), strtotime("-{$now} hours"), array('limit' => array(0, 20)));
         $notas_muestra = array_reverse($notas_muestra);
         foreach ($notas_muestra as $time_nid) {
             $time_nid = explode(":", $time_nid);
             //var_dump("[", date("Y:m:d G:i:s",$time_nid[1]) , " ]");
             $nids_view[$time_nid[0]] = $time_nid[0];
             $mtags = \Rpp\Services\Get\Content::part($time_nid[0], 'tags');
             if (is_array($mtags)) {
                 foreach ($mtags as $tag) {
                     if (isset($tag_rank_timeline[$tag['slug']])) {
                         $tag_rank_timeline[$tag['slug']]++;
                     } else {
                         $tag_rank_timeline[$tag['slug']] = 1;
                     }
                 }
             }
             $categoria = \Rpp\Services\Get\Content::part($time_nid[0], 'categoria')['slug'];
             if (isset($secciones_rank_timeline[$categoria])) {
                 $secciones_rank_timeline[$categoria]++;
             } else {
                 $secciones_rank_timeline[$categoria] = 1;
             }
         }
     }
     arsort($tag_rank_timeline);
     arsort($secciones_rank_timeline);
     $portadas_view_rank = array();
     foreach ($intervalos_timeline as $intervalo) {
         $now = $intervalo - 12;
         $portadas_view = $this->redis->zRangeByScore(user_portadas . $user, strtotime("-{$intervalo} hours"), strtotime("-{$now} hours"), array('limit' => array(0, 20)));
         foreach ($portadas_view as $portada) {
             $time_portada = explode(":", $portada);
             if (isset($portadas_view_rank[$time_portada[0]])) {
                 $portadas_view_rank[$time_portada[0]]++;
             } else {
                 $portadas_view_rank[$time_portada[0]] = 1;
             }
         }
     }
     arsort($portadas_view_rank);
     $nids_portada_top = array();
     /*nids de la portada hot*/
     if (count($portadas_view_rank) > 0) {
         foreach ($portadas_view_rank as $portada => $rank) {
             if ($rank >= $hot_minimo_numero) {
                 $portada = str_replace(".", "/", $portada);
                 foreach (\Rpp\Services\Get\Flow::seccion($portada, 30) as $node) {
                     $nids_portada_top[$node->_id] = $node->_id;
                 }
                 break;
             } else {
                 break;
             }
         }
     }
     /*var_dump("<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>");
              $ultimas_temas = $this->redis->zRevRange(user_temas.$user, 0,50, true);  
     
              foreach ($ultimas_temas as $tema => $time) {
              	$tema = explode(":", $tema);
              	var_dump("[",date("Y:m:d h:i:s",$time)," => ", $tema[0] , " ]");
              }
     
              var_dump("<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>");
              $ultimas_search = $this->redis->zRevRange(user_search.$user, 0,50, true);
              foreach ($ultimas_search as $search => $time) {
              	var_dump("[",date("Y:m:d h:i:s",$time)," => ", $search , " ]");
              }*/
     $nids_suggested[1] = array();
     $nids_suggested[2] = array();
     $nids_suggested[3] = array();
     $tags_top = array_slice($tag_rank_timeline, 0, 3);
     $secciones_top = array_slice($secciones_rank_timeline, 0, 3);
     if (count($tags_top) > 0) {
         $tags_slug = array_keys($tags_top);
         $SearchPatternBuilder = new SearchPatternBuilder(new \Rpp\Repositorio\Builder\Search\Pattern\Tag());
         $Pattern = $SearchPatternBuilder->addFields(array("_id"))->addFilter(array("tags.slug" => $tags_slug[0]))->addLimit(20)->build();
         $result = $Pattern->load();
         foreach ($result as $suggested) {
             $nids_suggested[1][$suggested->_id] = $suggested->_id;
         }
         $Pattern = $SearchPatternBuilder->addFilter(array("tags.slug" => array('$in' => $tags_slug)))->build();
         $result = $Pattern->load();
         foreach ($result as $suggested) {
             $nids_suggested[3][$suggested->_id] = $suggested->_id;
         }
         array_pop($tags_top);
         if (count($tags_top) > 0) {
             $tags_slug = array_keys($tags_top);
             $Pattern = $SearchPatternBuilder->addFilter(array("tags.slug" => $tags_slug[0]))->build();
             $result = $Pattern->load();
             foreach ($result as $suggested) {
                 $nids_suggested[1][$suggested->_id] = $suggested->_id;
             }
             $Pattern = $SearchPatternBuilder->addFilter(array("tags.slug" => array('$in' => $tags_slug)))->build();
             $result = $Pattern->load();
             foreach ($result as $suggested) {
                 $nids_suggested[2][$suggested->_id] = $suggested->_id;
             }
         }
     }
     $add = 20;
     $top_rangos = array(3 => 20, 2 => 40, 1 => 60);
     $notas_by_tops = array();
     $sugeridas_news_calculate[3] = array();
     $sugeridas_news_calculate[2] = array();
     $sugeridas_news_calculate[1] = array();
     foreach ($top_rangos as $id => $rango) {
         $notas_by_tops[$id] = $this->redis->zRevRangeByScore(SITESLUG . ':notas:views', 10000000, 0, array('withscores' => TRUE, 'limit' => array($rango - $add, $rango)));
         $notas_by_tops[$id] = array_reverse(array_keys($notas_by_tops[$id]));
         $notas_by_tops[$id] = array_combine($notas_by_tops[$id], $notas_by_tops[$id]);
     }
     foreach ($notas_by_tops as $id => $top) {
         $notas_by_tops[$id] = array_diff($top, $nids_view);
     }
     foreach ($nids_suggested as $id => $suggested) {
         $nids_suggested[$id] = array_diff($suggested, $nids_view);
     }
     $nids_portada_top = array_diff($nids_portada_top, $nids_view);
     $sugeridas_portadas_calculate = array();
     $levels = array(3, 2, 1);
     foreach ($levels as $lsuge) {
         $sugeridas_news_calculate['level'][$lsuge] = array();
         foreach ($levels as $ltops) {
             $sugeridas_news_calculate['level'][$lsuge] = $sugeridas_news_calculate['level'][$lsuge] + array_intersect($nids_suggested[$lsuge], $notas_by_tops[$ltops]);
         }
     }
     foreach ($levels as $ltops) {
         $sugeridas_portadas_calculate = $sugeridas_portadas_calculate + array_intersect($nids_portada_top, $notas_by_tops[$ltops]);
     }
     $nids_sugeridos = array();
     $nids_sugeridos = array_slice($sugeridas_news_calculate['level'][3], 0, 3, true) + array_slice($sugeridas_portadas_calculate, 0, 2, true) + array_slice($sugeridas_news_calculate['level'][3], 3, 6, true) + array_slice($sugeridas_portadas_calculate, 2, 2, true) + array_slice($sugeridas_news_calculate['level'][3], 6, 20, true) + array_slice($sugeridas_news_calculate['level'][2], 0, 3, true) + array_slice($sugeridas_portadas_calculate, 4, 8, true) + array_slice($sugeridas_news_calculate['level'][2], 3, true) + $sugeridas_news_calculate['level'][1];
     $nids_sugeridos = array_slice($nids_sugeridos, 0, 15, true);
     Cache::request()->save('analitica.recomendadas.' . $user, $nids_sugeridos, Cache::get_conf()->cache_time->analitica_user_recomendados);
     $this->viewCache->delete('sidebar.recomendados.' . $user);
     var_dump(Cache::request()->get('analitica.recomendadas.' . $user));
 }