Another homepage for the movie database. Do I have to ask the api several times for a

Hello, 


Im almost done with  the web developement course here. but I do not like the layout.  

I was thinking instead of the names , the posters could be displayed on the frontpage. 

Am I right that for every film in the database , I have to ask the api for a poster ? 

Solution

Yes you have to do that per movie

Solution

pity, that can mean 10 or more request a page and maybe a very slow page

Hi Roelof,

You could retrieve the poster in a single query if you wanted.

The API is https://www.themoviedb.org/documentation/api

and documented here https://developers.themoviedb.org/3. You might also try signing up and getting your own API key.

I think that would make an excellent real world example. I encourage you to see if you can get it working.

The discover method might be a good one to try https://developers.themoviedb.org/3/discover/movie-discover

eg http://api.themoviedb.org/3/discover/movie?api_key=a8ec58e252045db51dda98b6f5db8821&with_genres=18&primary_release_year=2014

Best of luck!

Kind regards,

Stuart

Roelof Wobben wrote:

pity, that can mean 10 or more request a page and maybe a very slow page

You could store the poster with the movie data, so you only ever get it once. When it is stored in the move entity than you can skip it next time.

ps. might as well be the reason why they where not listed on the home page :)


Roelof,

Here is a quick example reading directly from the API, and not trying to merge with an Entity.

I hope this helps.  It would be great to hear how you go.

Kind regards,

Stuart


Thanks


I will try to make it work in the next few weeks and try to find a nice layout for it. Im  like nice layouts.

But first find a good schema for the projects. I know that on the mobile course images are stored in the database.



@stuart  I think I have finised the schema and could post here so you can take a look. if the schema is allright I can try to make the input screen and then the homepage.


Now first sleep.

Sounds good, I'm happy to review.

First attempt ready. i hope the schema can work for this project.

Hi Roelof,

Looks good.  That would work, but I have adjusted it a little to what might be closer to a real world example.

The things I have changed are:

  • Resource split into 2 entities, ResourceMetadata and ResourceContent.  The ResourceContent only contains the BinaryData.  This way OutSystems will not accidentally load the content from the database when you only want the filename
  • Changed Resource.Id from Movie Identifier to Long Integer (its own id) so it can be used by other entities.  ResourceContent though is a 1-1 relationship with ResourceMetadata so ResourceContent.Id is a ResourceMetadata Identifier.
  • Added MovieImageId (type ResourceMetadata Identifier) to Movie entity
  • As an example I added PersonImageId to Person entity, so a Person can have an image now using the same entity.
  • To ResourceMetadata, I added CreatedByUserId, CreatedDateTime, ChangedByUser and ChangedDateTime attributes.  I generally add these to about 50% of Entities I create.
  • To ResourceMetadata, I also added SizeBytes to record the size of the resource.  This way you don't have to load the content and check its size when you want to display or use the size.

You also might consider a unique index on PersonMovieRole.

Here is the updated diagram.

I hope this helps!

thanks, I almost missed this respons so I will try to incoperate this into the new version. 

Finally I have a very rought version ready for a input field. the user enters a movie title and then the app will look the data up instead of entering all the data itself. Most of the data is already know if I understand the data right.


Things I still have to figure out.


1) How to coperate a second call to another part of the api so I have more details about the flilm.

2) How to take care that the image is stored as binary data in the database so I can use that image to show on the front page.


it now a very very slow progresss but when I have to base ready I think the rest can be done very quick. 

that version does not work properly. At some waty I cannot make my idea work which looks like this


____________________________________________________
|     image                             |    year                                              |
|                                            |     revenue                                       | 

|                                             |                                                        |

____________________________________________________


Bummer,  it looks very nice when I saw examples on the net for it. 


Maybe you have a hint or  a idea how to make it work.

This is the second project  in outsystems where I have a idea outside the box and cannot make it work. 


Roelof