Updated to new Depot world order.
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@797 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -35,26 +35,10 @@ import com.threerings.parlor.rating.util.Percentiler;
|
||||
public class PercentileRecord extends PersistentRecord
|
||||
{
|
||||
// AUTO-GENERATED: FIELDS START
|
||||
/** The column identifier for the {@link #gameId} field. */
|
||||
public static final String GAME_ID = "gameId";
|
||||
|
||||
/** The qualified column identifier for the {@link #gameId} field. */
|
||||
public static final ColumnExp GAME_ID_C =
|
||||
new ColumnExp(PercentileRecord.class, GAME_ID);
|
||||
|
||||
/** The column identifier for the {@link #gameMode} field. */
|
||||
public static final String GAME_MODE = "gameMode";
|
||||
|
||||
/** The qualified column identifier for the {@link #gameMode} field. */
|
||||
public static final ColumnExp GAME_MODE_C =
|
||||
new ColumnExp(PercentileRecord.class, GAME_MODE);
|
||||
|
||||
/** The column identifier for the {@link #data} field. */
|
||||
public static final String DATA = "data";
|
||||
|
||||
/** The qualified column identifier for the {@link #data} field. */
|
||||
public static final ColumnExp DATA_C =
|
||||
new ColumnExp(PercentileRecord.class, DATA);
|
||||
public static final Class<PercentileRecord> _R = PercentileRecord.class;
|
||||
public static final ColumnExp GAME_ID = colexp(_R, "gameId");
|
||||
public static final ColumnExp GAME_MODE = colexp(_R, "gameMode");
|
||||
public static final ColumnExp DATA = colexp(_R, "data");
|
||||
// AUTO-GENERATED: FIELDS END
|
||||
|
||||
/** Increment this value to reflect changes to this object's schema. */
|
||||
@@ -79,7 +63,7 @@ public class PercentileRecord extends PersistentRecord
|
||||
{
|
||||
return new Key<PercentileRecord>(
|
||||
PercentileRecord.class,
|
||||
new String[] { GAME_ID, GAME_MODE },
|
||||
new ColumnExp[] { GAME_ID, GAME_MODE },
|
||||
new Comparable[] { gameId, gameMode });
|
||||
}
|
||||
// AUTO-GENERATED: METHODS END
|
||||
|
||||
@@ -33,57 +33,25 @@ import com.samskivert.depot.annotation.Id;
|
||||
import com.samskivert.depot.annotation.Index;
|
||||
import com.samskivert.depot.expression.ColumnExp;
|
||||
|
||||
@Entity(indices={
|
||||
@Index(name="ixPlayerId", fields={ RatingRecord.PLAYER_ID })
|
||||
})
|
||||
@Entity
|
||||
public class RatingRecord extends PersistentRecord
|
||||
{
|
||||
// AUTO-GENERATED: FIELDS START
|
||||
/** The column identifier for the {@link #gameId} field. */
|
||||
public static final String GAME_ID = "gameId";
|
||||
|
||||
/** The qualified column identifier for the {@link #gameId} field. */
|
||||
public static final ColumnExp GAME_ID_C =
|
||||
new ColumnExp(RatingRecord.class, GAME_ID);
|
||||
|
||||
/** The column identifier for the {@link #playerId} field. */
|
||||
public static final String PLAYER_ID = "playerId";
|
||||
|
||||
/** The qualified column identifier for the {@link #playerId} field. */
|
||||
public static final ColumnExp PLAYER_ID_C =
|
||||
new ColumnExp(RatingRecord.class, PLAYER_ID);
|
||||
|
||||
/** The column identifier for the {@link #rating} field. */
|
||||
public static final String RATING = "rating";
|
||||
|
||||
/** The qualified column identifier for the {@link #rating} field. */
|
||||
public static final ColumnExp RATING_C =
|
||||
new ColumnExp(RatingRecord.class, RATING);
|
||||
|
||||
/** The column identifier for the {@link #experience} field. */
|
||||
public static final String EXPERIENCE = "experience";
|
||||
|
||||
/** The qualified column identifier for the {@link #experience} field. */
|
||||
public static final ColumnExp EXPERIENCE_C =
|
||||
new ColumnExp(RatingRecord.class, EXPERIENCE);
|
||||
|
||||
/** The column identifier for the {@link #lastUpdated} field. */
|
||||
public static final String LAST_UPDATED = "lastUpdated";
|
||||
|
||||
/** The qualified column identifier for the {@link #lastUpdated} field. */
|
||||
public static final ColumnExp LAST_UPDATED_C =
|
||||
new ColumnExp(RatingRecord.class, LAST_UPDATED);
|
||||
public static final Class<RatingRecord> _R = RatingRecord.class;
|
||||
public static final ColumnExp GAME_ID = colexp(_R, "gameId");
|
||||
public static final ColumnExp PLAYER_ID = colexp(_R, "playerId");
|
||||
public static final ColumnExp RATING = colexp(_R, "rating");
|
||||
public static final ColumnExp EXPERIENCE = colexp(_R, "experience");
|
||||
public static final ColumnExp LAST_UPDATED = colexp(_R, "lastUpdated");
|
||||
// AUTO-GENERATED: FIELDS END
|
||||
|
||||
public static final int SCHEMA_VERSION = 3;
|
||||
|
||||
/** The identifier of the game we're rating for. */
|
||||
@Id
|
||||
public int gameId;
|
||||
@Id public int gameId;
|
||||
|
||||
/** The identifier of the player we're rating. */
|
||||
@Id
|
||||
public int playerId;
|
||||
@Id @Index public int playerId;
|
||||
|
||||
/** The player's current rating. */
|
||||
public int rating;
|
||||
@@ -132,7 +100,7 @@ public class RatingRecord extends PersistentRecord
|
||||
{
|
||||
return new Key<RatingRecord>(
|
||||
RatingRecord.class,
|
||||
new String[] { GAME_ID, PLAYER_ID },
|
||||
new ColumnExp[] { GAME_ID, PLAYER_ID },
|
||||
new Comparable[] { gameId, playerId });
|
||||
}
|
||||
// AUTO-GENERATED: METHODS END
|
||||
|
||||
@@ -85,8 +85,8 @@ public class RatingRepository extends DepotRepository
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return findAll(RatingRecord.class,
|
||||
new Where(new And(new Equals(RatingRecord.GAME_ID_C, gameId),
|
||||
new In(RatingRecord.PLAYER_ID_C, players))));
|
||||
new Where(new And(new Equals(RatingRecord.GAME_ID, gameId),
|
||||
new In(RatingRecord.PLAYER_ID, players))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,15 +102,15 @@ public class RatingRepository extends DepotRepository
|
||||
ArrayList<QueryClause> clauses = new ArrayList<QueryClause>();
|
||||
if (since > 0L) {
|
||||
Timestamp when = new Timestamp(System.currentTimeMillis() - since);
|
||||
clauses.add(new Where(new And(new Equals(RatingRecord.PLAYER_ID_C, playerId),
|
||||
new GreaterThan(RatingRecord.LAST_UPDATED_C, when))));
|
||||
clauses.add(new Where(new And(new Equals(RatingRecord.PLAYER_ID, playerId),
|
||||
new GreaterThan(RatingRecord.LAST_UPDATED, when))));
|
||||
} else {
|
||||
clauses.add(new Where(RatingRecord.PLAYER_ID_C, playerId));
|
||||
clauses.add(new Where(RatingRecord.PLAYER_ID, playerId));
|
||||
}
|
||||
if (count > 0) {
|
||||
clauses.add(new Limit(0, count));
|
||||
}
|
||||
clauses.add(OrderBy.descending(RatingRecord.LAST_UPDATED_C));
|
||||
clauses.add(OrderBy.descending(RatingRecord.LAST_UPDATED));
|
||||
return findAll(RatingRecord.class, clauses);
|
||||
}
|
||||
|
||||
@@ -126,17 +126,17 @@ public class RatingRepository extends DepotRepository
|
||||
public List<RatingRecord> getTopRatings (int gameId, int limit, long since, IntSet playerIds)
|
||||
{
|
||||
List<SQLExpression> where = Lists.newArrayList();
|
||||
where.add(new Equals(RatingRecord.GAME_ID_C, gameId));
|
||||
where.add(new Equals(RatingRecord.GAME_ID, gameId));
|
||||
if (since > 0L) {
|
||||
where.add(new GreaterThan(RatingRecord.LAST_UPDATED_C,
|
||||
where.add(new GreaterThan(RatingRecord.LAST_UPDATED,
|
||||
new Timestamp(System.currentTimeMillis() - since)));
|
||||
}
|
||||
if (playerIds != null) {
|
||||
where.add(new In(RatingRecord.PLAYER_ID_C, playerIds));
|
||||
where.add(new In(RatingRecord.PLAYER_ID, playerIds));
|
||||
}
|
||||
|
||||
OrderBy ob = new OrderBy(
|
||||
new SQLExpression[] { RatingRecord.RATING_C, RatingRecord.LAST_UPDATED_C },
|
||||
new SQLExpression[] { RatingRecord.RATING, RatingRecord.LAST_UPDATED },
|
||||
new OrderBy.Order[] { OrderBy.Order.DESC, OrderBy.Order.DESC });
|
||||
return findAll(RatingRecord.class, new Where(new And(where)), new Limit(0, limit), ob);
|
||||
}
|
||||
@@ -178,7 +178,7 @@ public class RatingRepository extends DepotRepository
|
||||
{
|
||||
Map<Integer, Percentiler> tilers = Maps.newHashMap();
|
||||
for (PercentileRecord record : findAll(
|
||||
PercentileRecord.class, new Where(PercentileRecord.GAME_ID_C, gameId))) {
|
||||
PercentileRecord.class, new Where(PercentileRecord.GAME_ID, gameId))) {
|
||||
tilers.put(record.gameMode, new Percentiler(record.data));
|
||||
}
|
||||
return tilers;
|
||||
@@ -201,7 +201,7 @@ public class RatingRepository extends DepotRepository
|
||||
*/
|
||||
public void deletePercentiles (int gameId)
|
||||
{
|
||||
deleteAll(PercentileRecord.class, new Where(PercentileRecord.GAME_ID_C, gameId));
|
||||
deleteAll(PercentileRecord.class, new Where(PercentileRecord.GAME_ID, gameId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user