banshee r3026 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Sources src/Core/Hyena/Hyena.Data.Sqlite



Author: gburt
Date: Sat Jan 26 02:00:28 2008
New Revision: 3026
URL: http://svn.gnome.org/viewvc/banshee?rev=3026&view=rev

Log:
2008-01-25  Gabriel Burt  <gabriel burt gmail com>

	* src/Core/Banshee.Services/Banshee.Collection.Database/AlbumListDatabaseModel.cs:
	* src/Core/Banshee.Services/Banshee.Collection.Database/ArtistListDatabaseModel.cs:
	Use the CoreCache table to filter artists and albums based on the
	currently matching tracks.  Means the artist/album lists are filtered as
	you filter you tracks.

	* src/Core/Banshee.Services/Banshee.Collection.Database/TrackListDatabaseModel.cs:
	Comment out query debugging.

	* src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs: Call
	OnUpdated after Reloading.

	* src/Core/Hyena/Hyena.Data.Sqlite/SqliteModelCache.cs: Comment out timers.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/AlbumListDatabaseModel.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/ArtistListDatabaseModel.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/TrackListDatabaseModel.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
   trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/SqliteModelCache.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/AlbumListDatabaseModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/AlbumListDatabaseModel.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/AlbumListDatabaseModel.cs	Sat Jan 26 02:00:28 2008
@@ -58,7 +58,8 @@
             this.connection = connection;
         }
 
-        public AlbumListDatabaseModel(TrackListDatabaseModel trackModel, BansheeDbConnection connection, string uuid) : this (connection, uuid)
+        public AlbumListDatabaseModel(TrackListDatabaseModel trackModel, 
+                BansheeDbConnection connection, string uuid) : this (connection, uuid)
         {
             this.track_model = trackModel;
         }
@@ -69,18 +70,24 @@
             if (!first_reload || !cache.Warm) {
                 bool either = (artist_id_filter_query != null) || (track_model != null);
                 bool both = (artist_id_filter_query != null) && (track_model != null);
+
                 reload_fragment = String.Format (@"
-                    FROM CoreAlbums INNER JOIN CoreArtists ON CoreAlbums.ArtistID = CoreArtists.ArtistID 
-                        {0} {1} {2} {3}
-                        ORDER BY CoreAlbums.Title, CoreArtists.Name",
+                    FROM CoreAlbums INNER JOIN CoreArtists ON CoreAlbums.ArtistID = CoreArtists.ArtistID
+                        {0} {1} {2} {3} ORDER BY CoreAlbums.Title, CoreArtists.Name",
                     either ? "WHERE" : null,
-                    artist_id_filter_query,
+                    track_model == null ? null :
+                        String.Format (@"
+                            CoreAlbums.AlbumID IN
+                                (SELECT DISTINCT(CoreTracks.AlbumID) FROM CoreTracks, CoreAlbums, CoreCache
+                                    WHERE CoreCache.ModelID = {0} AND
+                                          CoreCache.ItemId = CoreTracks.TrackID AND
+                                          CoreAlbums.AlbumID = CoreTracks.AlbumID)",
+                            track_model.CacheId
+                        ),
                     both ? "AND" : null,
-                    track_model == null ? null : String.Format(
-                        "CoreAlbums.AlbumID IN (SELECT DISTINCT (CoreTracks.AlbumID) {0})",
-                        track_model.ReloadFragment
-                    )
+                    artist_id_filter_query
                 );
+                //Console.WriteLine ("reload fragment for albums is {0}", reload_fragment);
 
                 cache.Reload ();
             }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/ArtistListDatabaseModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/ArtistListDatabaseModel.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/ArtistListDatabaseModel.cs	Sat Jan 26 02:00:28 2008
@@ -64,17 +64,20 @@
         public override void Reload()
         {
             if (!first_reload || !cache.Warm) {
-                reload_fragment = String.Format (@"
-                    FROM CoreArtists
-                        {0} {1}
-                        ORDER BY Name",
-                    track_model != null ? "WHERE" : null,
-                    track_model == null ? null : String.Format(
-                        "CoreArtists.ArtistID IN (SELECT DISTINCT (CoreTracks.ArtistID) {0})",
-                        track_model.ReloadFragment
-                    )
+                reload_fragment = String.Format (
+                    @"FROM CoreArtists {0} ORDER BY Name",
+                    track_model != null ? String.Format(@"
+                        WHERE CoreArtists.ArtistID IN
+                            (SELECT DISTINCT (CoreTracks.ArtistID) FROM CoreTracks, CoreArtists, CoreCache
+                                WHERE CoreCache.ModelID = {0} AND
+                                      CoreCache.ItemId = CoreTracks.TrackID AND
+                                      CoreArtists.ArtistId = CoreTracks.ArtistID)",
+                        track_model.CacheId
+                    ) : null
                 );
 
+                //Console.WriteLine ("reload fragment for artists is {0}", reload_fragment);
+
                 cache.Reload ();
             }
 
@@ -92,7 +95,7 @@
                 return cache.GetValue (index - 1);
             }
         }
-        
+
         public override int Count { 
             get { return count; }
         }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/TrackListDatabaseModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/TrackListDatabaseModel.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/TrackListDatabaseModel.cs	Sat Jan 26 02:00:28 2008
@@ -82,10 +82,9 @@
 
                 filter_query = n.ToSql (field_set);
 
+                /*
                 Console.WriteLine ("query: {0}", Filter);
-                //Console.WriteLine ("tree:");
-                //n.Dump ();
-                Console.WriteLine ("Xml for Query: {0}", n.ToXml (field_set));
+                Console.WriteLine ("Xml for Query: {0}", n.ToXml (field_set, true));
                 Console.WriteLine ("Sql for Query: {0}", filter_query);
                 Hyena.Data.Query.QueryParser qp2 = new XmlQueryParser (n.ToXml (field_set));
                 QueryNode n2 = qp2.BuildTree (field_set);
@@ -93,9 +92,14 @@
                     Console.WriteLine ("User query for Xml: {0}", n2.ToUserQuery ());
                 } else
                     Console.WriteLine ("n2 is null");
+                */
 
                 if (filter_query.Length == 0)
                     filter_query = null;
+                //else {
+                    //artist_id_filter_query = null;
+                    //album_id_filter_query = null;
+                //}
             }
         }
 

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs	Sat Jan 26 02:00:28 2008
@@ -72,7 +72,7 @@
                 base.FilterQuery = value;
                 track_model.Filter = value;
                 track_model.Refilter ();
-                track_model.Reload ();
+                RateLimitedReload ();
             }
         }
 
@@ -114,6 +114,7 @@
             track_model.Reload ();
             artist_model.Reload ();
             album_model.Reload ();
+            OnUpdated ();
         }
 
         // Methods for removing tracks from this source
@@ -155,7 +156,7 @@
         protected void AfterInitialized ()
         {
             Reload ();
-            track_model.Reloaded += OnTrackModelReloaded;
+            //track_model.Reloaded += OnTrackModelReloaded;
             OnSetupComplete ();
         }
 

Modified: trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/SqliteModelCache.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/SqliteModelCache.cs	(original)
+++ trunk/banshee/src/Core/Hyena/Hyena.Data.Sqlite/SqliteModelCache.cs	Sat Jan 26 02:00:28 2008
@@ -148,9 +148,9 @@
         public override int Reload ()
         {
             InvalidateManagedCache ();
-            using (new Timer (String.Format ("Generating cache table for {0}", model))) {
+            //using (new Timer (String.Format ("Generating cache table for {0}", model))) {
                 connection.Execute (reload_sql + model.ReloadFragment);
-            }
+            //}
             first_order_id = -1;
             UpdateCount ();
             return rows;
@@ -158,7 +158,7 @@
 
         protected override void FetchSet (int offset, int limit)
         {
-            using (new Timer (String.Format ("Fetching set for {0}", model))) {
+            //using (new Timer (String.Format ("Fetching set for {0}", model))) {
                 select_range_command.ApplyValues (offset, limit);
                 using (IDataReader reader = connection.ExecuteReader (select_range_command)) {
                     while (reader.Read ()) {
@@ -168,7 +168,7 @@
                         offset++;
                      }
                  }
-            }
+            //}
         }
         
         protected void UpdateCount ()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]