AugustoMarcelo / mcuapi

🦸 Marvel Cinematic Universe API
https://mcuapi.herokuapp.com/docs
67 stars 3 forks source link

Suggestion: Chronology for shows #32

Open deBasMan21 opened 1 year ago

deBasMan21 commented 1 year ago

Currently the movies have a chronology property with a number to order them chronologically. I would also like this property on the tv shows so all the projects can be ordered by that one property. I would love to hear if this is possible in some way.

AugustoMarcelo commented 1 year ago

Hi, @deBasMan21. It's possible. I thought about this long ago, but I'm not 100% sure how to do it. I had plans to make one endpoint where all productions (movies and tv shows) are returned. However, each model is located in a different table. So I need to implement a strategy to add a chronology number that would be easy to change since each future production can be located in different places on the timeline.

deBasMan21 commented 1 year ago

@AugustoMarcelo Do you use any CMS or do you add the data directly into the db? If you use a CMS this would maybe be a good place to add some logic to make a GUI to drag and drop items and get the according index to save it in the db.

If thats not the case you could create a simple sql script that updates all the indices of the projects with a higher index than the new project with +1. Since there aren't a lot of projects being added this isn't really a big performance problem. It could be something like:

UPDATE projects 
SET chronology = chronology + 1 
WHERE chronology >= <<newProjectIndex here>>

Let me know if i can help you in any way :)

AugustoMarcelo commented 1 year ago

@deBasMan21 Today I just update the data directly in the DB. I understood your solution, but it's not possible to be done today because movies and tv shows are stored in different tables. I can just add a new field to the tv show model and create a chronology between them (tv shows). But if I want to do a global endpoint to return both sorted chronologically, the tv shows will not be placed correctly. I think the solution may be to use a float number in the tv shows. So if it's placed between the movie 1 and 2 (chronologically speaking) it could be stored with 1.1 or something like this.