Hi, Does the following approach for auto moderation sound fine or am I on the wrong path ?
I think we neet to make changes in handler to_outgoing.py in method process. form Table2 and enqueue it in outgoing queue else it stays in the
We need to make two databases : Table1 Schema-> [ user_id | Thread name | list_id | count | last_msg_posted_at ] user_id, list_id, Thread name together act as primary key. It stores the count of number of posts of a user on a particular thread and the time corresponding to the last post. Table2 Schema-> [message_id | user_id |Thread name| list_id |don't_post_before_time] here, don't_post_before_time=(last_msg_posted_at)+(count/10)*d where, "d" will be delay set by list-admin, eg 3 hrs.
The count variable is accessed from Table1.
When process is called and a new message entry comes: a) case 1: It is the first post by user on that thread then we create a new entry in Table1 with count 1 and last_msg_posted_at_time = posting time of that message. Then the corresponding entry is made in Table2 with new count and calculated don't_post_before_time. case 2: It is not the first post implies there is already an entry in Table1 then we increase its count by 1 and we calculate don't_post_before_time using count and last_msg_posted_at_time. After making the corresponding entry in Table2 using values just calculated we update last_msg_posted_at_time in Table1 with the value of don't_post_before_time of this entry b)Now we iterate over all entries in Table2 and whoever has don't_post_before_time < current_time we remove the corresponding entry
database.
Suppose, "abc@gmail.com" sends 9 messages to a list "foo@foo.com" on the thread "Questions",the last being sent at 4:00pm, then Table1 will look like [abc@gmail.com | Questions| foo@foo.com | 9 | 4:00pm] Now, if the 10th msg comes,from this database, we will retrieve the "last_msg_posted_at" before updating the tuple for the 10th msg and will calculate dont_post_it_before=last_msg_posted_at+(count/10)*d = 7:00pm, now the last_msg_posted_at field in the first database will be updated and will be equal to dont_post_it_before, and these details will be used to create an entry in Table2 database too. Table1 will look like [abc@gmail.com | Questions| foo@foo.com | 10 | 7:00pm] Table2 will look like [xyz | abc@gmail.com | Questions| foo@foo.com | 7:00pm] Now we iterate over all entries and enqueue all that have don't_post_before_time < current_time. Remaining entries stay in the database and will be checked the next time process is called.
Regards Aanand