public static function findApprovedAndInReviewImages($limit = 100) { $app = F::app(); $dbr = wfGetDB(DB_MASTER, array(), $app->wg->ExternalSharedDB); $city_ids = (new WikiaSQL())->SELECT("city_visualization_images.city_id")->FROM("city_visualization_images")->WHERE("city_visualization_images.image_review_status")->EQUAL_TO("0")->AND_("city_visualization_images.city_lang_code")->EQUAL_TO($app->wg->ContLang->getCode())->AND_("city_visualization_images.city_id")->IN(\FluentSql\StaticSQL::RAW("( select city_id from city_visualization_images WHERE image_review_status = 2 )"))->LIMIT($limit)->run($dbr, function ($result) { $res = []; while ($row = $result->fetchObject($result)) { $res[] = $row->city_id; } return $res; }); return $city_ids; }
public static function fetchAfflictedCityIds($langCode = null) { $app = F::app(); if (empty($langCode)) { $langCode = $app->wg->ContLang->getCode(); } $dbr = wfGetDB(DB_MASTER, array(), $app->wg->ExternalSharedDB); $city_ids = (new WikiaSQL())->SELECT("city_visualization.city_id")->FROM("city_visualization")->WHERE("city_visualization.city_lang_code")->EQUAL_TO($langCode)->AND_("city_visualization.city_id")->NOT_IN(\FluentSql\StaticSQL::RAW("( select city_id from city_visualization_images)"))->run($dbr, function ($result) { $res = []; while ($row = $result->fetchObject($result)) { $res[] = $row->city_id; } return $res; }); return $city_ids; }
/** * @return SQL */ public function VALUES() { $args = func_get_args(); if ($this->type->type() == Clause\Type::INSERT) { if (count($args) == 1 && is_array($args[0])) { $args = $args[0]; } $newArgs = []; foreach ($args as $valuesList) { $sql = rtrim(str_repeat('?, ', count($valuesList)), ', '); $newArgs[] = StaticSQL::RAW($sql, $valuesList); } $args = $newArgs; } return call_user_func_array([$this, 'VALUE'], $args); }
private function getWikisByHubOrCluster($hubId = null, $clusterId = null) { global $wgExternalSharedDB; $db = wfGetDB(DB_SLAVE, array(), $wgExternalSharedDB); $sql = (new \WikiaSQL())->SELECT('city_id', 'city_dbname')->FROM('city_list')->JOIN('city_cat_mapping')->USING('city_id')->WHERE('city_public')->EQUAL_TO(1)->AND_('city_useshared')->EQUAL_TO(1); if ($hubId) { $this->info('get list of all active wikis belonging to a specific hub', ['cat_id' => $hubId]); $sql->AND_('cat_id')->EQUAL_TO($hubId); } if ($clusterId) { $clusterId = intval($clusterId); $this->info('get list of all active wikis belonging to cluster', ['cluster_id' => $clusterId]); if ($clusterId == 1) { $sql->AND_(StaticSQL::RAW('(city_cluster IS NULL OR city_cluster = ?)', ['c1'])); } else { $sql->AND_('city_cluster')->EQUAL_TO("c{$clusterId}"); } } return $sql->runLoop($db, function (&$results, $row) { $results[$row->city_id] = $row->city_dbname; }); }