@@ -64,6 +64,7 @@ class CncMap(GameScopedUserOwnedModel, Moderabile):
6464 is_legacy = models .BooleanField (
6565 default = False ,
6666 help_text = "If true, this is an upload from the old cncnet database." ,
67+ db_index = True ,
6768 )
6869 """:attr:
6970 This will be set for all maps that we bulk upload from the legacy cncnet map database.
@@ -78,8 +79,7 @@ class CncMap(GameScopedUserOwnedModel, Moderabile):
7879 """:attr: Tracks the original upload dates for legacy maps, for historical reasons."""
7980
8081 is_published = models .BooleanField (
81- default = False ,
82- help_text = "If true, this map will show up in normal searches and feeds." ,
82+ default = False , help_text = "If true, this map will show up in normal searches and feeds." , db_index = True
8383 )
8484 """:attr:
8585 Did the map maker set this map to be published? Published maps show up in normal search and feeds.
@@ -90,6 +90,7 @@ class CncMap(GameScopedUserOwnedModel, Moderabile):
9090 default = False ,
9191 help_text = "If true, this will be deleted eventually. "
9292 "This flag is to support sharing in multiplayer lobbies." ,
93+ db_index = True ,
9394 )
9495 """:attr:
9596 Whether this map is temporary. We don't want to keep storing every map that is shared in a multiplayer lobby,
@@ -105,15 +106,10 @@ class CncMap(GameScopedUserOwnedModel, Moderabile):
105106 )
106107
107108 categories = models .ManyToManyField (MapCategory )
108- parent = models .ForeignKey (
109- "CncMap" ,
110- on_delete = models .SET_NULL ,
111- null = True ,
112- blank = True ,
113- )
109+ parent = models .ForeignKey ("CncMap" , on_delete = models .SET_NULL , null = True , blank = True , db_index = True )
114110 """If set, then this map is a child of ``parent``. Used to track edits of other peoples' maps."""
115111
116- is_mapdb1_compatible = models .BooleanField (default = False )
112+ is_mapdb1_compatible = models .BooleanField (default = False , db_index = True )
117113 """If true, then this map was uploaded by a legacy CnCNet client and is backwards compatible with map db 1.0.
118114
119115 This should never be set for maps uploaded via the web UI.
@@ -182,7 +178,7 @@ class CncMapFile(file_base.CncNetFileBaseModel):
182178 height = models .IntegerField ()
183179 version = models .IntegerField (editable = False )
184180
185- cnc_map = models .ForeignKey (CncMap , on_delete = models .CASCADE , null = False )
181+ cnc_map = models .ForeignKey (CncMap , on_delete = models .CASCADE , null = False , db_index = True )
186182
187183 ALLOWED_EXTENSION_TYPES = {game_models .CncFileExtension .ExtensionTypes .MAP .value }
188184
@@ -192,7 +188,6 @@ class Meta:
192188 constraints = [
193189 models .UniqueConstraint (fields = ["cnc_map_id" , "version" ], name = "unique_map_version" ),
194190 ]
195- indexes = [models .Index (fields = ["cnc_map" ])]
196191
197192 def save (self , * args , ** kwargs ):
198193 if not self .version :
@@ -234,7 +229,7 @@ class CncMapImageFile(file_base.CncNetFileBaseModel):
234229 width = models .IntegerField ()
235230 height = models .IntegerField ()
236231
237- cnc_map = models .ForeignKey (CncMap , on_delete = models .CASCADE , null = False )
232+ cnc_map = models .ForeignKey (CncMap , on_delete = models .CASCADE , null = False , db_index = True )
238233
239234 ALLOWED_EXTENSION_TYPES = {game_models .CncFileExtension .ExtensionTypes .IMAGE .value }
240235
@@ -243,7 +238,7 @@ class CncMapImageFile(file_base.CncNetFileBaseModel):
243238 file = models .ImageField (null = False , upload_to = file_base .default_generate_upload_to , max_length = 2048 )
244239 """The actual file this object represent."""
245240
246- is_extracted = models .BooleanField (null = False , blank = False , default = False )
241+ is_extracted = models .BooleanField (null = False , blank = False , default = False , db_index = True )
247242 """attr: If true, then this image was extracted from the uploaded map file, usually generated by FinalAlert.
248243
249244 This will always be false for games released after Yuri's Revenge because Generals and beyond do not pack the
@@ -257,14 +252,6 @@ class CncMapImageFile(file_base.CncNetFileBaseModel):
257252 If there are ``order`` collisions, then we fallback to the creation date.
258253 """
259254
260- class Meta :
261- indexes = [
262- models .Index (fields = ["cnc_map" ]),
263- models .Index (fields = ["is_extracted" ]),
264- models .Index (fields = ["cnc_user_id" ]),
265- models .Index (fields = ["cnc_game_id" ]),
266- ]
267-
268255 def save (self , * args , ** kwargs ):
269256 if not self .name :
270257 self .name = self .cnc_map .map_name
0 commit comments