Repository navigation
feat: track post views once per session #1300
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
base: production
Are you sure you want to change the base?
Changes from all commits
fb382b0
1fe000f
647be57
d4aca85
b0b3085
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace App\Actions; | ||
|
|
||
| use App\Models\Commit; | ||
| use Illuminate\Contracts\Session\Session; | ||
|
|
||
| final readonly class RecordCommitView | ||
| { | ||
| public function handle(Commit $commit, Session $session): void | ||
| { | ||
| $key = "viewed_commits.{$commit->id}"; | ||
|
|
||
| if ($session->has($key)) { | ||
| return; | ||
| } | ||
|
|
||
| $session->put($key, true); | ||
|
|
||
| Commit::withoutTimestamps(fn () => $commit->increment('views_count')); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -37,8 +37,8 @@ final class CommitBuilder extends Builder | |||||||||
| */ | ||||||||||
| private const array COLUMNS_BUT_EMBEDDING = [ | ||||||||||
| 'id', 'user_id', 'body', 'created_at', 'updated_at', 'status', 'parent_id', 'deleted_at', 'link_preview_id', | ||||||||||
| 'quoted_commit_id', 'mentions', 'ai_decision', 'ai_categories', 'root_id', 'hot_score', 'pasteis_count', 'author_id', | ||||||||||
| 'headlines_classified_at', 'guild_id', | ||||||||||
| 'quoted_commit_id', 'mentions', 'ai_decision', 'ai_categories', 'root_id', 'hot_score', 'pasteis_count', | ||||||||||
| 'views_count', | ||||||||||
|
Comment on lines
+40
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restore the three columns dropped from The list must contain every column except the embedding, as its docblock states. This PR removes Restore the removed columns and keep Suggested fix
Committable suggestion
|
||||||||||
| ]; | ||||||||||
|
|
||||||||||
| /** | ||||||||||
|
|
||||||||||
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.
Inject
RecordCommitViewbefore calling it.show()does not declare$recordView. Every request that reaches this line fails before the commit page renders. AddRecordCommitView $recordViewto the method parameters.