mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 14:31:57 -05:00
Slim down the /organisations response
At the moment this response returns a list of service IDs for hundreds of organisations. The admin app doesn’t use this information, but having to wait for it to be serialized and sent across the network slows it down all the same.
This commit is contained in:
@@ -376,6 +376,12 @@ class Organisation(db.Model):
|
||||
if service.active and not service.restricted
|
||||
]
|
||||
|
||||
@property
|
||||
def domain_list(self):
|
||||
return [
|
||||
domain.domain for domain in self.domains
|
||||
]
|
||||
|
||||
def serialize(self):
|
||||
return {
|
||||
"id": str(self.id),
|
||||
@@ -391,13 +397,20 @@ class Organisation(db.Model):
|
||||
"agreement_signed_on_behalf_of_name": self.agreement_signed_on_behalf_of_name,
|
||||
"agreement_signed_on_behalf_of_email_address": self.agreement_signed_on_behalf_of_email_address,
|
||||
"agreement_signed_version": self.agreement_signed_version,
|
||||
"domains": [
|
||||
domain.domain for domain in self.domains
|
||||
],
|
||||
"domains": self.domain_list,
|
||||
"request_to_go_live_notes": self.request_to_go_live_notes,
|
||||
"count_of_live_services": len(self.live_services),
|
||||
}
|
||||
|
||||
def serialize_for_list(self):
|
||||
return {
|
||||
'name': self.name,
|
||||
'id': str(self.id),
|
||||
'active': self.active,
|
||||
'count_of_live_services': len(self.live_services),
|
||||
'domains': self.domain_list,
|
||||
}
|
||||
|
||||
|
||||
class Service(db.Model, Versioned):
|
||||
__tablename__ = 'services'
|
||||
|
||||
@@ -45,7 +45,7 @@ def handle_integrity_error(exc):
|
||||
@organisation_blueprint.route('', methods=['GET'])
|
||||
def get_organisations():
|
||||
organisations = [
|
||||
org.serialize() for org in dao_get_organisations()
|
||||
org.serialize_for_list() for org in dao_get_organisations()
|
||||
]
|
||||
|
||||
return jsonify(organisations)
|
||||
|
||||
Reference in New Issue
Block a user