Repository: internetarchive/openlibrary

Issue:
Lists should follow redirects when rendering
### Evidence

![image](https://user-images.githubusercontent.com/6251786/107540363-f9c90f00-6b93-11eb-9250-bc181effe536.png)

### Relevant url?
e.g. https://openlibrary.org/people/seabelis/lists/OL140479L/Duplicate_Work?page=16 (at the bottom)

<!-- What actually happened after these steps? What did you expect to happen? -->
* Actual: Redirects appear broken
* Expected: Redirects should be followed, and appear as normal books

### Details

- **Logged in (Y/N)?** Y
- **Browser type/version?** FF85
- **Operating system?** Win10
- **Environment (prod/dev/local)?** prod
<!-- If not sure, put prod -->

### Proposal & Constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->

### Related files
<!-- Files related to this issue; this is super useful for new contributors who might want to help! If you're not sure, leave this blank; a maintainer will add them. -->

### Stakeholders
@seabelis 


Discussion:

Resolving patch:
diff --git a/openlibrary/core/lists/model.py b/openlibrary/core/lists/model.py
--- a/openlibrary/core/lists/model.py
+++ b/openlibrary/core/lists/model.py
@@ -119,7 +119,7 @@ def get_editions(self, limit=50, offset=0, _raw=False):
     def get_all_editions(self):
         """Returns all the editions of this list in arbitrary order.
 
-        The return value is an iterator over all the edtions. Each entry is a dictionary.
+        The return value is an iterator over all the editions. Each entry is a dictionary.
         (Compare the difference with get_editions.)
 
         This works even for lists with too many seeds as it doesn't try to
@@ -266,10 +266,19 @@ def get_subject_type(s):
                 d[kind].append(s)
         return d
 
-    def get_seeds(self, sort=False):
-        seeds = [Seed(self, s) for s in self.seeds]
+    def get_seeds(self, sort=False, resolve_redirects=False):
+        seeds = []
+        for s in self.seeds:
+            seed = Seed(self, s)
+            max_checks = 10
+            while resolve_redirects and seed.type == 'redirect' and max_checks:
+                seed = Seed(self, web.ctx.site.get(seed.document.location))
+                max_checks -= 1
+            seeds.append(seed)
+
         if sort:
             seeds = h.safesort(seeds, reverse=True, key=lambda seed: seed.last_update)
+
         return seeds
 
     def get_seed(self, seed):
@@ -358,35 +367,9 @@ def get_solrdata(self):
         return self._solrdata
 
     def _load_solrdata(self):
-        if self.type == "edition":
-            return {
-                'ebook_count': int(bool(self.document.ocaid)),
-                'edition_count': 1,
-                'work_count': 1,
-                'last_update': self.document.last_modified
-            }
-        else:
-            q = self.get_solr_query_term()
-            if q:
-                solr = get_solr()
-                result = solr.select(q, fields=["edition_count", "ebook_count_i"])
-                last_update_i = [doc['last_update_i'] for doc in result.docs if 'last_update_i' in doc]
-                if last_update_i:
-                    last_update = self._inttime_to_datetime(last_update_i)
-                else:
-                    # if last_update is not present in solr, consider last_modfied of
-                    # that document as last_update
-                    if self.type in ['work', 'author']:
-                        last_update = self.document.last_modified
-                    else:
-                        last_update = None
-                return {
-                    'ebook_count': sum(doc.get('ebook_count_i', 0) for doc in result.docs),
-                    'edition_count': sum(doc.get('edition_count', 0) for doc in result.docs),
-                    'work_count': result.num_found,
-                    'last_update': last_update
-                }
-        return {}
+        return {
+            'last_update': self.document.get('last_modified')
+        }
 
     def _inttime_to_datetime(self, t):
         return datetime.datetime(*time.gmtime(t)[:6])
@@ -402,6 +385,8 @@ def get_type(self):
             return "work"
         elif type == "/type/author":
             return "author"
+        elif type == "/type/redirect":
+            return "redirect"
         else:
             return "unknown"
 


Test patch: