newtheatre / history-project

:scroll: Historical record of happenings at the Nottingham New Theatre.
https://history.newtheatre.org.uk
MIT License
18 stars 14 forks source link

Feature: 6 Degrees Of The New Theatre #985

Open GingertronMk1 opened 7 years ago

GingertronMk1 commented 7 years ago

So I've spent the last few weeks putting together a "6 degrees of Kevin Bacon" type thing for actors at the NNT (in the history site's records), available here, and I think it'd be a cool addition to the history site.

wjdp commented 7 years ago

Can you post an example of output? (I don't have Haskell installed 😄)

GingertronMk1 commented 7 years ago
System-X | jack | Mon Nov 06, 14:12 | ~/Git/sixDegsNNT/
╚> ./6degs 
Jack Ellis
Fran Roper
Jack Ellis and Fran Roper are linked as follows:
- Jack Ellis was in When The Lights Come Up with Mitchell Masterson
- Mitchell Masterson was in Robin Hood with James McAndrew
- James McAndrew was in Flare Path with Peter Cary
- Peter Cary was in The Pillowman with John Franklin
- John Franklin was in Stars in Their Eyes with Sam  Morris
- Sam  Morris was in Popcorn with Fran Roper

They have 6 degrees of separation.

That's it printing prettily; at a basic level it returns a tuple containing a list of actors and the degree of separation, so in this case it would return (["Jack Ellis","Mitchell Masterson","James McAndrew","Peter Cary","John Franklin","Sam Morris","Fran Roper"],6)

wjdp commented 7 years ago

OK, this is pretty cool! 👏

What you need to think about is how to deliver this on a static website:

How do we want to show this data? From one person page do you just select another person and it pops up?

Assuming we AJAX fetch something f(Person A, Person B)

GingertronMk1 commented 7 years ago

I'd back AWS Lambda, just cos I know based on some very shaky maths that there's about 200000 possible combinations of all actors, so anything particularly file-based will be a complete PITA

wjdp commented 7 years ago

Also looking over the code it looks like you're doing string matching and wrangling to get show and people names. It'd be better off getting the site to dump a json file which you just read in.

Doing the lambda function route it could just grab that data over HTTP from the live site.

GingertronMk1 commented 7 years ago

Yeah, it's using lots of string matching stuff but that's just cos it pulls directly from the info in the history repo; I've managed to work it now so the gathering show information is done at the beginning, so really isn't a limiting factor at this point

wjdp commented 7 years ago

The point is you won't have access to the repo when running in lambda. You're going to need some access to the data, and preferably a more reliable form than wrangling text out of YAML files.

wjdp commented 7 years ago

If we do a JSON endpoint we can guarantee the syntax won't change and break the function.

GingertronMk1 commented 7 years ago

A lot of this stuff is totally new to me, so I'll defer to your knowledge on this

wjdp commented 7 years ago

No worries 😄

wjdp commented 7 years ago

I have next to zero experience with haskell, but if this is to be a microservice separate from the main repo that is no issue at all.

Things to do:

  1. Make a JSON endpoint on the history project side (preferably in Ruby, rather than a hacky liquid one)
  2. Make your function use the JSON hosted on history.newtheatre.org.uk
  3. Get your function running on Lambda

Have a go trying to get this running on lambda (don't know if you used it before), while it is a fantastic service it is a huge PITA to get started with anything more complex than 'Hello World'. It seems you can run haskell on lambda by providing a binary and some shared library (very cursory Google).

I can help with everything other than the haskell. Let me know what you need 😄

GingertronMk1 commented 7 years ago

As long as the JSON can be read to give a list of shows and the actors in them (basically the Detail data type in the code) the Haskell should run fine; dunno my way around Lambda though so that'll be fun.

If you fancy dropping an example JSON file I can try to get it read and working with what I've got now.

GingertronMk1 commented 7 years ago

UPDATE: it now works with /feeds/search.json

Unfortunately, while Haskell can deal with getting files from http, it throws errors on https