Ejemplo n.º 1
0
function contests_cache($job, $step)
{
    $fw = \Base::instance();
    $new = "{$fw['installerCFG.db5.dbname']}`.`{$fw['installerCFG.db5.prefix']}";
    $limit = 50;
    $tracking = new DB\SQL\Mapper($fw->db5, $fw->get('installerCFG.db5.prefix') . 'convert');
    $tracking->load(['id = ?', $step['id']]);
    if ($step['success'] == 0) {
        $total = $fw->db5->exec("SELECT COUNT(*) as found FROM `{$new}contests`;")[0]['found'];
        $fw->db5->exec("UPDATE `{$new}convert`SET `success` = 1, `total` = :total WHERE `id` = :id ", [':total' => $total, ':id' => $step['id']]);
    }
    $dataIn = $fw->db5->exec("SELECT \r\n\t\t\t\t\t\t\t\tCon.conid,\r\n\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT S.sid,',',S.title,',',U.uid,',',U.nickname ORDER BY charname ASC SEPARATOR '||') AS storyblock,\r\n\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT Chara.charid,',',Chara.charname ORDER BY charname ASC SEPARATOR '||') AS characterblock,\r\n\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT C.cid,',',C.category ORDER BY category ASC SEPARATOR '||' ) as categoryblock,\r\n\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT T.tid,',',T.label,',',TG.description ORDER BY TG.order,TG.tgid,T.label ASC SEPARATOR '||') AS tagblock\r\n\t\t\t\t\t\t\t\t\tFROM \r\n\t\t\t\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\t\t\t\tSELECT Con1.conid\r\n\t\t\t\t\t\t\t\t\t\t\tFROM `{$new}contests`Con1\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE Con1.cache_tags IS NULL\r\n\t\t\t\t\t\t\t\t\t\t\tLIMIT 0,{$limit}\r\n\t\t\t\t\t\t\t\t\t) AS Con\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}contest_relations`rC ON ( rC.conid = Con.conid )\r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}stories`S ON ( S.sid = rC.relid and rC.type='ST' )\r\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}stories_authors`rSA ON ( rSA.sid = S.sid )\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}users`U ON ( U.uid = rSA.aid )\r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}tags`T ON ( T.tid = rC.relid AND rC.type = 'T' )\r\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}tag_groups`TG ON ( TG.tgid = T.tgid )\r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}characters`Chara ON ( Chara.charid = rC.relid AND rC.type = 'CH' )\r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}categories`C ON ( C.cid = rC.relid AND rC.type = 'CA' )\r\n\t\t\t\t\t\t\t\t\tGROUP BY Con.conid;");
    if (0 < ($count = sizeof($dataIn))) {
        foreach ($dataIn as $item) {
            $fw->db5->exec("UPDATE `{$new}contests` SET \r\n\t\t\t\t\t\t`cache_stories`\t\t= :storyblock,\r\n\t\t\t\t\t\t`cache_tags`\t\t= :tagblock,\r\n\t\t\t\t\t\t`cache_characters`\t= :characterblock,\r\n\t\t\t\t\t\t`cache_categories`\t= :categoryblock\r\n\t\t\t\t\tWHERE conid = {$item['conid']} ;", [':storyblock' => json_encode(upgradetools::cleanResult($item['storyblock'])), ':tagblock' => json_encode(upgradetools::cleanResult($item['tagblock'])), ':characterblock' => json_encode(upgradetools::cleanResult($item['characterblock'])), ':categoryblock' => json_encode(upgradetools::cleanResult($item['categoryblock']))]);
        }
        $tracking->items = $tracking->items + $count;
        $tracking->save();
    }
    if ($count == 0 or $count < $limit) {
        // There was either nothing to be done, or there are no elements left for the next run
        $tracking->success = 2;
        $tracking->save();
    }
}
Ejemplo n.º 2
0
function series_cache($job, $step)
{
    $fw = \Base::instance();
    $new = "{$fw['installerCFG.db5.dbname']}`.`{$fw['installerCFG.db5.prefix']}";
    $limit = 20;
    $tracking = new DB\SQL\Mapper($fw->db5, $fw->get('installerCFG.db5.prefix') . 'convert');
    $tracking->load(['id = ?', $step['id']]);
    if ($step['success'] == 0) {
        $total = $fw->db5->exec("SELECT COUNT(*) as found FROM `{$new}series`;")[0]['found'];
        $fw->db5->exec("UPDATE `{$new}convert`SET `success` = 1, `total` = :total WHERE `id` = :id ", [':total' => $total, ':id' => $step['id']]);
    }
    $dataIn = $fw->db5->exec("SELECT \r\n\t\t\t\t\t\t\t\tSERIES.seriesid, \r\n\t\t\t\t\t\t\t\tSERIES.tagblock, \r\n\t\t\t\t\t\t\t\tSERIES.characterblock, \r\n\t\t\t\t\t\t\t\tSERIES.authorblock, \r\n\t\t\t\t\t\t\t\tSERIES.categoryblock, \r\n\t\t\t\t\t\t\t\tCONCAT(rating,'||',max_rating_id) as max_rating\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\tSELECT \r\n\t\t\t\t\t\t\tSer.seriesid,\r\n\t\t\t\t\t\t\tMAX(Ra.rid) as max_rating_id,\r\n\t\t\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT U.uid,',',U.nickname ORDER BY nickname ASC SEPARATOR '||' ) as authorblock,\r\n\t\t\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT Chara.charid,',',Chara.charname ORDER BY charname ASC SEPARATOR '||') AS characterblock,\r\n\t\t\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT C.cid,',',C.category ORDER BY category ASC SEPARATOR '||' ) as categoryblock,\r\n\t\t\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT T.tid,',',T.label,',',TG.description ORDER BY TG.order,TG.tgid,T.label ASC SEPARATOR '||') AS tagblock\r\n\t\t\t\t\t\t\t\t\tFROM \r\n\t\t\t\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\t\t\t\tSELECT Ser1.seriesid\r\n\t\t\t\t\t\t\t\t\t\t\tFROM `{$new}series`Ser1\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE Ser1.cache_authors IS NULL\r\n\t\t\t\t\t\t\t\t\t\t\tLIMIT 0,{$limit}\r\n\t\t\t\t\t\t\t\t\t) AS Ser\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}series_stories`TrS ON ( Ser.seriesid = TrS.seriesid )\r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}stories`S ON ( TrS.sid = S.sid )\r\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}ratings`Ra ON ( Ra.rid = S.ratingid )\r\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}stories_tags`rST ON ( rST.sid = S.sid )\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}tags`T ON ( T.tid = rST.tid AND rST.character = 0 )\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}tag_groups`TG ON ( TG.tgid = T.tgid )\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}characters`Chara ON ( Chara.charid = rST.tid AND rST.character = 1 )\r\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}stories_categories`rSC ON ( rSC.sid = S.sid )\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}categories`C ON ( rSC.cid = C.cid )\r\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}stories_authors`rSA ON ( rSA.sid = S.sid )\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}users` U ON ( rSA.aid = U.uid )\r\n\t\t\t\t\t\t\t\t\tGROUP BY Ser.seriesid\r\n\t\t\t\t\t\t\t) AS SERIES\r\n\t\t\t\t\t\t\tLEFT JOIN `{$new}ratings`R ON (R.rid = max_rating_id);");
    if (0 < ($count = sizeof($dataIn))) {
        foreach ($dataIn as $item) {
            $fw->db5->exec("UPDATE `{$new}series` SET \r\n\t\t\t\t\t\t`cache_authors`\t\t= :authorblock,\r\n\t\t\t\t\t\t`cache_tags`\t\t= :tagblock,\r\n\t\t\t\t\t\t`cache_characters`\t= :characterblock,\r\n\t\t\t\t\t\t`cache_categories`\t= :categoryblock,\r\n\t\t\t\t\t\t`max_rating`\t\t= :max_rating\r\n\t\t\t\t\tWHERE seriesid = {$item['seriesid']} ;", [':authorblock' => json_encode(upgradetools::cleanResult($item['authorblock'])), ':tagblock' => json_encode(upgradetools::cleanResult($item['tagblock'])), ':characterblock' => json_encode(upgradetools::cleanResult($item['characterblock'])), ':categoryblock' => json_encode(upgradetools::cleanResult($item['categoryblock'])), ':max_rating' => json_encode(explode(",", $item['max_rating']))]);
        }
        $tracking->items = $tracking->items + $count;
        $tracking->save();
    }
    if ($count == 0 or $count < $limit) {
        // There was either nothing to be done, or there are no elements left for the next run
        $tracking->success = 2;
        $tracking->save();
    }
}
Ejemplo n.º 3
0
function recommendations_cache($job, $step)
{
    $fw = \Base::instance();
    $new = "{$fw['installerCFG.db5.dbname']}`.`{$fw['installerCFG.db5.prefix']}";
    $limit = 50;
    $tracking = new DB\SQL\Mapper($fw->db5, $fw->get('installerCFG.db5.prefix') . 'convert');
    $tracking->load(['id = ?', $step['id']]);
    if ($step['success'] == 0) {
        $total = $fw->db5->exec("SELECT COUNT(*) as found FROM `{$new}recommendations`;")[0]['found'];
        $fw->db5->exec("UPDATE `{$new}convert`SET `success` = 1, `total` = :total WHERE `id` = :id ", [':total' => $total, ':id' => $step['id']]);
    }
    $dataIn = $fw->db5->exec("SELECT SELECT_OUTER.recid,\r\n\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT tid,',',tag,',',description ORDER BY `order`,tgid,tag ASC SEPARATOR '||') AS tagblock,\r\n\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT charid,',',charname ORDER BY charname ASC SEPARATOR '||') AS characterblock,\r\n\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT cid,',',category ORDER BY category ASC SEPARATOR '||' ) as categoryblock,\r\n\t\t\t\t\t\t\t\tGROUP_CONCAT(DISTINCT ratingid,',',rating_name,',',rating_image SEPARATOR '||' ) as rating\r\n\t\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\t\t\tSELECT R.recid,\r\n\t\t\t\t\t\t\t\t\t\tR.ratingid, Ra.rating as rating_name, IF(Ra.rating_image,Ra.rating_image,'') as rating_image,\r\n\t\t\t\t\t\t\t\t\t\tCat.cid, Cat.category,\r\n\t\t\t\t\t\t\t\t\t\tTG.description,TG.order,TG.tgid,T.label as tag,T.tid,\r\n\t\t\t\t\t\t\t\t\t\tCh.charid, Ch.charname\r\n\t\t\t\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\t\t\t\t\tSELECT R1.*\r\n\t\t\t\t\t\t\t\t\t\t\tFROM `{$new}recommendations` R1\r\n\t\t\t\t\t\t\t\t\t\t\tWHERE R1.cache_tags IS NULL\r\n\t\t\t\t\t\t\t\t\t\t\tLIMIT 0,{$limit}\r\n\t\t\t\t\t\t\t\t\t\t) AS R\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}ratings` Ra ON ( Ra.rid = R.ratingid )\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}recommendation_relations`rRT ON ( rRT.recid = R.recid )\r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}tags` T ON ( T.tid = rRT.relid AND rRT.type='T' )\r\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}tag_groups` TG ON ( TG.tgid = T.tgid )\r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}characters` Ch ON ( Ch.charid = rRT.relid AND rRT.type = 'CH' )\r\n\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `{$new}categories` Cat ON ( Cat.cid = rRT.relid AND rRT.type = 'CA' )\r\n\t\t\t\t\t\t\t\t)AS SELECT_OUTER\r\n\t\t\t\t\t\t\t\tGROUP BY recid ORDER BY recid ASC;");
    if (0 < ($count = sizeof($dataIn))) {
        foreach ($dataIn as $item) {
            $fw->db5->exec("UPDATE `{$new}recommendations` SET \r\n\t\t\t\t\t`cache_tags`\t\t= :tagblock,\r\n\t\t\t\t\t`cache_characters`\t= :characterblock,\r\n\t\t\t\t\t`cache_categories`\t= :categoryblock,\r\n\t\t\t\t\t`cache_rating`\t\t= :rating\r\n\t\t\t\tWHERE recid = {$item['recid']} ;", [':tagblock' => json_encode(upgradetools::cleanResult($item['tagblock'])), ':characterblock' => json_encode(upgradetools::cleanResult($item['characterblock'])), ':categoryblock' => json_encode(upgradetools::cleanResult($item['categoryblock'])), ':rating' => json_encode(explode(",", $item['rating']))]);
        }
        $tracking->items = $tracking->items + $count;
        $tracking->save();
    }
    if ($count == 0 or $count < $limit) {
        // There was either nothing to be done, or there are no elements left for the next run
        $tracking->success = 2;
        $tracking->save();
    }
}