Skip to content

Instantly share code, notes, and snippets.

@IsaacRay
Created May 5, 2015 19:36
Show Gist options
  • Select an option

  • Save IsaacRay/620309f7b41039b0b607 to your computer and use it in GitHub Desktop.

Select an option

Save IsaacRay/620309f7b41039b0b607 to your computer and use it in GitHub Desktop.
JANUS-4677/B-02578
diff --git a/medley/grids/models.py b/medley/grids/models.py
index f24ce55..a30e147 100644
--- a/medley/grids/models.py
+++ b/medley/grids/models.py
@@ -992,7 +992,8 @@ class Slot(models.Model):
# NB This should hit the cache populated by a prior
# call to Layout.fetch_content_object_results()
results = get_results_by_guid(
- get_guid_uri(self.content_object)
+ get_guid_uri(self.content_object),
+ count=100 # FOR TIMELINES
)
else:
# List cast in case the content_object is list like, otherwise make a single item list
diff --git a/medley/medley_lists/util.py b/medley/medley_lists/util.py
index f260230..3112f9c 100644
--- a/medley/medley_lists/util.py
+++ b/medley/medley_lists/util.py
@@ -187,7 +187,7 @@ def dedupe_by_slug(entities):
return results
-def get_batch_results(guids):
+def get_batch_results(guids, count=None):
""" Makes a single request to melvil for multiple guids at once.
It takes a list of of guids, and returns a dict (guid, results).
returned dict can be empty if an error occurs
@@ -230,6 +230,8 @@ def get_batch_results(guids):
# 'OR' query of all the guids not fetched from cache
query = reduce(MQ.__or__, [MQ(guid=g) for g in missed_guids])
+ if count:
+ query.count(count)
try:
response = client.filter(query).response()
except MelvilClientException:
@@ -311,12 +313,12 @@ def get_batch_results(guids):
return results
-def get_results_by_guid(guid):
+def get_results_by_guid(guid, count=None):
"""Makes a Melvil request by GUID for a single object.
Returns a List of ContentObjects - the items in the list
"""
# get_batch_results Returns dict(guid=[ContentObject, ..])
- results = get_batch_results([guid])
+ results = get_batch_results([guid], count=count)
# In dev things might not be indexed - Error would have been logged above
return results.get(guid, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment