Hi!
Just so loving your module, thank you so much!
I've changed the time period a little to reflect shorter time deletion of activities (have a lot of users here :)
$cron_delete_options = array(
0 => t('Never, my queries are limited manually'),
600 => t('Older than 10 minutes'),
3600 => t('Older than an hour'),
86400 => t('Older than a day'),
604800 => t('Older than a week'),
2678400 => t('Older than a month'),
5270400 => t('Older than two months'),
7948800 => t('Older than three months'),
);and running cron every 15 minutes
Was wondering, is it perhaps possible to say delete everything in a time period, but keep for example last 10, 20 or 30 activities per user for the user profile (personal heartbeat) ? I think the project/activity module has something similar.
Is this perhaps possible please?
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | activity.gif | 15.61 KB | liliplanet |
| #6 | heartbeat_issue_1191740_6.patch | 0 bytes | Stalski |
Comments
Comment #1
Stalski commentedI'll look at it. I won't be easy but you certainly have a point there.
- Resetting status to get my attention -
Comment #2
liliplanet commentedThat is wonderful, thank you Stalski. As mentioned a similar concept exists at http://drupal.org/project/activity :)
Comment #3
Stalski commentedFirst part with the new selections , pushed to git.
Comment #4
liliplanet commentedfabulous! looking so forward Staski, thank you!
Comment #5
Stalski commentedReally sweating on this. One day to create a query is my current record now. Specialists are helping me.
I checked activity and I don't see a working and scalable solution there? Can you point me the code where you saw this?
Comment #6
Stalski commented@liliplanet The patch included works on the dev. Can you test this for me? Don't forget to backup the database.
I worked on this query a whole day and I think I can go bad in the way that too recent messages would be deleted, however the query should make sure that 10 activity records for each user are kept in database.
- EDIT -
If someone comes by, please review this code for me.
TODO Get language in the query so it's 10 per language. So in multilingual sites, you can set the configuration I added to double the time or something.
Comment #7
Stalski commentedComment #8
Stalski commentedIt does not break anything, so I pushed it go git to get more feedback (or some feedback or none is even better).
Comment #9
liliplanet commentedStalski, I will test today but in the meantime you can see the settings at admin/settings/activity/settings
and have attached a screenshot and believe the code is in activity.admin.inc
not sure if the following is part of it ..
Hope this helps some and will revert asap with results :) Thank you so much Stalski!
Comment #10
liliplanet commentedalso found this is activity.module
Comment #11
Stalski commentedYes, I found that code too. This does not what you asked for. It's a solution that is less scalable and does not exactly the same.
Without being to hush, this seems like a fix more than a scalable database solution.
So now, I am even more proud on the result :)
Comment #12
liliplanet commentedWow Stalski, thank you so much, so far running perfectly! You are a Super-Star! Will revert if anything changes, but looking very good :)
Comment #14
gcassie commentedI wonder if you might consider another approach to this query. If the heartbeat_activity table is very large and joined to itself in a situation like this were it can't use indexes effectively due to the comparison operators, the query can take many minutes to execute, if it finishes at all. For example, on a site with ~20K entries in the heartbeat_activity table this query is effectively blocking cron from running.
It looks more complex but on that same set of data executes in only a couple seconds.
There's a nice writeup of why/how this works here.
Comment #15
Stalski commentedOk, did not know that. This query I built together with one of the main figures in the mysql IRC room and I got the guarantee that it would be scalable. It could be you are correct and therefore I will take some advanced tests for this.
Is it a solution to add indexed to some fields you think?
About the sql, the timestamp still needs to be put into query as well. So the last query will stay the same.
Also, I prefer this to be taken up in another issue. See #1240436: Delete old activity on cron needs to be scalable.