Skip to content

Commit ab33184

Browse files
committed
Caching Layer
1 parent de5a560 commit ab33184

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

conditional/util/ldap.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def __ldap_remove_member_from_group__(username, group):
119119
ldap_conn.modify_s(groupdn, ldap_modlist)
120120

121121

122-
# @ldap_init_required
122+
@ldap_init_required
123123
def __ldap_is_member_of_committee__(username, committee):
124124
ldap_results = ldap_conn.search_s(committee_search_ou, ldap.SCOPE_SUBTREE,
125125
"(cn=%s)" % committee)
@@ -130,51 +130,49 @@ def __ldap_is_member_of_committee__(username, committee):
130130
[x.decode('ascii') for x in ldap_results[0][1]['head']]
131131

132132

133-
# @lru_cache(maxsize=1024)
133+
@lru_cache(maxsize=1024)
134134
def ldap_get_housing_points(username):
135135
return int(__ldap_get_field__(username, 'housingPoints'))
136136

137137

138-
# @lru_cache(maxsize=1024)
139138
def ldap_get_room_number(username):
140139
roomno = __ldap_get_field__(username, 'roomNumber')
141140
if roomno is None:
142141
return "N/A"
143142
return roomno.decode('utf-8')
144143

145144

146-
# @lru_cache(maxsize=1024)
145+
@lru_cache(maxsize=1024)
147146
def ldap_get_active_members():
148147
return [x for x in ldap_get_current_students()
149148
if ldap_is_active(x['uid'][0].decode('utf-8'))]
150149

151150

152-
# @lru_cache(maxsize=1024)
151+
@lru_cache(maxsize=1024)
153152
def ldap_get_intro_members():
154153
return [x for x in ldap_get_current_students()
155154
if ldap_is_intromember(x['uid'][0].decode('utf-8'))]
156155

157156

158-
# @lru_cache(maxsize=1024)
157+
@lru_cache(maxsize=1024)
159158
def ldap_get_non_alumni_members():
160159
return [x for x in ldap_get_current_students()
161160
if ldap_is_alumni(x['uid'][0].decode('utf-8'))]
162161

163162

164-
# @lru_cache(maxsize=1024)
163+
@lru_cache(maxsize=1024)
165164
def ldap_get_onfloor_members():
166165
return [x for x in ldap_get_current_students()
167166
if ldap_is_onfloor(x['uid'][0].decode('utf-8'))]
168167

169168

170-
# @lru_cache(maxsize=1024)
169+
@lru_cache(maxsize=1024)
171170
def ldap_get_current_students():
172171
return [x[1]
173172
for x in __ldap_get_members__()[1:]
174173
if ldap_is_current_student(str(str(x[0]).split(",")[0]).split("=")[1])]
175174

176175

177-
# @lru_cache(maxsize=1024)
178176
def ldap_is_active(username):
179177
return __ldap_is_member_of_group__(username, 'active')
180178

0 commit comments

Comments
 (0)