Skip to content
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

duplicate logs #22

Open
miladbrave opened this issue Mar 5, 2021 · 5 comments
Open

duplicate logs #22

miladbrave opened this issue Mar 5, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@miladbrave
Copy link

How can duplicate logs be prevented? For example if a person refresh several time in a page system add new log so it causes misinformation!!

@khanzadimahdi khanzadimahdi added the enhancement New feature or request label Apr 15, 2021
@khanzadimahdi
Copy link
Member

please add this feature to the package and send a pull request. I will merge it.

@salawu
Copy link

salawu commented Jun 27, 2022

Good morning dear friend,

I see that there are duplicates. Were you able to fix this bug? If so, tell us how to fix the link. Thanks !
Good morning dear friend,

I see that there are duplicates. Were you able to fix this bug? If so, tell us how to fix the link. Thanks !

Bonjour cher ami,

Je constate qu'il y a des doublons. Avez-vous pu corriger ce bug? Si oui, dites-nous comment procéder pour corriger le lien. Merci!

@salawu
Copy link

salawu commented Jun 27, 2022

Good morning dear friend,

I see that there are duplicates. Were you able to fix this bug? If so, tell us how to fix the link. Thanks !

@gagaltotal
Copy link

wtf, I tried writing code in visitor but it doesn't affect it at all, it can still duplicate logs

example in file Visitor.php :

public function visit(Model $model = null)
    {
        if (in_array($this->request->path(), $this->except)) {
            return;
        }

        $data = $this->prepareLog();

        // Check for existing log to prevent duplicates
        $existingVisit = Visit::where('ip', $data['ip'])
            ->where('url', $data['url'])
            ->where('device', $data['device'])
            ->where('platform', $data['platform'])
            ->first();

        if ($existingVisit) {
            return $existingVisit;
        }

        if (null !== $model && method_exists($model, 'visitLogs')) {
            $visit = $model->visitLogs()->create($data);
        } else {
            $visit = Visit::create($data);
        }

        return $visit;
    }

why ?

@gagaltotal
Copy link

gagaltotal commented Aug 2, 2024

If you want no duplication, I have tried using if logic, and bringing in a model or you can use a query builder

example code in file home your website :

    $visit = ViewPage::where('ip', $request->ip())->count(); // Check for existing log to prevent duplicates

    if ($visit >= 1) {
        return view(getTheme('home'));
    }else{
    visitor()->visit(); // create a visit log
    return view(getTheme('home'));
}

I think editing the file in /shetabit/src/Visitor.php

You can change the log to not duplicate it, but it's still the code example that I showed above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants