55/*
66Usage:
77
8- use function Results\GetResults\get_results;
8+ use function Results\GetResults\get_results; // get_results($cat, $camp, $depth, $code)
99
1010*/
1111
1212use Tables \SqlTables \TablesSql ;
13- // use function Results\FetchCatData\get_cat_exists_and_missing;
14- use function Results \FetchCatDataSparql \get_cat_exists_and_missing ;
15- use function Results \GetCats \get_mdwiki_cat_members ;
13+ use function Results \FetchCatData \get_cat_exists_and_missing ;
14+ use function Results \SparqlBot \filter_existing_out ;
1615use function TD \Render \TestPrint \test_print ;
1716use function SQLorAPI \Process \get_lang_in_process_new ;
17+ use function SQLorAPI \Funcs \get_lang_pages_by_cat ;
18+ use function Results \ResultsHelps \make_exists_targets ;
19+ use function Results \ResultsHelps \filter_items_missing_cat2 ;
20+ use function Results \ResultsHelps \create_summary ;
21+
1822
1923function getinprocess ($ missing , $ code )
2024{
@@ -26,26 +30,31 @@ function getinprocess($missing, $code)
2630 return $ titles ;
2731}
2832
29- function get_results ($ cat , $ camp , $ depth , $ code ): array
33+ function get_results ($ cat , $ camp , $ depth , $ code, $ filter_sparql ): array
3034{
3135 // Get existing and missing pages
3236 // ---
33- $ items = get_cat_exists_and_missing ($ cat , $ depth , $ code , true ) ?: [];
37+ $ targets_via_td = get_lang_pages_by_cat ($ code , $ cat );
38+ //---
39+ $ items = get_cat_exists_and_missing ($ cat , $ depth , $ code , true );
3440 // ---
35- $ len_of_exists_pages = $ items ['len_of_exists ' ];
3641 $ items_missing = $ items ['missing ' ];
37-
3842 $ items_exists = $ items ['exists ' ];
39-
43+ $ len_of_exists_pages = count ($ items_exists );
44+ // ---
45+ if (!empty ($ filter_sparql )) {
46+ [$ items_exists , $ items_missing ] = filter_existing_out ($ items_missing , $ items_exists , $ code );
47+ }
48+ // ---
49+ $ items_exists = make_exists_targets ($ targets_via_td , $ items_exists , $ code , $ cat );
50+ // ---
4051 test_print ("Items missing: " . count ($ items_missing ));
4152
4253 // Check for a secondary category
4354 $ cat2 = TablesSql::$ s_camps_cat2 [$ camp ] ?? '' ;
55+
4456 if (!empty ($ cat2 ) && $ cat2 !== $ cat ) {
45- // $cat2_members = get_mdwiki_cat_members($cat2, $use_cache = true, $depth = $depth, $camp = $camp);
46- $ cat2_members = get_mdwiki_cat_members ($ cat2 , $ depth , true );
47- $ items_missing = array_intersect ($ items_missing , $ cat2_members );
48- test_print ("Items missing after intersecting with cat2: " . count ($ items_missing ));
57+ $ items_missing = filter_items_missing_cat2 ($ items_missing , $ cat2 , $ depth );
4958 }
5059
5160 test_print ("Length of existing pages: $ len_of_exists_pages " );
@@ -57,27 +66,18 @@ function get_results($cat, $camp, $depth, $code): array
5766 $ inprocess = getinprocess ($ missing , $ code );
5867 $ len_inprocess = count ($ inprocess );
5968
60- // Calculate totals
61- $ len_of_missing_pages = count ($ missing );
62- $ len_of_all = $ len_of_exists_pages + $ len_of_missing_pages ;
63-
64- // Prepare category URL
65- $ cat2 = "Category: " . str_replace ('Category: ' , '' , $ cat );
66- $ caturl = "<a href='https://mdwiki.org/wiki/ $ cat2' target='_blank'>category</a> " ;
67-
68- // Generate summary message
69- $ ix = "Found $ len_of_all pages in $ caturl, $ len_of_exists_pages exists, and $ len_of_missing_pages missing in (<a href='https:// $ code.wikipedia.org' target='_blank'> $ code</a>), $ len_inprocess In process. " ;
70-
7169 // Remove in-process items from missing list
7270 if ($ len_inprocess > 0 ) {
7371 $ inprocess_2 = array_column ($ inprocess , 'title ' );
7472 $ missing = array_diff ($ missing , $ inprocess_2 );
7573 }
7674
75+ $ summary = create_summary ($ code , $ cat , $ inprocess , $ missing , $ len_of_exists_pages );
76+
7777 return [
7878 "inprocess " => $ inprocess ,
7979 "exists " => $ items_exists ,
8080 "missing " => $ missing ,
81- "ix " => $ ix ,
81+ "ix " => $ summary ,
8282 ];
8383}
0 commit comments