[banshee] [Shuffler] Add bulk RecordShuffles/Discards methods
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [Shuffler] Add bulk RecordShuffles/Discards methods
- Date: Wed, 3 Mar 2010 21:49:19 +0000 (UTC)
commit 423b0ea2b2f0b730e03a17107d30bb66668f4855
Author: Gabriel Burt <gabriel burt gmail com>
Date: Tue Mar 2 23:31:33 2010 -0800
[Shuffler] Add bulk RecordShuffles/Discards methods
.../Banshee.Collection.Database/Shuffler.cs | 29 +++++++++++++++++---
1 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs
index 89fada9..ea88f48 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/Shuffler.cs
@@ -38,6 +38,7 @@ using Hyena.Data.Sqlite;
using Banshee.ServiceStack;
using Banshee.PlaybackController;
using System.Collections.Generic;
+using Hyena.Collections;
namespace Banshee.Collection.Database
{
@@ -45,8 +46,11 @@ namespace Banshee.Collection.Database
{
public static readonly Shuffler Playback = new Shuffler () { Id = "playback", DbId = 0 };
- private static HyenaSqliteCommand add_shuffle_cmd = new HyenaSqliteCommand ("INSERT OR REPLACE INTO CoreShuffles (ShufflerID, TrackID, LastShuffledAt) VALUES (?, ?, ?)");
- private static HyenaSqliteCommand add_discard_cmd = new HyenaSqliteCommand ("INSERT OR REPLACE INTO CoreShuffleDiscards (ShufflerID, TrackID, LastDiscardedAt) VALUES (?, ?, ?)");
+ private static string shuffles_sql = "INSERT OR REPLACE INTO CoreShuffles (ShufflerID, LastShuffledAt, TrackID) ";
+ private static string discard_sql = "INSERT OR REPLACE INTO CoreShuffleDiscards (ShufflerID, LastDiscardedAt, TrackID) ";
+
+ private static HyenaSqliteCommand add_shuffle_cmd = new HyenaSqliteCommand (String.Format ("{0} VALUES (?, ?, ?)", shuffles_sql));
+ private static HyenaSqliteCommand add_discard_cmd = new HyenaSqliteCommand (String.Format ("{0} VALUES (?, ?, ?)", discard_sql));
private DateTime random_began_at = DateTime.MinValue;
private DateTime last_random = DateTime.MinValue;
@@ -159,17 +163,34 @@ namespace Banshee.Collection.Database
public void RecordShuffle (DatabaseTrackInfo track)
{
if (track != null) {
- ServiceManager.DbConnection.Execute (add_shuffle_cmd, this.DbId, track.TrackId, DateTime.Now);
+ RecordShuffle (track.TrackId);
}
}
+ public void RecordShuffle (int trackId)
+ {
+ ServiceManager.DbConnection.Execute (add_shuffle_cmd, this.DbId, DateTime.Now, trackId);
+ }
+
+ public void RecordShuffles (DatabaseTrackListModel model, RangeCollection.Range range)
+ {
+ ServiceManager.DbConnection.Execute (String.Format ("{0} SELECT ?, ?, {1}", shuffles_sql, model.TrackIdsSql),
+ DbId, DateTime.Now, model.CacheId, range.Start, range.Count);
+ }
+
public void RecordDiscard (DatabaseTrackInfo track)
{
if (track != null) {
- ServiceManager.DbConnection.Execute (add_discard_cmd, this.DbId, track.TrackId, DateTime.Now);
+ ServiceManager.DbConnection.Execute (add_discard_cmd, this.DbId, DateTime.Now, track.TrackId);
}
}
+ public void RecordDiscards (DatabaseTrackListModel model, RangeCollection.Range range)
+ {
+ ServiceManager.DbConnection.Execute (String.Format ("{0} SELECT ?, ?, {1}", discard_sql, model.TrackIdsSql),
+ DbId, DateTime.Now, model.CacheId, range.Start, range.Count);
+ }
+
private TrackInfo GetRandomTrack (string mode, bool repeat, bool resetSinceTime)
{
foreach (var r in random_modes) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]