Forked from ashaegupta/get_matches_for_status_matched
Created
October 19, 2011 02:13
-
-
Save shreyansb/1297323 to your computer and use it in GitHub Desktop.
Way to improve this
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@classmethod | |
def get_matches_for_status_matched(klass, ride_doc): | |
ride=[] | |
# first ensure status is matched | |
if ride_doc.get(Ride.A_STATUS) != 2: return ride | |
# get the match ride and user info | |
match_ride_id = ride_doc.get(Ride.A_MATCH_ID) | |
if not match_ride_id: return ride | |
match_ride = klass.get_ride(match_ride_id) | |
if not match_ride: return ride | |
user_id = match_ride_id.get(klass.A_USER_ID) | |
if not user_id: return ride | |
user_doc = UserHelper.get_users_by_id(user_id) | |
if not user_doc: return ride | |
# link the | |
if user_doc: | |
match_ride["user"]=user_doc | |
ride = match_ride | |
return ride |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is one quick improvement - less nested.
Each time you do 'return ride', you could instead raise a specific error if you wanted to (later)