aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/views/staff/jams/teams/view.py
diff options
context:
space:
mode:
authorGravatar Gareth Coles <[email protected]>2018-06-23 19:00:07 +0000
committerGravatar Gareth Coles <[email protected]>2018-06-23 19:00:07 +0000
commit90b9ebfe6b59a69e9783259a70e7927d989604f8 (patch)
treea6b796051cb7b7811ce8528b2b4501278422591e /pysite/views/staff/jams/teams/view.py
parentUpdate Font-Awesome Pro to 5.1.0 (diff)
parentAdd some documentation to the team_edit_repo route (diff)
Merge branch 'teams-user-frontend' into 'master'
User frontend for teams See merge request python-discord/projects/site!9
Diffstat (limited to 'pysite/views/staff/jams/teams/view.py')
-rw-r--r--pysite/views/staff/jams/teams/view.py14
1 files changed, 3 insertions, 11 deletions
diff --git a/pysite/views/staff/jams/teams/view.py b/pysite/views/staff/jams/teams/view.py
index 6b30f9a2..662cc084 100644
--- a/pysite/views/staff/jams/teams/view.py
+++ b/pysite/views/staff/jams/teams/view.py
@@ -61,18 +61,10 @@ class StaffView(RouteView, DBMixin):
.coerce_to("array"), # Coerce the document stream into an array
"form": self.db.query(self.forms_table).get(jam), # Just get the correct form object
"teams":
- # Query the teams table
self.db.query(self.table_name)
- # Join the teams table against the jams table, to find all of the teams for this
- # specific jam - we can't simply filter because of the one-to-many relationship,
- # so we must use an inner join with a predicate function. This function is still
- # run on the server, however
- .inner_join(self.db.query(self.jams_table),
- lambda team_row, jams_row: jams_row["teams"].contains(team_row["id"]))
- # Only take the ID, name and members of each team, discard everything else
- .pluck({"left": ["id", "name", "members"]})
- .zip() # Combine the left and right documents together
- .coerce_to("array") # Coerce the document stream into an array
+ .filter(lambda team_row: jam_obj["teams"].contains(team_row["id"]))
+ .pluck(["id", "name", "members"])
+ .coerce_to("array")
}
)