-
Notifications
You must be signed in to change notification settings - Fork 17
Fix post views bugs #167
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
Fix post views bugs #167
Conversation
|
@mckenziearts J'ai refait le PR, J'ai aussi remarqué lorsque je voulais faire un don que cela marque une erreur 500. |
| $user = Auth::user(); | ||
|
|
||
| views($article)->record(); | ||
| views($article)->cooldown(now()->addHours(2))->record(); |
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.
Que résoud cette action et quel comportement tu reçois et comment devrait-il normalement se comporter
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.
views($article)->record();
la première ligne comptabilise chaque vue sans restriction, tandis que views($article)->cooldown(now()->addHours(2))->record(); impose une attente de 2 heures entre les enregistrements de vues pour le même article.
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.
Si 50 personnes regardent l'article au bout de 10 minutes il n'enregistre pas les 50 records ? Ou tu dis qu'il va enregistrer les 50 records après 2h
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.
Non c'est pour dire que un utilisateur ne pourrait voir le post deux fois de suite, genre sa vue sera mis en cache de tel sorte que si il voit un poste, en actualisant le navigateur, on considérera que il a déjà vu le post , la le nombre de vue ne sera pas incrémenté cela pendant les deux prochaines heures. donc la vue de post par cette utilisateur sera gelée.
| ->send(); | ||
|
|
||
| $this->reset(); | ||
| $this->reset('body'); |
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.
C'est la même chose. Le reset réinitialise toutes les variables du formulaire
app/helpers.php
Outdated
| } | ||
| } | ||
|
|
||
| if(! function_exists('getAvatar')) { |
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.
Pas nécessaire
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.
Ici je voulais faire une illustration afin de simuler l'utilisation du onerror, ce n'était pas définitif.
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.
Faut supprimer cette fonction du coup on ne garde pas du coup qui n'est pas utile
| <h2 class="text-xs leading-5 tracking-wide uppercase text-skin-base">{{ __('Article suivant') }}</h2> | ||
| <div class="mt-3 flex items-start space-x-2"> | ||
| <img class="h-10 w-10 object-cover shadow-lg rounded-md" src="{{ $next->getFirstMediaUrl('media') ?? asset('images/socialcard.png') }}" alt="{{ $next->slug }}"> | ||
| <img class="h-10 w-10 object-cover shadow-lg rounded-md" src="{{ $next->getFirstMediaUrl('media') ?? asset('images/socialcard.png') }}" alt="{{ $next->slug }}" onerror="this.onerror=null;this.src='{{ getAvatar($next->title) }}'"> |
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.
Le onerror c'est quoi son utilité vu que il y'a déjà une condition? C'est la condition qu'il faut revoir
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.
Le onerror gère les erreurs de chargement d'image et utilise une image alternative si le chargement échoue, ce qui améliore l'expérience utilisateur en fournissant une option de secours. car j'ai remarque sur la plateforme des images n'ayant pas chargé donc n'existant pas, et la place c'est le title de l'image qui s'affichait et cela détruisait l'ui
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.
C'est la condition qu'il faut corriger dans ce cas parce que si un article n'a pas d'image il y'a un placeholder normalement
mckenziearts
left a comment
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.
Une fois que tu auras effectué les retours je pourrai merge ta PR
app/helpers.php
Outdated
| } | ||
| } | ||
|
|
||
| if(! function_exists('getAvatar')) { |
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.
Faut supprimer cette fonction du coup on ne garde pas du coup qui n'est pas utile
| <h2 class="text-xs leading-5 tracking-wide uppercase text-skin-base">{{ __('Article suivant') }}</h2> | ||
| <div class="mt-3 flex items-start space-x-2"> | ||
| <img class="h-10 w-10 object-cover shadow-lg rounded-md" src="{{ $next->getFirstMediaUrl('media') ?? asset('images/socialcard.png') }}" alt="{{ $next->slug }}"> | ||
| <img class="h-10 w-10 object-cover shadow-lg rounded-md" src="{{ $next->getFirstMediaUrl('media') ?? asset('images/socialcard.png') }}" alt="{{ $next->slug }}" onerror="this.onerror=null;this.src='{{ getAvatar($next->title) }}'"> |
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.
C'est la condition qu'il faut corriger dans ce cas parce que si un article n'a pas d'image il y'a un placeholder normalement
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.
@jiordiviera ce que je dis souvent c'est que si un fichier n'entre pas dasn le scope de ta tache faudrait éviter de les modifier. Parce que tu modifies ce fichier pourtant ta feature n'a pas besoin de le faire.
| {{ __('PNG, JPG, GIF up to 1MB') }} | ||
| </p> | ||
| <input @focus="focused = true" @blur="focused = false" class="sr-only" type="file" {{ $attributes }} /> | ||
| <input @focus="focused = true" @blur="focused = false" class="sr-only" type="file" accept="image/jpg, image/jpeg, image/png" {{ $attributes }} /> |
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.
Annule cette modification
| <img class="object-cover shadow-lg rounded-lg group-hover:opacity-75" | ||
| src="{{ $article->getFirstMediaUrl('media') }}" | ||
| alt="{{ $article->title }}" | ||
| alt="{{ $article->title }}" onerror="this.src='{{ asset('images/socialcard.png') }}'" |
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.
Annule cette modification
| <a href="{{ route('articles.show', $article) }}" class="group"> | ||
| <div class="aspect-w-3 aspect-h-2"> | ||
| <img class="object-cover shadow-lg rounded-lg group-hover:opacity-75" src="{{ $article->getFirstMediaUrl('media') }}" alt="{{ $article->title }}" onerror="this.onerror=null;this.src='{{ getAvatar($article->title) }}'" /> | ||
| <img class="object-cover shadow-lg rounded-lg group-hover:opacity-75" src="{{ $article->getFirstMediaUrl('media') }}" alt="{{ $article->title }}" onerror="this.onerror=null;this.src='{{ asset('images/socialcard.png') }}'" /> |
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.
Annule cette modification
| </p> | ||
| <div class="relative h-96 overflow-hidden"> | ||
| <img class="w-full h-full object-cover shadow-lg rounded-lg group-hover:opacity-75" src="{{ $article->getFirstMediaUrl('media') }}" alt="{{ $article->title }}" /> | ||
| <img class="w-full h-full object-cover shadow-lg rounded-lg group-hover:opacity-75" src="{{ $article->getFirstMediaUrl('media') }}" alt="{{ $article->title }}" onerror="this.src='{{ asset('images/socialcard.png') }}'" /> |
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.
Annule cette modification
| <h2 class="text-xs leading-5 tracking-wide uppercase text-skin-base">{{ __('Article précédent') }}</h2> | ||
| <div class="mt-3 flex items-start space-x-2"> | ||
| <img class="h-10 w-10 object-cover shadow-lg rounded-md" src="{{ $previous->getFirstMediaUrl('media') ?? asset('images/socialcard.png') }}" alt="{{ $previous->slug }}" onerror="this.onerror=null;this.src='{{ getAvatar($previous->title) }}'"> | ||
| <img class="h-10 w-10 object-cover shadow-lg rounded-md" src="{{ $previous->getFirstMediaUrl('media') ?? asset('images/socialcard.png') }}" alt="{{ $previous->slug }}" onerror="this.onerror=null; this.src='{{ asset('images/socialcard.png') }}'"> |
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.
Annule cette modification
| <h2 class="text-xs leading-5 tracking-wide uppercase text-skin-base">{{ __('Article suivant') }}</h2> | ||
| <div class="mt-3 flex items-start space-x-2"> | ||
| <img class="h-10 w-10 object-cover shadow-lg rounded-md" src="{{ $next->getFirstMediaUrl('media') ?? asset('images/socialcard.png') }}" alt="{{ $next->slug }}" onerror="this.onerror=null;this.src='{{ getAvatar($next->title) }}'"> | ||
| <img class="h-10 w-10 object-cover shadow-lg rounded-md" src="{{ $next->getFirstMediaUrl('media') ?? asset('images/socialcard.png') }}" alt="{{ $next->slug }}" onerror="this.onerror=null;this.src='{{ asset('images/socialcard.png') }}'"> |
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.
Annule cette modification
| @if($article->isNotApproved()) | ||
| @hasanyrole('admin|moderator') | ||
| <button onclick="Livewire.emit('openModal', 'modals.approved-article', {{ json_encode([$article->id]) }})" type="button" class="-ml-px relative inline-flex items-center px-4 py-2 border border-skin-base bg-skin-card text-sm font-medium text-green-500 hover:bg-skin-card-muted focus:z-10 focus:outline-none focus:ring-1 focus:ring-green-500 focus:border-green-500 focus:border-green-500 focus:ring-offset-body"> | ||
| <button onclick="Livewire.emit('openModal', 'modals.approved-article', {{ json_encode([$article->id]) }})" type="button" class="-ml-px relative inline-flex items-center px-4 py-2 border border-skin-base bg-skin-card text-sm font-medium text-green-500 hover:bg-skin-card-muted focus:z-10 focus:outline-none focus:ring-1 focus:ring-green-500 focus:border-green-500 focus:ring-offset-body"> |
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.
rétabli les classes que tu as retiré
| <h2 class="text-xs leading-5 font-medium tracking-wide uppercase text-skin-base">Article précédent</h2> | ||
| <a href="{{ route('articles.show', $previous) }}" class="mt-3 flex items-start space-x-2"> | ||
| <img class="h-8 w-8 object-cover shadow-lg rounded-md" src="{{ $previous->getFirstMediaUrl('media') }}" alt="{{ $previous->slug }}"> | ||
| <img class="h-8 w-8 object-cover shadow-lg rounded-md" src="{{ $previous->getFirstMediaUrl('media') }}" alt="{{ $previous->slug }}" onerror="this.onerror=null;this.src='{{ asset('images/socialcard.png') }}'"> |
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.
Annule cette modification
Correction de l'incrémentation des vues d'un post à l'actualisation de la page, et aussi ajout d'une image de secours lorsque l'image est inexistant. et aussi résolution du problème qui subvenait après avoir commenté une discussion .