-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add country flag tooltips in wiki #10668
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure we don't want to be doing a db query for every single flag
I just realized that if |
I don't think we want to make a network request to redis for every flag either; use a local cache like https://github.com/ppy/osu-web/blob/3b91b06/app/Libraries/Groups.php or https://github.com/ppy/osu-web/blob/3b91b06/app/Libraries/Medals.php does it. |
I mean making a service object to cache the country names like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fetch the countries (preferably just the name and country code) once, store it in an a Map
or keyed array and do the lookup against the Map/array
as needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private function allByCode(): Collection
{
return $this->memoize(__FUNCTION__, fn () => Country::get(['acronym', 'name'])->keyBy('acronym'));
}
public function byCode(string $code): ?Country
{
return $this->allByCode()->get($code);
}
app/Libraries/Countries.php
Outdated
|
||
class Countries | ||
{ | ||
use Memoizes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is needed for LocalCacheManager
to manage resetting the local cache with resetMemoized()
Closes #10661