Movie set fixes and sorting improvements #1000

Merged
merged 8 commits into from Jun 1, 2012

Conversation

Projects
None yet
3 participants
@Montellese
Member

Montellese commented May 23, 2012

These commits add a fix for the following set-related problem: The problem is that we only retrieve sets if they contain more than one movie (which is handled through SQL's COUNT() and GROUP BY on the setlinkmovie table). The existing logic does not take into account special WHERE conditions like when browsing movies by years which can result in a set being found which usually contains multiple movies but combined with the special WHERE condition, only one movie matches the whole query. In that case up until now neither the set containing the matching movie nor the movie itself were listed.

Furthermore they implement a new way to retrieve sets by going through all the movies belonging to the set and using their metadata (currently year, rating, lastplayed, dateadded and playcount) to calculate the metadata for the whole set (e.g. the average of all the ratings). This allows sets to be sorted like movies in a list instead of just treating them as folders and putting them at the top/bottom of the list.

As a result of the new available metadata for sets I also added the respective sorting methods to the sets node in the video library.

Theoretically skins could use these new metadata values and display them for sets like they do for movies but only the above mentioned properties (year, rating, lastplayed, dateadded and playcount) are currently automatically filled and therefore available.

@ghost ghost assigned Montellese May 23, 2012

Montellese added some commits May 16, 2012

videodb: fix retrieval of movies being part of a set
The problem is that we only retrieve sets if they contain more than one movie
(which is handled through SQL's COUNT() and GROUP BY on the setlinkmovie table).
The existing logic does not take into account special WHERE conditions like when
browsing movies by years which can result in a set being found which usually
contains multiple movies but combined with the special WHERE condition, only one
movie matches the whole query. In that case up until now neither the set containing
the matching movie nor the movie itself were listed.
@Montellese

This comment has been minimized.

Show comment Hide comment
@Montellese

Montellese May 24, 2012

Member

Fixed two PrepareSQLs I missed (thanks jmarshall) and added "total", "watched" and "unwatched" properties to the set's CFileItem (similar to what we do for tvshows and "totalepisodes" etc).

Member

Montellese commented May 24, 2012

Fixed two PrepareSQLs I missed (thanks jmarshall) and added "total", "watched" and "unwatched" properties to the set's CFileItem (similar to what we do for tvshows and "totalepisodes" etc).

Montellese added a commit that referenced this pull request Jun 1, 2012

Merge pull request #1000 from Montellese/moviesets_fixes
Movie set fixes and sorting improvements

@Montellese Montellese merged commit 1464ab6 into xbmc:master Jun 1, 2012

@amet

This comment has been minimized.

Show comment Hide comment
@amet

amet Jun 1, 2012

int maybe?

This comment has been minimized.

Show comment Hide comment
@Montellese

Montellese Jun 1, 2012

Owner

wtf this must have gone missing during one of my rebases. I remember having forgotten to change the bool to an int and then added another commit and rebased it into the rest. Thanks for fixing it.

Owner

Montellese replied Jun 1, 2012

wtf this must have gone missing during one of my rebases. I remember having forgotten to change the bool to an int and then added another commit and rebased it into the rest. Thanks for fixing it.

This comment has been minimized.

Show comment Hide comment
@amet

amet Jun 1, 2012

no problem, vdrfan tested on linux and I pushed all the osx needed fixes

amet replied Jun 1, 2012

no problem, vdrfan tested on linux and I pushed all the osx needed fixes

@amet

This comment has been minimized.

Show comment Hide comment
@amet

amet Jun 1, 2012

pItem->SetProperty("total", (int)it->second.movies.size());

pItem->SetProperty("total", (int)it->second.movies.size());

@amet

This comment has been minimized.

Show comment Hide comment
@amet

amet Jun 1, 2012

pItem->SetProperty("unwatched", (int)it->second.movies.size() - iWatched);

pItem->SetProperty("unwatched", (int)it->second.movies.size() - iWatched);

@amet

This comment has been minimized.

Show comment Hide comment
@amet

amet Jun 1, 2012

  pItem->GetVideoInfoTag()->m_playCount = iWatched >= (int)it->second.movies.size() ? (pItem->GetVideoInfoTag()->m_playCount / it->second.movies.size()) : 0;
  pItem->GetVideoInfoTag()->m_playCount = iWatched >= (int)it->second.movies.size() ? (pItem->GetVideoInfoTag()->m_playCount / it->second.movies.size()) : 0;

amet added a commit that referenced this pull request Jun 1, 2012

@vicbitter

This comment has been minimized.

Show comment Hide comment
@vicbitter

vicbitter Jun 2, 2012

The SQL query does not execute on a MySQL backend. The following proposed fix (query) executes against both SQLite and MySQL DBs:

SELECT movieview.*, sets.idSet, sets.strSet FROM movieview,sets,setlinkmovie WHERE movieview.idMovie = setlinkmovie.idMovie AND sets.idSet = setlinkmovie.idSet AND movieview.idMovie IN (SELECT idMovie FROM setlinkmovie s1 JOIN(SELECT idSet, COUNT(1) AS c FROM setlinkmovie GROUP BY idSet HAVING c>1) s2 ON s2.idSet=s1.idSet)

The SQL query does not execute on a MySQL backend. The following proposed fix (query) executes against both SQLite and MySQL DBs:

SELECT movieview.*, sets.idSet, sets.strSet FROM movieview,sets,setlinkmovie WHERE movieview.idMovie = setlinkmovie.idMovie AND sets.idSet = setlinkmovie.idSet AND movieview.idMovie IN (SELECT idMovie FROM setlinkmovie s1 JOIN(SELECT idSet, COUNT(1) AS c FROM setlinkmovie GROUP BY idSet HAVING c>1) s2 ON s2.idSet=s1.idSet)

This comment has been minimized.

Show comment Hide comment
@Montellese

Montellese Jun 2, 2012

Owner

What does MySQL report? Apart from the movieview.* part it's not that different from the old query which worked fine.

Owner

Montellese replied Jun 2, 2012

What does MySQL report? Apart from the movieview.* part it's not that different from the old query which worked fine.

This comment has been minimized.

Show comment Hide comment
@vicbitter

vicbitter Jun 3, 2012

I think that the JOINs are throwing MySQL as the error is #1054 - Unknown column 'sets.idSet' in 'on clause'

I think that the JOINs are throwing MySQL as the error is #1054 - Unknown column 'sets.idSet' in 'on clause'

This comment has been minimized.

Show comment Hide comment
@Montellese

Montellese Jun 3, 2012

Owner

Can you try and switch the second and the third JOIN clause? Because I already use sets.idSet in the second JOIN clause before I actually join with the sets table in the third JOIN clause.

Owner

Montellese replied Jun 3, 2012

Can you try and switch the second and the third JOIN clause? Because I already use sets.idSet in the second JOIN clause before I actually join with the sets table in the third JOIN clause.

This comment has been minimized.

Show comment Hide comment
@vicbitter

vicbitter Jun 3, 2012

I switched the second and third JOIN clause and it works! Just to confirm the query now looks like this:

SELECT movieview.*, sets.idSet, sets.strSet FROM movieview
JOIN setlinkmovie ON movieview.idMovie = setlinkmovie.idMovie
JOIN sets ON setlinkmovie.idSet = sets.idSet
JOIN (SELECT idSet, COUNT(1) AS c FROM setlinkmovie GROUP BY idSet HAVING c>1) s2 ON s2.idSet = sets.idSet

I switched the second and third JOIN clause and it works! Just to confirm the query now looks like this:

SELECT movieview.*, sets.idSet, sets.strSet FROM movieview
JOIN setlinkmovie ON movieview.idMovie = setlinkmovie.idMovie
JOIN sets ON setlinkmovie.idSet = sets.idSet
JOIN (SELECT idSet, COUNT(1) AS c FROM setlinkmovie GROUP BY idSet HAVING c>1) s2 ON s2.idSet = sets.idSet

This comment has been minimized.

Show comment Hide comment
@Montellese

Montellese Jun 3, 2012

Owner

Thanks for reporting it and trying my suggestion. Will commit the fix ASAP.

Owner

Montellese replied Jun 3, 2012

Thanks for reporting it and trying my suggestion. Will commit the fix ASAP.

@vicbitter

This comment has been minimized.

Show comment Hide comment
@vicbitter

vicbitter Jun 3, 2012

When executing the query MySQL returns "#1054 - Unknown column 'sets.idSet' in 'on clause'"

When executing the query MySQL returns "#1054 - Unknown column 'sets.idSet' in 'on clause'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment