View Single Post
  #5   Spotlight this post!  
Unread 31-07-2010, 14:11
Unsung FIRST Hero
Greg Marra Greg Marra is offline
[automate(a) for a in tasks_to_do]
FRC #5507 (Robotic Eagles)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2005
Location: San Francisco, CA
Posts: 2,030
Greg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond reputeGreg Marra has a reputation beyond repute
Re: [TBA]: TBATV v4 Development Log

I am going to change the Match model to be less flexible so we can speed up datastore performance.

I am thinking we will have a Match have Match.teams, which will be a ListProperty that stores the Teams in the match. Separately, we will store Match.alliances, which will contain a dictionary shaped like {"red": ["frc177", "frc195", "frc125"], "blue": ["frc433", "frc190", "frc222"]}. The teams property will basically be an index to let us quickly search by team, and the alliances property will store the actual structure of the alliances.

We'll add another property to Matches called "game", where we write down which FRC game was being played. This way, if they change the game structure in the future (or we get data on past games), we'll easily be able to adjust Controllers to handle it without having to muck with the model.

New concept:
Code:
class Match(db.Model):
    """
    Matches represent individual matches at Events.
    Matches have many Videos.
    key_name is like 2010ct_qm10 or 2010ct_sf1m2
    """
    event = db.ReferenceProperty(Event,
                                 required=True)
    time = db.DateTimeProperty()
    comp_level = db.StringProperty(required=True,choices=set(["Qualifications", "Quarterfinals", "Semifinals", "Finals"])) # This choices set should probably become a global Constant somewhere. How do you do that in Python properly? -greg 5/20/2010
    set_number = db.IntegerProperty(required=True)
    match_number = db.IntegerProperty(required=True)
    teams = db.ListProperty(Team) #Primarily for indexing and searching
    alliances = db.StringProperty #Store a Dictionary as a JSON string
    scores = db.StringProperty #Store a Dictionary as a JSON string
This will reduce the number of Datastore lookups to display a Match (assuming we're not interested in more than the team number) by just under an order of magnitude. I think that's a good thing!

Similarly, by changing from having a bunch of EventTeam objects, we could make teams a ListProperty of an Event. Then to get all of the Teams at an Event would require just finding the Event, instead of finding all of the EventTeams. This is switching away from a many-to-many relationship to many one-to-many relationships.

I haven't had much time to work on development, but I think these new ideas will remove some of the major roadblocks that existed.
Reply With Quote