tuna42na / baby-namr

Baby Naming Application Frontend
0 stars 1 forks source link

View a name's popularity over time #5

Closed trvslhlt closed 3 years ago

trvslhlt commented 3 years ago

In addition to comparing the popularity of names within a date range, we would also like to show users the popularity of single names over time.

cwkarwisch commented 3 years ago

For the api here, I think we should use the '/names?name=Nathaniel&sex=M' format as an example. The response to this request would be JSON containing records for every year in which Nathaniel was in the top 1000 male names (otherwise there won't be an entry in the database for that year when a name falls below the top 1,000 for the sex in that year).

@tuna42na does that api work for you?

cwkarwisch commented 3 years ago

I added the change to the api to allow retrieval of a names popularity over time in the same PR where the year-range functionality was added. The PR is here for reference.

@tuna42na Let me know if this format works for how you want to handle it on the frontend. If you make a request for /names?name=Nathaniel&sex=M you'll get data starting with:

{"id":1147,"name":"Nathaniel","sex":"M","count":60,"popularity":205,"year":1880,"country":"U.S.A.","created_at":"2021-02-19T02:55:59.026Z","updated_at":"2021-02-19T02:55:59.026Z"}

and ending with:

{"id":279000,"name":"Nathaniel","sex":"M","count":3072,"popularity":123,"year":2019,"country":"U.S.A.","created_at":"2021-02-19T02:57:41.863Z","updated_at":"2021-02-19T02:57:41.863Z"}