laravel-timezone icon indicating copy to clipboard operation
laravel-timezone copied to clipboard

Improve performance. Avoiding extra request.

Open rrpadilla opened this issue 4 years ago • 3 comments

Hi, I think you are making an extra request if you do not have to update the user timezone. See L50-L60

Maybe you should check first if you have to update the user timezone. See recommended code below:

if (config('timezone.overwrite') == true || $user->timezone == null) {
        $ip = $this->getFromLookup();
        $geoip_info = geoip()->getLocation($ip);

        if ($user->timezone != $geoip_info['timezone']) {
                $user->timezone = $geoip_info['timezone'];
                $user->save();

                $this->notify($geoip_info);
        }
}       

rrpadilla avatar Jun 05 '20 05:06 rrpadilla

Hey, tks for the clinic eye on it. I wouldn't say an extra request, but an unnecessary one. We will be fixing soon with the provided suggestion ;)

amandiobm avatar Jun 08 '20 15:06 amandiobm

Just checking in, did this get looked at?

jamesmills avatar Jul 26 '20 07:07 jamesmills

Thanks @rrpadilla for this suggestions.

I was wondering if you would be willing to open a PR with your suggested update so that we could get this into the package. Anything to improve the performance of the package would be greatly appreciated.

Thanks for taking the time to contribute and I hope you continue to enjoy using the package.

James

jamesmills avatar Sep 15 '20 08:09 jamesmills