-
-
Notifications
You must be signed in to change notification settings - Fork 86
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
Feat/purge messages upto 24 hrs in current channel #982
base: develop
Are you sure you want to change the base?
Feat/purge messages upto 24 hrs in current channel #982
Conversation
* enum will hold duration constants for feature * tiny fixes in message for user of command * hrs-> hr for single message and in x hrs -> within x hrs
application/src/main/java/org/togetherjava/tjbot/features/moderation/history/Duration.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/togetherjava/tjbot/features/moderation/history/MessageHistoryRoutine.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/togetherjava/tjbot/features/moderation/history/MessageHistoryRoutine.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/togetherjava/tjbot/features/moderation/history/MessageHistoryRoutine.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/togetherjava/tjbot/features/moderation/history/MessageHistoryRoutine.java
Outdated
Show resolved
Hide resolved
...n/src/main/java/org/togetherjava/tjbot/features/moderation/history/PurgeMessageListener.java
Show resolved
Hide resolved
...n/src/main/java/org/togetherjava/tjbot/features/moderation/history/PurgeMessageListener.java
Show resolved
Hide resolved
...n/src/main/java/org/togetherjava/tjbot/features/moderation/history/PurgeMessageListener.java
Outdated
Show resolved
Hide resolved
...n/src/main/java/org/togetherjava/tjbot/features/moderation/history/PurgeMessageListener.java
Show resolved
Hide resolved
application/src/main/java/org/togetherjava/tjbot/features/moderation/history/Duration.java
Outdated
Show resolved
Hide resolved
private static final int MESSAGES_RECORDS_MAX_LIMIT = 7500; | ||
private static final int MESSAGES_RECORDS_THRESHOLD = MESSAGES_RECORDS_MAX_LIMIT - 100; | ||
private static final int RECORDS_TO_TRIM = 500; | ||
static AtomicInteger recordsCounter = new AtomicInteger(0); |
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.
since the PR is getting too old now and so much stuff to review , flagging the important bit, is using atomic justified here?
the goal is to limit only certain no of db entries(recordsCounter), which is modified across package in PurgeMessageListener
(incrementCounterByOne) on each new message and in both PurgeHistoryCommand
and PurgeExpiredMessageHistory
(decrementCountByOne) on each deletion of record/message.
converting this PR to draft, feel like it needs a bit of refactoring considering moderation usecase per channel basis might not be suited anymore. |
For earlier context related to PR, #945
resolves #912
Workflow
Includes
/purge-in-channel
.Additions
Command Interface
when there's no records:
![image](https://private-user-images.githubusercontent.com/61616007/283924736-060468c9-fc57-4121-bb24-e579d2b34879.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwMTc4OTQsIm5iZiI6MTcyNDAxNzU5NCwicGF0aCI6Ii82MTYxNjAwNy8yODM5MjQ3MzYtMDYwNDY4YzktZmM1Ny00MTIxLWJiMjQtZTU3OWQyYjM0ODc5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE4VDIxNDYzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYzNmIxYjQ4MmE4MTE3NjZkMDFjYjk3ZGZkOTdjNzM2NzUzZDUyN2NhNTZmZjZhNmI4MDkyMThhNTU1YmI3YzYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.X3ZqcXIBFJXrx5PiBOSCBAUQ2kxLbZMkxtyqFf_7ZAI)
if there's any records within selected duration:
![image](https://private-user-images.githubusercontent.com/61616007/283925032-fe03e6e6-a284-4c1f-b9e2-06cd38fbcdde.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQwMTc4OTQsIm5iZiI6MTcyNDAxNzU5NCwicGF0aCI6Ii82MTYxNjAwNy8yODM5MjUwMzItZmUwM2U2ZTYtYTI4NC00YzFmLWI5ZTItMDZjZDM4ZmJjZGRlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE4VDIxNDYzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZlMWVjMGU0ZDE0YmQ5ZmE0M2Y5ZTEyMDUzMTQwZjE0ZmJkMDQ4OThhNzhlYjg3MWQzOTUwMzQ2ZDI1YzAyYmQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.tigGcr_A-JxocfrWAVlKCJSNB0f_cCiqbhibFBfFzZk)
Note: Duration is optional, if skipped it defaults to last hour.