mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
fixed things and applied code review recommends
This commit is contained in:
parent
f4e5986514
commit
628f3e2294
@ -40,7 +40,7 @@ class SourceHeartbeatProvider extends ServiceProvider
|
||||
{
|
||||
try {
|
||||
$failsJson = Storage::get('failovers.json');
|
||||
$fails = json_decode($failsJson, true);
|
||||
$fails = $failsJson ? json_decode($failsJson, true) : [];
|
||||
} catch (\Exception $e) {
|
||||
$fails = [];
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ trait JikanDataGenerator
|
||||
"Shounen"
|
||||
];
|
||||
|
||||
private function createUrl($malId, $type): string
|
||||
private function createMalUrl($malId, $type): string
|
||||
{
|
||||
return "https://myanimelist.net/" . $type . "/" . $malId . "/x";
|
||||
}
|
||||
@ -127,8 +127,12 @@ trait JikanDataGenerator
|
||||
return $this->faker->randomElements($this->dummyGenres, $count);
|
||||
}
|
||||
|
||||
public function stuff()
|
||||
private function getItemTestUrl($type, $mal_id = "", $sub_type = ""): string
|
||||
{
|
||||
return "";
|
||||
$test_base_url = env('APP_URL');
|
||||
$url = empty($sub_type) ?
|
||||
$test_base_url . "/v4/" . $type . "/" . $mal_id
|
||||
: $test_base_url . "/v4/" . $type . "/" . $sub_type . "/" . $mal_id;
|
||||
return sha1($url);
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,11 @@ class AnimeFactory extends Factory
|
||||
$title = $this->createTitle();
|
||||
$status = $this->faker->randomElement(["Currently Airing", "Completed", "Upcoming"]);
|
||||
[$aired_from, $aired_to] = $this->createActiveDateRange($status, "Currently Airing");
|
||||
$test_base_url = env('APP_URL');
|
||||
|
||||
return [
|
||||
"mal_id" => $mal_id,
|
||||
"url" => $this->createUrl($mal_id, "anime"),
|
||||
"url" => $this->createMalUrl($mal_id, "anime"),
|
||||
"titles" => [
|
||||
[
|
||||
"type" => "Default",
|
||||
@ -101,7 +102,7 @@ class AnimeFactory extends Factory
|
||||
],
|
||||
"createdAt" => new UTCDateTime(),
|
||||
"modifiedAt" => new UTCDateTime(),
|
||||
"request_hash" => sprintf("request:%s:%s", "v4", sha1("http://localhost-test/v4/anime/" . $mal_id))
|
||||
"request_hash" => sprintf("request:%s:%s", "v4", $this->getItemTestUrl("anime", $mal_id))
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class CharacterFactory extends Factory
|
||||
public function definition()
|
||||
{
|
||||
$mal_id = $this->createMalId();
|
||||
$url = $this->createUrl($mal_id, "character");
|
||||
$url = $this->createMalUrl($mal_id, "character");
|
||||
|
||||
return [
|
||||
"mal_id" => $mal_id,
|
||||
@ -30,7 +30,7 @@ class CharacterFactory extends Factory
|
||||
"about" => "test",
|
||||
"createdAt" => new UTCDateTime(),
|
||||
"modifiedAt" => new UTCDateTime(),
|
||||
"request_hash" => sprintf("request:%s:%s", "v4", sha1("http://localhost-test/v4/character/" . $mal_id))
|
||||
"request_hash" => sprintf("request:%s:%s", "v4", $this->getItemTestUrl("character", $mal_id))
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ abstract class GenreFactory extends Factory
|
||||
{
|
||||
$mal_id = $this->createMalId();
|
||||
$name = $this->getRandomGenreName();
|
||||
$url = $this->createUrl($mal_id, $this->mediaType . "/genre");
|
||||
$url = $this->createMalUrl($mal_id, $this->mediaType . "/genre");
|
||||
|
||||
return [
|
||||
"mal_id" => $mal_id,
|
||||
@ -23,7 +23,8 @@ abstract class GenreFactory extends Factory
|
||||
"count" => $this->faker->randomDigit(),
|
||||
"createdAt" => new UTCDateTime(),
|
||||
"modifiedAt" => new UTCDateTime(),
|
||||
"request_hash" => sprintf("request:%s:%s", "v4", sha1("http://localhost-test/v4/genres/". $this->mediaType ."/" . $mal_id))
|
||||
"request_hash" => sprintf("request:%s:%s", "v4",
|
||||
$this->getItemTestUrl("genres", $mal_id, $this->mediaType))
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class MangaFactory extends Factory
|
||||
|
||||
return [
|
||||
"mal_id" => $mal_id,
|
||||
"url" => $this->createUrl($mal_id, "manga"),
|
||||
"url" => $this->createMalUrl($mal_id, "manga"),
|
||||
"titles" => [
|
||||
[
|
||||
"type" => "Default",
|
||||
@ -84,7 +84,7 @@ class MangaFactory extends Factory
|
||||
],
|
||||
"createdAt" => new UTCDateTime(),
|
||||
"modifiedAt" => new UTCDateTime(),
|
||||
"request_hash" => sprintf("request:%s:%s", "v4", sha1("http://localhost-test/v4/manga/" . $mal_id))
|
||||
"request_hash" => sprintf("request:%s:%s", "v4", $this->getItemTestUrl("manga", $mal_id))
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ class PersonFactory extends Factory
|
||||
|
||||
return [
|
||||
"mal_id" => $mal_id,
|
||||
"url" => $this->createUrl($mal_id, "people"),
|
||||
"url" => $this->createMalUrl($mal_id, "people"),
|
||||
"website_url" => "https://webiste.example",
|
||||
"images" => [],
|
||||
"name" => $name,
|
||||
@ -38,7 +38,7 @@ class PersonFactory extends Factory
|
||||
"about" => "test",
|
||||
"createdAt" => new UTCDateTime(),
|
||||
"modifiedAt" => new UTCDateTime(),
|
||||
"request_hash" => sprintf("request:%s:%s", "v4", sha1("http://localhost-test/v4/people/" . $mal_id))
|
||||
"request_hash" => sprintf("request:%s:%s", "v4", $this->getItemTestUrl("people", $mal_id))
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ abstract class TestCase extends Laravel\Lumen\Testing\TestCase
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
$database = env('DB_DATABASE', 'jikan_tests');
|
||||
$app['config']->set('database.connections.mongodb.database', $database === 'jikan' ? 'jikan_test' : $database);
|
||||
$app['config']->set('database.connections.mongodb.database', $database === 'jikan' ? 'jikan_tests' : $database);
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user