Development

Changeset 26434

You must first sign up to be able to contribute.

Changeset 26434

Show
Ignore:
Timestamp:
01/09/10 16:44:17 (3 years ago)
Author:
ornicar2
Message:

[Diem][dmChessPlugin]
- automatically clear old games

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/dmChessPlugin

    • Property svn:ignore set to
      .settings
      .project
      .buildpath
      nbproject
  • plugins/dmChessPlugin/lib/model/doctrine/PluginDmChessGameTable.class.php

    r25984 r26434  
    44class PluginDmChessGameTable extends myDoctrineTable 
    55{ 
     6 
     7  public function broom() 
     8  { 
     9    $query = $this->createQuery('g') 
     10    // games created yesterday, without a move 
     11    ->where('g.created_at < ? AND g.turns = ?', array(date ("Y-m-d H:i:s", strtotime('-1 day')), 0)) 
     12    // games with last move one month ago, and not finished 
     13    ->orWhere('g.updated_at < ? AND g.is_finished = ?', array(date ("Y-m-d H:i:s", strtotime('-1 month')), false)); 
     14 
     15    $query->delete()->execute(); 
     16  } 
    617 
    718  public function preload($id) 
  • plugins/dmChessPlugin/modules/dmChessGame/actions/actions.class.php

    r26010 r26434  
    171171  public function executeCreate(dmWebRequest $request) 
    172172  { 
     173    // clean old games 
     174    dmDb::table('DmChessGame')->broom(); 
     175 
    173176    return $this->redirect($this->getHelper()->£link($this->getPage())->param('p', dmDb::table('DmChessPlayer')->startNewGame()->code)->getHref()); 
    174177  }