-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added missing fields to Person and CourseRun Search API #94
base: develop-koa
Are you sure you want to change the base?
Conversation
return [{ | ||
'id': area_of_expertise.id, | ||
'value': area_of_expertise.value, | ||
} for area_of_expertise in sorted(result.object.areas_of_expertise.all(), key=attrgetter('id'))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can break this logic. Maybe into multiple lines for better understanding. One possible sol. can be. Better to order_by it, if it's a DB query.
areas = result.object.areas_of_expertise.all()
sorted_areas = sorted(areas, key=attrgetter('id'))
return [{'id': area.id, 'value': area.value} for area in sorted_areas]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to sort here?
given_name = indexes.CharField(model_attr='given_name') | ||
family_name = indexes.CharField(model_attr='family_name', null=True) | ||
slug = indexes.CharField(model_attr='slug') | ||
email = indexes.CharField(model_attr='email', null=True) | ||
major_works = indexes.CharField(model_attr='major_works', null=True) | ||
published = indexes.BooleanField(model_attr='published') | ||
phone_number = indexes.CharField(model_attr='phone_number', null=True) | ||
website = indexes.CharField(model_attr='website', null=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this not require a migration file?
if social_networks: | ||
return social_networks[0].url | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it's better to use it the other way around. Deal with failure flow first in the code and return the happy at last. e.g
if not len(social_networks):
return None
def get_urls_detailed(self, result): | ||
return [{ | ||
'id': network.id, | ||
'type': network.type, | ||
'title': network.title, | ||
'display_title': network.display_title, | ||
'url': network.url, | ||
} for network in sorted(result.object.person_networks.all(), key=attrgetter('id'))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, We can break the logic here.
} for area_of_expertise in sorted(result.object.areas_of_expertise.all(), key=attrgetter('id'))] | ||
|
||
def get_social_network_url(self, url_type, obj): | ||
social_networks = [network for network in obj.person_networks.all() if network.type == url_type] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this querying database? Can't we filter in that case?
This PR adds the following missing fields in the
course_runs
andpeople
search apis.course_run:
people:
Testing details:
Curl the following api endpoints to verify the changes
course_run:
people: