@@ -78,11 +78,31 @@ private function getTopExtensions( int $limit, DBConnRef $dbr ): array {
7878 COUNT
7979DESC
8080 ;
81+
82+ SELECT w8y_extension_data.w8y_ed_name, COUNT(w8y_extension_data.w8y_ed_ed_id) as count
83+ FROM w8y_wikis
84+ JOIN w8y_scrape_records ON w8y_wikis.w8y_wi_last_sr_id = w8y_scrape_records.w8y_sr_sr_id
85+ JOIN w8y_extension_links ON w8y_scrape_records.w8y_sr_vr_id = w8y_extension_links.w8y_el_vr_id
86+ JOIN w8y_extension_data ON w8y_extension_links.w8y_el_ed_id = w8y_extension_data.w8y_ed_ed_id
87+ WHERE w8y_wikis.w8y_wi_is_defunct = 0
88+ GROUP BY w8y_ed_name
89+ ORDER BY count DESC;
8190 */
82- $ select = [ '* ' ,
83- 'count ' => 'count(*) ' ];
84- $ from = Structure::DBTABLE_EXTENSIONS ;
85- $ res = $ dbr ->newSelectQueryBuilder ()->select ( $ select )->from ( $ from )->groupBy ( 'w8y_ex_name ' )
91+
92+
93+ $ select = [ Structure::DBTABLE_EXTENSIONS . '.* ' ,
94+ 'count ' => 'count( ' . Structure::DBTABLE_EXTENSIONS . '. ' . Structure::EXTENSION_ID . ') ' ];
95+ $ from = Structure::DBTABLE_WIKIS ;
96+ $ res = $ dbr ->newSelectQueryBuilder ()->select ( $ select )->from ( $ from )->
97+ leftJoin ( Structure::DBTABLE_SCRAPE ,
98+ null ,
99+ Structure::DBTABLE_WIKIS . '. ' . Structure::WIKI_LAST_SR_RCRD . '= ' . Structure::DBTABLE_SCRAPE . '. ' . Structure::SR_ID )->
100+ leftJoin ( Structure::DBTABLE_EXTENSIONS_LINK ,
101+ null ,
102+ Structure::DBTABLE_SCRAPE . '. ' . Structure::SCRAPE_VR_ID . '= ' . Structure::DBTABLE_EXTENSIONS_LINK . '. ' . Structure::EXTENSION_LINK_VID )->
103+ leftJoin ( Structure::DBTABLE_EXTENSIONS , null ,
104+ Structure::DBTABLE_EXTENSIONS_LINK . '. ' . Structure::EXTENSION_LINK_ID . '= ' . Structure::DBTABLE_EXTENSIONS . '. ' . Structure::EXTENSION_ID )->
105+ groupBy ( Structure::EXTENSION_ID )
86106 ->orderBy ( 'count ' ,
87107 'DESC ' )->limit ( $ limit )->caller ( __METHOD__ )->fetchResultSet ();
88108 $ ret = [];
0 commit comments