Hello I'm having some trouble getting my tallied clicks to expire... Please see the website here: http://www.bigfreelinks.com

As you can see, I would like the highest visited websites in our directory to get pushed up to the top of the list on our homepage; and the lifetime of any website clicks should lasts for only 12 hours, but I've not been able to get the clicks to expire, they only continue to add up!

Any help with achieving this would be great! :) thankyou to anyone who may be able to help!

Comments

HanleyDesigns’s picture

Can anybody help me please???

Scott Reynolds’s picture

You are going to have to implement hook_cron(). Call votingapi_select_votes() with a timestamp (time() - 12 * 3600). loop through the returned value collecting the content_ids. Call votingapi_delete_votes($result_from_votingapi_select_votes()), and then call votingapi_recalculate_results() for each content_id collected previously.

HanleyDesigns’s picture

sorry this is probably a silly question, but are you saying I need to hack the Voting API module?
And where would I enter these values for implementing the hook_cron(). ???? I'm pretty new to these type of instructions... I thank you for your help!

Scott Reynolds’s picture

Hahah no. Im saying you have to write code in your own custom module. http://api.drupal.org/api/function/hook_cron/6

HanleyDesigns’s picture

thanks for the link scott! I'll see how I go! ;) haha

HanleyDesigns’s picture

Hey, just wondering if anyone would be willing to build me this module? it sounds like a simple job if you know what you're doing! I don't... LOL
If you require some kind of payment for it I can certainly arrange that too...

Appreciate any takers help! :) thanks!!!

HanleyDesigns’s picture

can anybody help me write this cron job please? I have done some searching but there doesn't seem to be any instructions as such... Help! :) Do I just edit what's in my /cron.php file??? how is it meant to be coded?

THIS IS MY CRON.PHP CODE

include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_cron_run();

<?php
function hook_cron() {
  $result = db_query('SELECT * FROM {site} WHERE checked = 0 OR checked
    + refresh < %d', time());

  while ($site = db_fetch_array($result)) {
    cloud_update($site);
  }
}
?>
Scott Reynolds’s picture

You have to create a module and implement hook_cron. Here read up on this: http://drupal.org/developing/modules

Also take a look at: http://drupal.org/project/examples

HanleyDesigns’s picture

You don't know if 'Poormanscron' will be able to do this?
http://drupal.org/project/poormanscron

torotil’s picture

Status: Active » Closed (fixed)

As this is a rather special requirement I don't think that making it part of this module is a good idea. Also the support request has been inactive for the past 2.5 years.