Added purgePlayers().

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@803 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2009-03-03 23:21:24 +00:00
parent 6c3c435c7c
commit d05664f649
2 changed files with 13 additions and 4 deletions
@@ -42,13 +42,11 @@ public class StatRecord extends PersistentRecord
public static final int SCHEMA_VERSION = 4; public static final int SCHEMA_VERSION = 4;
/** The identifier of the player this is a stat for. */ /** The identifier of the player this is a stat for. */
@Id @Id @Column(name="PLAYER_ID")
@Column(name="PLAYER_ID")
public int playerId; public int playerId;
/** The code of the stat. */ /** The code of the stat. */
@Id @Id @Column(name="STAT_CODE")
@Column(name="STAT_CODE")
public int statCode; public int statCode;
/** The data associated with the stat. */ /** The data associated with the stat. */
@@ -4,6 +4,7 @@
package com.threerings.stats.server.persist; package com.threerings.stats.server.persist;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -24,6 +25,7 @@ import com.samskivert.depot.DuplicateKeyException;
import com.samskivert.depot.Key; import com.samskivert.depot.Key;
import com.samskivert.depot.PersistenceContext; import com.samskivert.depot.PersistenceContext;
import com.samskivert.depot.PersistentRecord; import com.samskivert.depot.PersistentRecord;
import com.samskivert.depot.operator.Conditionals;
import com.samskivert.depot.clause.FieldDefinition; import com.samskivert.depot.clause.FieldDefinition;
import com.samskivert.depot.clause.FromOverride; import com.samskivert.depot.clause.FromOverride;
import com.samskivert.depot.clause.QueryClause; import com.samskivert.depot.clause.QueryClause;
@@ -180,6 +182,15 @@ public class StatRepository extends DepotRepository
_codeToString.get(type).remove(ocode); _codeToString.get(type).remove(ocode);
} }
/**
* Deletes all data associated with the supplied players.
*/
public void purgePlayers (Collection<Integer> playerIds)
{
deleteAll(StatRecord.class,
new Where(new Conditionals.In(StatRecord.PLAYER_ID, playerIds)));
}
/** /**
* Instantiates the appropriate stat class and decodes the stat from the data. * Instantiates the appropriate stat class and decodes the stat from the data.
*/ */