From afa31fb8b65805f92145182647684b199bb67758 Mon Sep 17 00:00:00 2001 From: Colin McDonald Date: Fri, 27 May 2016 16:34:18 -0400 Subject: [PATCH] Add better indexes on ipLog and punishments --- .../java/net/frozenorb/apiv3/models/IPLogEntry.java | 10 +++++++--- .../java/net/frozenorb/apiv3/models/Punishment.java | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/frozenorb/apiv3/models/IPLogEntry.java b/src/main/java/net/frozenorb/apiv3/models/IPLogEntry.java index 8349702..0e77799 100644 --- a/src/main/java/net/frozenorb/apiv3/models/IPLogEntry.java +++ b/src/main/java/net/frozenorb/apiv3/models/IPLogEntry.java @@ -4,15 +4,19 @@ import lombok.AllArgsConstructor; import lombok.Getter; import net.frozenorb.apiv3.APIv3; import org.bson.types.ObjectId; -import org.mongodb.morphia.annotations.Entity; -import org.mongodb.morphia.annotations.Id; -import org.mongodb.morphia.annotations.Indexed; +import org.mongodb.morphia.annotations.*; import java.util.Date; import java.util.UUID; @Entity(value = "ipLog", noClassnameStored = true) @AllArgsConstructor +@Indexes( + @Index(fields = { + @Field("user"), + @Field("userIp") + }) +) public final class IPLogEntry { @Getter @Id private String id; diff --git a/src/main/java/net/frozenorb/apiv3/models/Punishment.java b/src/main/java/net/frozenorb/apiv3/models/Punishment.java index 79c109f..5225190 100644 --- a/src/main/java/net/frozenorb/apiv3/models/Punishment.java +++ b/src/main/java/net/frozenorb/apiv3/models/Punishment.java @@ -7,9 +7,7 @@ import net.frozenorb.apiv3.actors.Actor; import net.frozenorb.apiv3.actors.ActorType; import net.frozenorb.apiv3.utils.TimeUtils; import org.bson.types.ObjectId; -import org.mongodb.morphia.annotations.Entity; -import org.mongodb.morphia.annotations.Id; -import org.mongodb.morphia.annotations.Indexed; +import org.mongodb.morphia.annotations.*; import java.util.Date; import java.util.Map; @@ -17,6 +15,12 @@ import java.util.UUID; @Entity(value = "punishments", noClassnameStored = true) @AllArgsConstructor +@Indexes( + @Index(fields = { + @Field("user"), + @Field("type") + }) +) public final class Punishment { @Getter @Id private String id;