mirror of
https://github.com/jikan-me/jikan-rest.git
synced 2025-02-20 11:23:35 +08:00
user profile bug fixes
This commit is contained in:
parent
6205f35cb8
commit
f7342eea93
@ -48,8 +48,11 @@ class UserController extends Controller
|
||||
*/
|
||||
public function profile(Request $request, string $username)
|
||||
{
|
||||
|
||||
$username = strtolower($username);
|
||||
|
||||
$results = Profile::query()
|
||||
->where('request_hash', $this->fingerprint)
|
||||
->where('username', $username)
|
||||
->get();
|
||||
|
||||
if (
|
||||
@ -58,10 +61,6 @@ class UserController extends Controller
|
||||
) {
|
||||
$response = Profile::scrape($username);
|
||||
|
||||
if (HttpHelper::hasError($response)) {
|
||||
return HttpResponse::notFound($request);
|
||||
}
|
||||
|
||||
if ($results->isEmpty()) {
|
||||
$meta = [
|
||||
'createdAt' => new UTCDateTime(),
|
||||
@ -80,16 +79,15 @@ class UserController extends Controller
|
||||
|
||||
if ($this->isExpired($request, $results)) {
|
||||
Profile::query()
|
||||
->where('request_hash', $this->fingerprint)
|
||||
->where('username', $username)
|
||||
->update($response);
|
||||
}
|
||||
|
||||
$results = Profile::query()
|
||||
->where('request_hash', $this->fingerprint)
|
||||
->where('username', $username)
|
||||
->get();
|
||||
}
|
||||
|
||||
|
||||
if ($results->isEmpty()) {
|
||||
return HttpResponse::notFound($request);
|
||||
}
|
||||
|
@ -268,8 +268,10 @@ class ProfileResource extends JsonResource
|
||||
'birthday' => $this->birthday,
|
||||
'location' => $this->location,
|
||||
'joined' => $this->joined,
|
||||
'anime_stats' => $this->anime_stats,
|
||||
'manga_stats' => $this->manga_stats,
|
||||
'statistics' => [
|
||||
'anime' => $this->anime_stats,
|
||||
'manga' => $this->manga_stats,
|
||||
],
|
||||
'favorites' => $this->favorites,
|
||||
'about' => $this->about,
|
||||
];
|
||||
|
@ -15,7 +15,7 @@
|
||||
"flipbox/lumen-generator": "^6",
|
||||
"illuminate/redis": "^7",
|
||||
"jenssegers/mongodb": "^4.0",
|
||||
"jikan-me/jikan": "v3.0.0-alpha.23",
|
||||
"jikan-me/jikan": "v3.0.0-alpha.24",
|
||||
"jms/serializer": "^1.13",
|
||||
"laravel/lumen-framework": "^7.0",
|
||||
"league/flysystem": "^1.0",
|
||||
|
12
composer.lock
generated
12
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "4c26689674266ffd85bf1e7375030997",
|
||||
"content-hash": "8b53a22c8136caa8cf63a5a7015eb5ea",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brick/math",
|
||||
@ -2264,16 +2264,16 @@
|
||||
},
|
||||
{
|
||||
"name": "jikan-me/jikan",
|
||||
"version": "v3.0.0-alpha.23",
|
||||
"version": "v3.0.0-alpha.24",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jikan-me/jikan.git",
|
||||
"reference": "4c4204489525d715b0a37db588affbf4a39751fa"
|
||||
"reference": "b502454d5b5db41adafbfc26f5ddad5b0d325859"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/jikan-me/jikan/zipball/4c4204489525d715b0a37db588affbf4a39751fa",
|
||||
"reference": "4c4204489525d715b0a37db588affbf4a39751fa",
|
||||
"url": "https://api.github.com/repos/jikan-me/jikan/zipball/b502454d5b5db41adafbfc26f5ddad5b0d325859",
|
||||
"reference": "b502454d5b5db41adafbfc26f5ddad5b0d325859",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -2311,7 +2311,7 @@
|
||||
}
|
||||
],
|
||||
"description": "Jikan is an unofficial MyAnimeList API",
|
||||
"time": "2020-09-08T17:02:59+00:00"
|
||||
"time": "2020-09-08T17:35:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "jms/metadata",
|
||||
|
@ -14,7 +14,7 @@ class CreateProfilesTable extends Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->unique(['request_hash' => 1], 'request_hash');
|
||||
$table->string('request_hash');
|
||||
$table->unique(['mal_id' => 1], 'mal_id');
|
||||
$table->unique(['username' => 1], 'username');
|
||||
$table->date('last_online')->index();
|
||||
|
Loading…
x
Reference in New Issue
Block a user