Skip to content

Commit ca97957

Browse files
authored
Merge pull request #187 from Mdwiki-TD/update_new
Refactor cats api
2 parents 335f451 + e8c5a40 commit ca97957

File tree

19 files changed

+573
-480
lines changed

19 files changed

+573
-480
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ leaderboard/z.php
4848
composer.lock
4949
/tests_backup
5050
.phpunit.result.cache
51-
phpunit.xml.dist
5251
phpunit.xml.z
5352
run.sh
5453
/src/.claude

phpunit.xml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.0/phpunit.xsd"
4-
bootstrap="vendor/autoload.php"
5-
colors="true">
6-
7-
<testsuites>
8-
<testsuite name="ParseWiki Test Suite">
9-
<directory>tests</directory>
10-
</testsuite>
11-
</testsuites>
12-
13-
</phpunit>
2+
<phpunit bootstrap="tests/bootstrap.php"
3+
colors="true"
4+
stopOnFailure="false"
5+
verbose="true">
6+
<testsuites>
7+
<testsuite name="Project Test Suite">
8+
<directory>tests</directory>
9+
</testsuite>
10+
</testsuites>
11+
<coverage processUncoveredFiles="true">
12+
<include>
13+
<directory suffix=".php">.</directory>
14+
</include>
15+
<exclude>
16+
<directory>vendor</directory>
17+
<directory>tests</directory>
18+
</exclude>
19+
</coverage>
20+
</phpunit>

run_tests.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
vendor/bin/phpunit tests --testdox --colors=always -c phpunit.xml
3+

src/backend/api_calls/curl_api.php

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/backend/api_calls/mdwiki_api.php

Lines changed: 0 additions & 72 deletions
This file was deleted.

src/backend/api_or_sql/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function isvalid($str)
2828
return !empty($str) && strtolower($str) != "all";
2929
}
3030

31-
function super_function($api_params, $sql_params, $sql_query, $no_refind = false, $table_name = null)
31+
function super_function(array $api_params, array $sql_params, string $sql_query, $table_name = null, $no_refind = false): array
3232
{
3333
global $use_td_api;
3434
// ---

src/backend/api_or_sql/new_sql_tables.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function exists_by_qids_query_and_category($lang, $category)
3939
// ---
4040
$params = [$lang, $category];
4141
// ---
42-
$u_data = super_function($api_params, $params, $query, $no_refind = false, $table_name = "all_qids_titles");
42+
$u_data = super_function($api_params, $params, $query, "all_qids_titles");
4343
// ---
4444
$data2[$lang . $category] = $u_data;
4545
// ---
@@ -71,7 +71,7 @@ function exists_by_qids_query($lang)
7171
// ---
7272
$params = [$lang];
7373
// ---
74-
$u_data = super_function($api_params, $params, $query, $no_refind = false, $table_name = "all_qids_titles");
74+
$u_data = super_function($api_params, $params, $query, "all_qids_titles");
7575
// ---
7676
$data2[$lang] = $u_data;
7777
// ---

src/backend/api_or_sql/process_data.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function get_process_all_new(): array
3232
return $process_all;
3333
}
3434

35-
function get_user_process_new($user, $year_y = "all")
35+
function get_user_process_new(string $user, string $year_y = "all")
3636
{
3737
// ---
3838
static $cache = [];
@@ -53,7 +53,7 @@ function get_user_process_new($user, $year_y = "all")
5353
$api_params['year'] = $year_y;
5454
}
5555
// ---
56-
$data = super_function($api_params, $params, $query, true);
56+
$data = super_function($api_params, $params, $query, "in_process", true);
5757
// ---
5858
$cache[$user] = $data;
5959
// ---
@@ -82,7 +82,7 @@ function get_users_process_new(): array
8282
return $process_new;
8383
}
8484

85-
function get_lang_in_process_new($code, $year_y = "all")
85+
function get_lang_in_process_new($code, $year_y = "all"): array
8686
{
8787
// ---
8888
static $cache = [];
@@ -113,7 +113,7 @@ function get_lang_in_process_new($code, $year_y = "all")
113113
$api_params['year'] = $year_y;
114114
}
115115
// ---
116-
$data = super_function($api_params, $params, $query, true);
116+
$data = super_function($api_params, $params, $query, "in_process", true);
117117
// ---
118118
// $cache[$code] = array_column($data, 'title');
119119
$cache[$code] = $data;

src/backend/results/cats_api.php

Lines changed: 0 additions & 91 deletions
This file was deleted.

src/backend/results/get_titles/get_results.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@
2323
function getinprocess($missing, $code)
2424
{
2525
$res = get_lang_in_process_new($code);
26+
// ---
2627
$titles = [];
28+
// ---
2729
foreach ($res as $t) {
28-
if (in_array($t['title'], $missing)) $titles[$t['title']] = $t;
30+
if (in_array($t['title'], $missing)) {
31+
$titles[$t['title']] = $t;
32+
}
2933
}
34+
// ---
3035
return $titles;
3136
}
3237

0 commit comments

Comments
 (0)