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

Avoids recording repeated activities. #1265

Conversation

solomon-ochepa
Copy link

@solomon-ochepa solomon-ochepa commented Jan 19, 2024

Avoids recording repeated activities.

Use case:

Tracking access to the user dashboard, for instance, on each refresh, a record will be saved to the database.

Solution:

The system will check the last record, and if it matches the new record, it will return false, preventing the duplicate record from being saved.

Avoids recording repeated activities.
@solomon-ochepa solomon-ochepa changed the title Update Activity.php Avoids recording repeated activities. Jan 19, 2024
@Gummibeer
Copy link
Collaborator

No underlying issue attached and no use case description or anything what kind of problem this should solve: closed ❌

@Gummibeer Gummibeer closed this Jan 31, 2024
@solomon-ochepa
Copy link
Author

No underlying issue attached and no use case description or anything what kind of problem this should solve: closed ❌

I discover the issue and choose to create a fix for it since I can.

Nevertheless, the title is clear and descriptive enough.

You should have asked and waited for a response, instead of closing the PR instantly without caring what problem it fixed.

@solomon-ochepa
Copy link
Author

I've updated the description. Please check.

@Gummibeer
Copy link
Collaborator

Just wrap your outer code in https://github.com/spatie/once for example.
That's absolutely nothing this package should and will handle. As what makes an activity unique and for how long and if duplicates are wanted or not is different per app.

@solomon-ochepa
Copy link
Author

Just wrap your outer code in https://github.com/spatie/once for example. That's absolutely nothing this package should and will handle. As what makes an activity unique and for how long and if duplicates are wanted or not is different per app.

You can't use that package to test repeated action scenarios. Why not test the case study I provided instead?

Case:

Log user access to the Dashboard page.

Result:

Every time the user refreshes the Dashboard, a new entry will be recorded, repeatedly.

Solution:

Only the first entry should be recorded. On each subsequent refresh, the model should check if the last log is the same as the incoming record, if the same the transaction should be aborted, or updated.

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

Successfully merging this pull request may close these issues.

2 participants