Repository: internetarchive/openlibrary

Issue:
Show 10 authors on /authors search page
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

If one goes to https://openlibrary.org/authors without a search result, it is a ghost town.

After the search box and above all the "merge" text (which should probably be moved **off** this page **into** our librarian docs, cc: @seabelis) let's see if we can show a few example authors.

### Describe the problem that you'd like solved
<!-- A clear and concise description of what you want to happen. -->

Make our authors page more useful and friendly.

### Proposal & Constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->

We already have the ability to query for authors (because that's already what is happening when we do an author search!). We can use this same back-end logic to show authors by default.

<!-- Which suggestions or requirements should be considered for how feature needs to appear or be implemented? -->

- recently added authors?
- authors with most books? Can we query for this? @cdrini 
- authors with **new** works? i.e. do we have a "last updated" for authors? And does that get updated when a work is added/associated w/ an author?

### Stakeholders
<!-- @ tag stakeholders of this bug -->
@cdrini , @seabelis 




Discussion:
Given that you only want a handful, it seems like the easiest approach would be to curate a short, appropriately multicultural list of classic authors, e.g. Plato, Dostoevsky, etc.

If you wanted to include more modern authors, but likely with a Western bias, you could use something like https://en.wikipedia.org/wiki/List_of_most_translated_individual_authors
which is based on http://www.unesco.org/xtrans/bsstatexp.aspx?crit1L=5&nTyp=min&topN=100

Other comments inline below:

> the "merge" text (which should probably be moved **off** this page **into** our librarian docs, cc: @seabelis)

Yes, definitely. Where ever it moves to, it should be updated to account for the current state of search not working, etc.

> * recently added authors?

No. Subject to spam and, for the most part, much less interesting than the millions of authors we have already.

> * authors with most books? 
*Maybe*, but with a pretty big blacklist to get rid of Various, the U.S. Government, and the "authors" of machine generated books like https://openlibrary.org/search/authors?q=philip

> Can we query for this?

Yes, the current author queries return results in descending order by work count.

> * authors with **new** works? i.e. do we have a "last updated" for authors? And does that get updated when a work is added/associated w/ an author?

Author records do have a last modified time, but authors are added to works, not the other way around, so the author record isn't updated.

Well the [subjects page](https://openlibrary.org/subjects) has 12 genres, and I was thinking the top author (as in most books) in each one.
I've added the text to the editing FAQs. I've removed this line,

> When adding authors include as little information as possible that identify the author while keeping them distinguishable from other authors.

because it does not seem to make much sense.
Hi @mekarpeles, I wanted to confirm by what you meant by this...
> If one goes to https://openlibrary.org/authors without a search result, it is a ghost town.

Is it 
1.) user clicks the Search button without specifying a search keyword 
or
2.) user specifies a keyword that yields 0 search result ?

There was an idea floating around that we should create a carousel with the most popular authors this month. Perhaps this would be a good place to have such a carousel
@srosalia my impression is that when people go on that page without any idea of what to search in mind, there's only a description. There's no list of authors to browse. However, you're right - when a user clicks the search button, nothing pops up and there are many keywords with 0 search results (but that would be a different issue).
@bluedaze it depends on what format is consistent with which webpage. So:
https://openlibrary.org/authors - is fine to have a carousel (maybe it's combined with a list?)
https://openlibrary.org/search/authors (from clicking the word 'find') - a list would be better
https://openlibrary.org/search/authors?q= (from clicking the search button) - list format preferred
> Hi @mekarpeles, I wanted to confirm by what you meant by this...
> 
> > If one goes to https://openlibrary.org/authors without a search result, it is a ghost town.
> 
> Is it
> 1.) user clicks the Search button without specifying a search keyword
> or
> 2.) user specifies a keyword that yields 0 search result ?

Yes, though we likely want to show suggested results even before a search is made (e.g. on the https://openlibrary.org/authors and https://openlibrary.org/search/authors page(s))
Hey, @mekarpeles ! 
How about displaying the 'most searched' authors by default even before a search is made? 
Is there an api/query for most searched authors or most popular authors this month so that we can get data of authors?
If not we can hardcode our suggestion under the search option with an option "Famous Authors" or "Popular Author" with a famous author of all the 12 genre 
I am thinking of creating a card in which there will be data as follow

``` 
Plato 
427 BCE - 348 BCE
Some MetaData about the author 
Genre 
```

We can use a carousel as well but I think this card will look good for this case 
what do you think @mekarpeles @jamesachamp 
I think that the card idea may be best for now.  It's probably best to use the data that we can currently get for authors today for the card.  Be mindful that some attributes may not exist for an author.  You can look at the template for the [author search results](https://github.com/internetarchive/openlibrary/blob/master/openlibrary/templates/search/authors.html) as an example of how this is handled today.
I don't think that we currently have a most searched or most popular author query today, but I could be wrong.  I can tell you that author search is handled in `openlibrary/plugins/worksearch/code.py`.  Maybe there's something in that file that I missed...
Okay so I am starting to create the cards for now, I will hardcode the information
After the pull request, we can think about how to get information about the authors  
@jamesachamp please check this


![authors](https://user-images.githubusercontent.com/43555219/97001721-7b9a1b80-1556-11eb-868c-252f3ff29660.JPG)

For now, I have hardcoded all the data 
I was thinking of creating a JSON file in which there are 12 famous authors and by that JSON we can create the component 
This can be a temporary add on till there is no API or query for most famous authors 
What's your idea on this 

and the cards are responsive as well
I'm not sure how well this would work for authors that have longer names.  Also, the amount of data returned for any given author will vary greatly.  It may look odd if a card with a lot of details is next to a card with few details.  Maybe a single column of wide cards would be better?
I'm not quite sure what to tell you about where to source the data.  If it is hard-coded, I think that the list of authors should be curated by the community.  I'll try to make some time soon to research what it would take to create some of the queries mentioned in this tread.
For the details, we can show data up to 100 words and append "..." or "read more" and then make the card clickable that will lead to author profiles 
and for the author name, we can make "font-size:100%" and 300 px width of one card(Right now in the image it is 200px)
And for the data, I was looking for creating an API yesterday and right now as well, I don't know if there is any query which tells us about how many times an author book has been red by users 
For now, I was thinking of creating a query that will find 12 authors with the most books published, but right now I am not sure about it 

There may be some data issues with a query that returns authors with the most books published.  For example, I think that all works with unknown authors are attributed to an author named "Unknown".  I suspect that this would show up in the results, creating an undesirable experience for patrons.
I did just put together a function that will return a JSON string containing a given number of authors, or 10 by default.  It will have to pass review before it can be merged and used, though.  I've listed you as a stakeholder so that you can track the progress of the PR.
In the meantime, you can prepare the cards to accept JSON author data.  You can use the [author search results](https://github.com/internetarchive/openlibrary/blob/master/openlibrary/templates/search/authors.html) file that I mentioned earlier as a model.  The data returned by the new function will have the same structure as the author data used in that file.
> Hey, @mekarpeles !
> How about displaying the 'most searched' authors by default even before a search is made?

This may be challenging information for us to get (unless, I guess, we could use google analytics API, which feels a little bit like a hack?)
I'm noting we don't currently have an assignee for this issue -- is there anyone working on this or who would like to work on this? Anything is probably better than what we have :D
@mekarpeles I would like to work on this.
I was working on this issue long ago @mekarpeles 
And as I say in the past that the data can be hard coded for famous authors of all time as a json file 
But we might need a librarian input on the most famous authors for top 12 authors 

A idea to think , we can create a carousal for this as well and as the author page is empty this can be a good way to check how the carousal will look with the website 

@Sabreen-Parveen I have worked on this issue before, so if it's okay I would like to work on this issue :D 
@ArunTeltia sure you can go for it..
For choosing the authors, can we create a poll and get input from the users themselves for the author whom they like the most? In this way we can involve the users as well. 
I just checked the random author pr by @jamesachamp I will work on this pr with the random authors
Sorry about the delay, I somehow miss this pr :P 

@Sabreen-Parveen the random authors would be great to allocate the data for the author page
@ArunTeltia Are you currently working on this issue? If not, can I proceed with this?
Hi all, I don't see anyone currently assigned to this issue, so if you'd like to proceed, feel free to try opening a **draft** PR.

Whatever solution we come up with will need to go through a community review (e.g. get feedback on one of our Tuesday community calls) and ultimately get cleared by staff, so I'd try not to invest too much time before getting feedback.

@Sabreen-Parveen was the first to offer, so I'm happy to assign accordingly if there's still interest :)
@mekarpeles thanks for warning us

Resolving patch:
diff --git a/openlibrary/plugins/worksearch/code.py b/openlibrary/plugins/worksearch/code.py
--- a/openlibrary/plugins/worksearch/code.py
+++ b/openlibrary/plugins/worksearch/code.py
@@ -964,7 +964,7 @@ def GET(self):
 @public
 def random_author_search(limit=10):
     """
-    Returns a JSON string that contains a random list of authors.  Amount of authors
+    Returns a dict that contains a random list of authors.  Amount of authors
     returned is set be the given limit.
     """
     letters_and_digits = string.ascii_letters + string.digits
@@ -987,7 +987,7 @@ def random_author_search(limit=10):
         # The template still expects the key to be in the old format
         doc['key'] = doc['key'].split("/")[-1]
 
-    return json.dumps(search_results['response'])
+    return search_results['response']
 
 
 def rewrite_list_editions_query(q, page, offset, limit):


Test patch: