Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 3c58daa

Browse files
committed
Fixed Wiki query option
1 parent 68ac70e commit 3c58daa

File tree

3 files changed

+45
-17
lines changed

3 files changed

+45
-17
lines changed

includes/data/Structure.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,22 @@ class Structure {
1818
private array $dbStructure;
1919

2020
public const DBTABLE_WIKIS = 'w8y_wikis';
21-
public const DBTABLE_EXTENSIONS = 'w8y_extensions';
22-
public const DBTABLE_SKINS = 'w8y_skins';
21+
public const DBTABLE_EXTENSIONS = 'w8y_extension_data';
22+
public const DBTABLE_EXTENSIONS_LINK = 'w8y_extension_links';
23+
public const DBTABLE_SKINS = 'w8y_skin_data';
24+
public const DBTABLE_SKINS_LINK = 'w8y_skin_links';
2325
public const DBTABLE_SCRAPE = 'w8y_scrape_records';
2426
public const WIKI_PAGEID = 'w8y_wi_page_id';
2527
public const WIKI_DEFUNCT = 'w8y_wi_is_defunct';
2628
public const WIKI_LAST_SR_RCRD = 'w8y_wi_last_sr_id';
2729
public const SR_ID = 'w8y_sr_sr_id';
2830
public const SCRAPE_VR_ID = 'w8y_sr_vr_id';
29-
public const EXTENSION_VERSION_ID = 'w8y_ex_vr_id';
30-
public const SKIN_VERSION_ID = 'w8y_sk_vr_id';
31+
public const EXTENSION_ID = 'w8y_ed_ed_id';
32+
public const EXTENSION_LINK_VID = 'w8y_el_vr_id';
33+
public const EXTENSION_LINK_ID = 'w8y_el_ed_id';
34+
public const SKIN_LINK_VID = 'w8y_sl_vr_id';
35+
public const SKIN_LINK_ID = 'w8y_sl_sd_id';
36+
public const SKIN_ID = 'w8y_sd_sd_id';
3137
public const SCRAPE_MEDIAWIKI_VERSION = 'w8y_sr_mw_version';
3238

3339
/**

includes/data/query/Stats.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,24 @@ private function getTopSkins( int $limit, DBConnRef $dbr ): array {
6161
* @return array
6262
*/
6363
private function getTopExtensions( int $limit, DBConnRef $dbr ): array {
64+
/*
65+
* SELECT
66+
w8y_wikis.w8y_wi_page_id,
67+
w8y_extensions.*,
68+
COUNT(
69+
DISTINCT w8y_extensions.w8y_ex_name
70+
) AS count
71+
FROM
72+
`w8y_wikis`
73+
INNER JOIN w8y_scrape_records ON w8y_wi_last_sr_id = w8y_scrape_records.w8y_sr_sr_id
74+
INNER JOIN w8y_extensions ON w8y_scrape_records.w8y_sr_vr_id = w8y_extensions.w8y_ex_vr_id
75+
GROUP BY
76+
w8y_extensions.w8y_ex_name
77+
ORDER BY
78+
COUNT
79+
DESC
80+
;
81+
*/
6482
$select = [ '*',
6583
'count' => 'count(*)' ];
6684
$from = Structure::DBTABLE_EXTENSIONS;

includes/data/query/Wiki.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,19 @@ public function __construct() {
2929
}
3030

3131
/**
32-
* @param int $scrapeId
32+
* @param int $versionId
3333
* @param DBConnRef $dbr
3434
*
3535
* @return array
3636
*/
3737
private function getExtensions( int $versionId, DBConnRef $dbr ): array {
3838
$select = [ '*' ];
39-
$from = Structure::DBTABLE_EXTENSIONS;
40-
$where = [ Structure::EXTENSION_VERSION_ID => $versionId ];
41-
$res = $dbr->newSelectQueryBuilder()->select( $select )->from( $from )->
42-
where( $where )->caller( __METHOD__ )->fetchResultSet();
39+
$from = Structure::DBTABLE_EXTENSIONS_LINK;
40+
$where = [ Structure::DBTABLE_EXTENSIONS_LINK . '.' . Structure::EXTENSION_LINK_VID => $versionId ];
41+
$res = $dbr->newSelectQueryBuilder()->select( $select )->from( $from )->join( Structure::DBTABLE_EXTENSIONS,
42+
null,
43+
Structure::DBTABLE_EXTENSIONS_LINK . '.' . Structure::EXTENSION_LINK_ID . ' = ' . Structure::DBTABLE_EXTENSIONS . '.' . Structure::EXTENSION_ID )
44+
->where( $where )->caller( __METHOD__ )->fetchResultSet();
4345

4446
$ret = [];
4547
$t = 0;
@@ -55,31 +57,34 @@ private function getExtensions( int $versionId, DBConnRef $dbr ): array {
5557
}
5658

5759
/**
58-
* @param int $scrapeId
60+
* @param int $versionId
5961
* @param DBConnRef $dbr
6062
*
6163
* @return array
6264
*/
6365
private function getSkins( int $versionId, DBConnRef $dbr ): array {
6466
$select = [ '*' ];
65-
$from = Structure::DBTABLE_SKINS;
66-
$where = [ Structure::SKIN_VERSION_ID => $versionId ];
67-
$res = $dbr->newSelectQueryBuilder()->select( $select )->from( $from )->
68-
where( $where )->caller( __METHOD__ )->fetchResultSet();
67+
$from = Structure::DBTABLE_SKINS_LINK;
68+
$where = [ Structure::DBTABLE_SKINS_LINK . '.' . Structure::SKIN_LINK_VID => $versionId ];
69+
$res = $dbr->newSelectQueryBuilder()->select( $select )->from( $from )->join( Structure::DBTABLE_SKINS,
70+
null,
71+
Structure::DBTABLE_SKINS_LINK . '.' . Structure::SKIN_LINK_ID . ' = ' . Structure::DBTABLE_SKINS . '.' . Structure::SKIN_ID )
72+
->where( $where )->caller( __METHOD__ )->fetchResultSet();
6973

7074
$ret = [];
7175
$t = 0;
7276
if ( $res->numRows() > 0 ) {
7377
while ( $row = $res->fetchRow() ) {
7478
foreach ( $this->structure->returnTableColumns( Structure::DBTABLE_SKINS ) as $tName ) {
7579
$ret[$t][$tName] = $row[$tName];
76-
$t++;
7780
}
81+
$t++;
7882
}
7983
}
8084
return $ret;
8185
}
8286

87+
8388
/**
8489
* @param int $pageId
8590
* @param DBConnRef $dbr
@@ -136,8 +141,7 @@ public function doQuery( int $pageID, string $export = "table" ): mixed {
136141
}
137142
$result['wiki']['pageTitle'] = Utils::getPageTitleFromID( $pageID );
138143
$result['extensions'] = $this->getExtensions( $result['scrape'][Structure::SCRAPE_VR_ID], $dbr );
139-
$result['skins'] = $this->getSkins( $result['scrape'][Structure::SCRAPE_VR_ID], $dbr );
140-
144+
//$result['skins'] = $this->getSkins( $result['scrape'][Structure::SCRAPE_VR_ID], $dbr );
141145
return match ( $export ) {
142146
"table" => Utils::renderTable( $result,
143147
'Results for ' . $result['wiki']['pageTitle'] . ' ( pageID: ' . $pageID . ' )' ),

0 commit comments

Comments
 (0)