Skip to content

Instantly share code, notes, and snippets.

@betamike
Created November 18, 2011 19:26
Show Gist options
  • Save betamike/1377490 to your computer and use it in GitHub Desktop.
Save betamike/1377490 to your computer and use it in GitHub Desktop.
<<<<<<< HEAD
static NSString *const selectEmptyPlaylists = @"SELECT DISTINCT p.playlistID FROM playlists AS p LEFT OUTER JOIN playlists_songs AS ps ON p.playlistID = ps.playlistID WHERE ps.songID IS NULL";
=======
>>>>>>> Fixed bug: deleting offline (and all) songs from a playlist does not clear the playlist offline songs count
FMResultSet *emptyListSet = [db executeQuery:selectEmptyPlaylists];
NSMutableSet *emptyPlaylists = [NSMutableSet set];
while ([emptyListSet next])
{
[emptyPlaylists addObject:[emptyListSet objectForColumnName:@"playlistId"]];
}
[emptyListSet close];
<<<<<<< HEAD
// zero-out offline songs counts for empty playlists.
// this fixes a one-off case where a playlist that had offline songs but is now empty never updates
// its offline songs count.
NSNumber *zero = [NSNumber numberWithInt:0];
for (id playlistId in emptyPlaylists)
{
if ([[playlistsOfflineSongCount objectForKey:playlistId] intValue] > 0)
{
[playlistsOfflineSongCount setObject:zero forKey:playlistId];
}
=======
NSNumber *zero = [NSNumber numberWithInt:0];
for (id playlistId in emptyPlaylists)
{
[playlistsOfflineSongCount setObject:zero forKey:playlistId];
>>>>>>> Fixed bug: deleting offline (and all) songs from a playlist does not clear the playlist offline songs count
}
[db close];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment