mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-02 11:58:27 +00:00
Small update to Indexer to ensure playlist sort order is always
sequential with no holes.
This commit is contained in:
parent
8bb70e7d98
commit
5fdffc292d
@ -695,6 +695,42 @@ void Indexer::SyncCleanup() {
|
||||
}
|
||||
}
|
||||
|
||||
/* make sure playlist sort orders are always sequential without holes. we
|
||||
do this anyway, as playlists are updated, but there's no way to guarantee
|
||||
it stays this way -- plugins, external processes, etc can cause problems */
|
||||
{
|
||||
db::Statement playlists("SELECT DISTINCT id FROM playlists", this->dbConnection);
|
||||
|
||||
while (playlists.Step() == db::Row) {
|
||||
db::Statement tracks(
|
||||
"SELECT track_external_id, sort_order "
|
||||
"FROM playlist_tracks WHERE playlist_id=? "
|
||||
"ORDER BY sort_order",
|
||||
this->dbConnection);
|
||||
|
||||
int64_t playlistId = playlists.ColumnInt64(0);
|
||||
tracks.BindInt64(0, playlistId);
|
||||
|
||||
db::Statement update(
|
||||
"UPDATE playlist_tracks "
|
||||
"SET sort_order=? "
|
||||
"WHERE track_external_id=? AND sort_order=?",
|
||||
this->dbConnection);
|
||||
|
||||
int order = 0;
|
||||
while (tracks.Step() == db::Row) {
|
||||
std::string externalId = tracks.ColumnText(0);
|
||||
int sortOrder = tracks.ColumnInt32(1);
|
||||
|
||||
update.ResetAndUnbind();
|
||||
update.BindInt32(0, order++);
|
||||
update.BindText(1, externalId);
|
||||
update.BindInt32(2, sortOrder);
|
||||
update.Step();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* optimize and shrink */
|
||||
this->dbConnection.Execute("VACUUM");
|
||||
}
|
||||
|
@ -103,13 +103,13 @@ namespace musik { namespace core {
|
||||
};
|
||||
|
||||
typedef std::vector<std::shared_ptr<
|
||||
musik::core::sdk::ITagReader> > TagReaderList;
|
||||
musik::core::sdk::ITagReader>> TagReaderList;
|
||||
|
||||
typedef std::vector<std::shared_ptr<
|
||||
musik::core::sdk::IDecoderFactory> > DecoderList;
|
||||
musik::core::sdk::IDecoderFactory>> DecoderList;
|
||||
|
||||
typedef std::vector<std::shared_ptr<
|
||||
musik::core::sdk::IIndexerSource> > IndexerSourceList;
|
||||
musik::core::sdk::IIndexerSource>> IndexerSourceList;
|
||||
|
||||
void ThreadLoop();
|
||||
|
||||
|
@ -117,6 +117,7 @@ namespace key {
|
||||
static const std::string playlist_name = "playlist_name";
|
||||
static const std::string subquery = "subquery";
|
||||
static const std::string type = "type";
|
||||
static const std::string sort_order = "sort_order";
|
||||
static const std::string sort_orders = "sort_orders";
|
||||
static const std::string predicate_category = "predicate_category";
|
||||
static const std::string predicate_id = "predicate_id";
|
||||
|
Loading…
Reference in New Issue
Block a user