[Slim-Checkins] r10993 - in /trunk/server:
HTML/EN/artistsAsHTML.html
HTML/EN/artistsAsText.html Slim/Schema/Album.pm Slim/Schema/Track.pm
adrian at svn.slimdevices.com
adrian at svn.slimdevices.com
Sun Dec 17 13:33:27 PST 2006
Author: adrian
Date: Sun Dec 17 13:33:27 2006
New Revision: 10993
URL: http://svn.slimdevices.com?rev=10993&view=rev
Log:
Bug: N/A
Description: speed up render of common pages including artist info,
by avoiding call to artistsWithAttributes from templates. Instead add
contributor info to params data before filling templates. This avoid
duplicated database accesses for the same information.
Modified:
trunk/server/HTML/EN/artistsAsHTML.html
trunk/server/HTML/EN/artistsAsText.html
trunk/server/Slim/Schema/Album.pm
trunk/server/Slim/Schema/Track.pm
Modified: trunk/server/HTML/EN/artistsAsHTML.html
URL: http://svn.slimdevices.com/trunk/server/HTML/EN/artistsAsHTML.html?rev=10993&r1=10992&r2=10993&view=diff
==============================================================================
--- trunk/server/HTML/EN/artistsAsHTML.html (original)
+++ trunk/server/HTML/EN/artistsAsHTML.html Sun Dec 17 13:33:27 2006
@@ -2,13 +2,13 @@
[%- FILTER null %]
[% contributorsHTML = [] %]
-[% FOREACH contributorTuple IN itemobj.artistsWithAttributes %]
+[% contributors = item.artistsWithAttributes || itemobj.artistsWithAttributes %]
- [% contributor = contributorTuple.artist %]
+[% FOREACH contributorTuple IN contributors %]
+
[% attrs = contributorTuple.attributes | html %]
[% target = notarget ? '' : 'target="browser"' %]
- [% contrib = contributor.name | html %]
- [% art = artwork ? "&artwork=$artwork" : '' %]
+ [% contrib = contributorTuple.name | html %]
[% contributorHTMLFrag = "<a href=\"${webroot}browsedb.html?hierarchy=contributor,album,track&$attrs&artwork=$artwork&level=1&player=$playerURI\" $target>$contrib</a>" %]
Modified: trunk/server/HTML/EN/artistsAsText.html
URL: http://svn.slimdevices.com/trunk/server/HTML/EN/artistsAsText.html?rev=10993&r1=10992&r2=10993&view=diff
==============================================================================
--- trunk/server/HTML/EN/artistsAsText.html (original)
+++ trunk/server/HTML/EN/artistsAsText.html Sun Dec 17 13:33:27 2006
@@ -2,10 +2,11 @@
[%- FILTER null %]
[% contributorsText = [] %]
-[% FOREACH contributorTuple IN itemobj.artistsWithAttributes %]
+[% contributors = item.artistsWithAttributes || itemobj.artistsWithAttributes %]
- [% contributor = contributorTuple.artist %]
- [% contributorsText.push(contributor.name) %]
+[% FOREACH contributorTuple IN contributors %]
+
+ [% contributorsText.push(contributorTuple.name) %]
[% END %]
[% END -%]
Modified: trunk/server/Slim/Schema/Album.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Schema/Album.pm?rev=10993&r1=10992&r2=10993&view=diff
==============================================================================
--- trunk/server/Slim/Schema/Album.pm (original)
+++ trunk/server/Slim/Schema/Album.pm Sun Dec 17 13:33:27 2006
@@ -118,18 +118,31 @@
# contributors in the album view.
# if ($form->{'hierarchy'} ne 'contributor,album,track') {
- if (my $contributor = $self->contributors->first) {
-
- $form->{'artist'} = $contributor;
- #$form->{'includeArtist'} = defined $findCriteria->{'artist'} ? 0 : 1;
- $form->{'noArtist'} = Slim::Utils::Strings::string('NO_ARTIST');
-
- if ($showContributor) {
- # override default field for anchors with contributor.namesort
- $$anchortextRef = $contributor->namesort;
- }
+ my $contributors = $self->contributors;
+
+ if (my $contributor = $contributors->first) {
+
+ $form->{'artist'} = $contributor;
+ #$form->{'includeArtist'} = defined $findCriteria->{'artist'} ? 0 : 1;
+ $form->{'noArtist'} = Slim::Utils::Strings::string('NO_ARTIST');
+
+ if ($showContributor) {
+ # override default field for anchors with contributor.namesort
+ $$anchortextRef = $contributor->namesort;
}
- # }
+ }
+
+ my @info;
+
+ for my $contributor ($contributors->all) {
+ push @info, {
+ 'artist' => $contributor,
+ 'name' => $contributor->name,
+ 'attributes' => 'contributor.id=' . $contributor->id,
+ };
+ }
+
+ $form->{'artistsWithAttributes'} = \@info;
}
my $Imports = Slim::Music::Import->importers;
@@ -207,6 +220,7 @@
push @artists, {
'artist' => $artist,
+ 'name' => $artist->name,
'attributes' => join('&', @attributes),
};
}
Modified: trunk/server/Slim/Schema/Track.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Schema/Track.pm?rev=10993&r1=10992&r2=10993&view=diff
==============================================================================
--- trunk/server/Slim/Schema/Track.pm (original)
+++ trunk/server/Slim/Schema/Track.pm Sun Dec 17 13:33:27 2006
@@ -119,6 +119,7 @@
push @objs, {
'artist' => $contributor,
+ 'name' => $contributor->name,
'attributes' => join('&',
join('=', 'contributor.id', $contributor->id),
join('=', 'contributor.role', $type),
@@ -385,8 +386,26 @@
# Only include Artist & Album if the user doesn't have them defined in a custom title format.
if ($format !~ /ARTIST/) {
- $form->{'artist'} = $self->artist;
- $form->{'includeArtist'} = 1;
+
+ if (my $contributors = $self->contributorsOfType(qw(ARTIST TRACKARTIST))) {
+
+ my $artist = $contributors->first;
+
+ $form->{'includeArtist'} = 1;
+ $form->{'artist'} = $artist;
+
+ my @info;
+
+ for my $contributor ($contributors->all) {
+ push @info, {
+ 'artist' => $contributor,
+ 'name' => $contributor->name,
+ 'attributes' => 'contributor.id=' . $contributor->id,
+ };
+ }
+
+ $form->{'artistsWithAttributes'} = \@info;
+ }
}
if ($format !~ /ALBUM/) {
More information about the checkins
mailing list