Update recommend endpoint and validation.

get_recommendations was recently changed to accept id36s instead of subreddit
objects for the omit list. This change updates the recommender api endpoint
to match. It also makes the VSRByNames() validator return an empty dict in
case of error so it's safe to call .values() on the result.

Note: Fixes the broken "more suggestions" link in multi recommendations.
This commit is contained in:
shlurbee
2013-12-06 08:40:30 -08:00
parent d847228dca
commit aae622d56e
3 changed files with 4 additions and 5 deletions

View File

@@ -3694,8 +3694,9 @@ class ApiController(RedditController, OAuth2ResourceController):
that appear in the optional `omit` param.
"""
omit_id36s = [sr._id36 for sr in to_omit.values()]
rec_srs = recommender.get_recommendations(srs.values(),
to_omit=to_omit.values())
to_omit=omit_id36s)
sr_data = [{'sr_name': sr.name} for sr in rec_srs]
return json.dumps(sr_data)

View File

@@ -63,7 +63,7 @@ def get_recommendations(srs,
- srs is one Subreddit object or a list of Subreddits
- count is total number of results to return
- source is a prefix telling which set of recommendations to use
- to_omit is one Subreddit object or a list of Subreddits that should not
- to_omit is a single or list of subreddit id36s that should not be
be included. (Useful for omitting recs that were already rejected.)
- match_set=True will return recs that are similar to each other, useful
for matching the "theme" of the original set

View File

@@ -718,9 +718,7 @@ class VSRByNames(Validator):
return Subreddit._by_name(sr_names)
elif self.required:
self.set_error(errors.BAD_SR_NAME, code=400)
return
else:
return {}
return {}
def param_docs(self):
return {