Development

Changeset 9821

You must first sign up to be able to contribute.

Changeset 9821

Show
Ignore:
Timestamp:
06/24/08 00:02:49 (5 years ago)
Author:
nicolas
Message:

sfPropelPlanetPlugin: added the planet:feed-purge task to purge entries older than a given date or amount of time

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfPropelPlanetPlugin/trunk/README

    r9748 r9821  
    4646 
    4747== After plugin(s) has been installed == 
    48 Run these commands within your project: 
    49  
     48First, you must enable the Propel behaviors, tuning your `config/propel.ini`  
     49file by changing the value of the `propel.builder.addBehaviors` property value: 
     50{{{ 
     51propel.builder.addBehaviors = true 
     52}}} 
     53 
     54Then run the following commands within your project: 
    5055{{{ 
    5156$ php symfony cache:clear 
  • plugins/sfPropelPlanetPlugin/trunk/config/schema.yml

    r9819 r9821  
    1212    is_active:       { type: boolean, default: 0 } 
    1313    periodicity:     { type: integer, required: true, default: 3600 } 
     14    #auto_purge:      { type: integer, required: true, default: 0 } 
    1415    last_grabbed_at: { type: timestamp, index: true } 
    1516    _indexes: 
  • plugins/sfPropelPlanetPlugin/trunk/lib/model/sfPlanetFeedEntryPeer.php

    r9819 r9821  
    77class sfPlanetFeedEntryPeer extends BasesfPlanetFeedEntryPeer 
    88{ 
     9   
     10  /** 
     11   * Deletes entries older than provided timestamp 
     12   * 
     13   * @param  int           $timestamp  The UNIX timestamp 
     14   * @param  sfPlanetFeed  $feed       The feed (optional) 
     15   * @return int                       The number of deleted entries 
     16   */ 
     17  public static function doDeleteOlderThan($timestamp, sfPlanetFeed $feed = null) 
     18  { 
     19    $c = new Criteria(); 
     20     
     21    if (!is_null($feed)) 
     22    { 
     23      $c->add(self::FEED_ID, $feed->getId()); 
     24    } 
     25     
     26    $c->add(self::PUBLISHED_AT, date('Y-m-d H:i:s'), Criteria::LESS_THAN); 
     27     
     28    return self::doDelete($c); 
     29  } 
    930   
    1031  /** 
  • plugins/sfPropelPlanetPlugin/trunk/lib/task/base/sfPlanetBaseTask.class.php

    r9727 r9821  
    9797   
    9898  /** 
     99   * Purges entries of a particular feed older than provided timestamp 
     100   * 
     101   * @param  sfPlanetFeed  $feed       The feed 
     102   * @param  int           $timestamp  The UNIX timestamp 
     103   * @return int                       The number of deleted entries 
     104   */ 
     105  public function purgeFeedEntries(sfPlanetFeed $feed, $timestamp) 
     106  { 
     107    try 
     108    { 
     109      return sfPlanetFeedEntryPeer::doDeleteOlderThan($timestamp, $feed); 
     110    } 
     111    catch (PropelException $e) 
     112    { 
     113      $this->logError(sprintf('Error while purging entries for feed "%s": %s',  
     114                              $feed->getTitle(), $e->getMessage())); 
     115    } 
     116  } 
     117   
     118  /** 
     119   * Purges entries older than provided timestamp 
     120   * 
     121   * @param int     $timestamp 
     122   */ 
     123  public function purgeEntries($timestamp) 
     124  { 
     125    try 
     126    { 
     127      return sfPlanetFeedEntryPeer::doDeleteOlderThan($timestamp); 
     128    } 
     129    catch (PropelException $e) 
     130    { 
     131      $this->logError(sprintf('Error while purging entries: %s', $e->getMessage())); 
     132    } 
     133  } 
     134   
     135  /** 
    99136   * Implemented here because declared abstract in parent class 
    100137   *  
  • plugins/sfPropelPlanetPlugin/trunk/lib/task/sfPlanetFeedGrabTask.class.php

    r9735 r9821  
    1818    $this->briefDescription = 'Grabs last planet feeds entries and store them in the database'; 
    1919    $this->detailedDescription = <<<EOF 
    20 The [planet:grab-entries|INFO] updates outdated feed entries, ones which the  
    21 [periodicity|COMMENT] value has been exceeded. 
     20The [planet:feed-grab|INFO] updates outdated feeds, ones from which the  
     21[periodicity|COMMENT] time has been exceeded. 
    2222 
    23 If you want to force grabbing for all feeds, even outdated ones: 
     23If you want to force grabbing for all feeds, even up-to-date ones: 
    2424 
    2525  $ php symfony planet:feed-grab [-f|COMMENT]