[mb-commits] r10088 - in mb_server/branches/Discographies-BRANCH: admin/sql/updates admin/sql/vertical/rawdata cgi-bin/MusicBrainz/Server cgi-bin/MusicBrainz/Server/Handlers/WS/1 htdocs/show/collection
root at musicbrainz.org
root at musicbrainz.org
Fri Jul 11 00:51:04 UTC 2008
Author: niklas
Date: 2008-07-11 00:51:04 +0000 (Fri, 11 Jul 2008)
New Revision: 10088
Added:
mb_server/branches/Discographies-BRANCH/admin/sql/updates/20080711.sql
Removed:
mb_server/branches/Discographies-BRANCH/admin/sql/updates/discography.sql
Modified:
mb_server/branches/Discographies-BRANCH/admin/sql/vertical/rawdata/CreateIndexes.sql
mb_server/branches/Discographies-BRANCH/cgi-bin/MusicBrainz/Server/Collection.pm
mb_server/branches/Discographies-BRANCH/cgi-bin/MusicBrainz/Server/CollectionInfo.pm
mb_server/branches/Discographies-BRANCH/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Collection.pm
mb_server/branches/Discographies-BRANCH/htdocs/show/collection/index.html
Log:
now using AuthDigest for webservice
Copied: mb_server/branches/Discographies-BRANCH/admin/sql/updates/20080711.sql (from rev 9997, mb_server/branches/Discographies-BRANCH/admin/sql/updates/discography.sql)
Deleted: mb_server/branches/Discographies-BRANCH/admin/sql/updates/discography.sql
Modified: mb_server/branches/Discographies-BRANCH/admin/sql/vertical/rawdata/CreateIndexes.sql
===================================================================
--- mb_server/branches/Discographies-BRANCH/admin/sql/vertical/rawdata/CreateIndexes.sql 2008-07-10 22:38:41 UTC (rev 10087)
+++ mb_server/branches/Discographies-BRANCH/admin/sql/vertical/rawdata/CreateIndexes.sql 2008-07-11 00:51:04 UTC (rev 10088)
@@ -27,4 +27,11 @@
-- an unique index made out of all the fields in the collection_has_release_join table. used to not allow duplicates of tuples
CREATE UNIQUE INDEX collection_has_release_join_combined_index ON collection_has_release_join (id, collection_info, album);
+CREATE INDEX collection_ignore_release_join_index ON collection_ignore_release_join (collection_info);
+CREATE INDEX collection_discography_artist_join_index ON collection_discography_artist_join (collection_info);
+CREATE INDEX collection_watch_artist_join_index ON collection_watch_artist_join (collection_info);
+CREATE INDEX collection_ignore_release_join_index ON collection_ignore_release_join (collection_info);
+CREATE INDEX collection_discography_artist_join_index ON collection_discography_artist_join (collection_info);
+CREATE INDEX collection_watch_artist_join_index ON collection_watch_artist_join (collection_info);
+
-- vi: set ts=4 sw=4 et :
Modified: mb_server/branches/Discographies-BRANCH/cgi-bin/MusicBrainz/Server/Collection.pm
===================================================================
--- mb_server/branches/Discographies-BRANCH/cgi-bin/MusicBrainz/Server/Collection.pm 2008-07-10 22:38:41 UTC (rev 10087)
+++ mb_server/branches/Discographies-BRANCH/cgi-bin/MusicBrainz/Server/Collection.pm 2008-07-11 00:51:04 UTC (rev 10088)
@@ -2,7 +2,6 @@
#
# TODO:
#
-# move RemoveRelease to RAW database
#
#!/usr/bin/perl -w
Modified: mb_server/branches/Discographies-BRANCH/cgi-bin/MusicBrainz/Server/CollectionInfo.pm
===================================================================
--- mb_server/branches/Discographies-BRANCH/cgi-bin/MusicBrainz/Server/CollectionInfo.pm 2008-07-10 22:38:41 UTC (rev 10087)
+++ mb_server/branches/Discographies-BRANCH/cgi-bin/MusicBrainz/Server/CollectionInfo.pm 2008-07-11 00:51:04 UTC (rev 10088)
@@ -29,22 +29,53 @@
collectionId => $result->{id},
hasReleases => undef,
missingReleases => undef
- #$result{id}
- #collectionHash => {}, # {'Smash Mouth' => ('Release 1', 'Release 2'), 'Fort Minor' => ('Release')}
#artistHash => {}
}, $this);
}
-sub RetrieveCollection
+# check if a user has a collection_info tuple. returns true or false.
+sub HasCollection
{
- my($this) = @_;
+ my ($userId, $rawdbh) = @_;
- my %collection;
+ my $sql = Sql->new($rawdbh);
+
+ my $query = "SELECT COUNT(*) FROM collection_info WHERE moderator='". $userId ."'";
+
+ return $sql->SelectSingleValue($query);
}
+# assure that the user has a corresponding collection_info tuple. if it does not have one yet - create it.
+# this sub should be called on every page that requires a collection
+sub AssureCollection
+{
+ my ($userId, $rawdbh) = @_;
+
+ if(HasCollection($userId, $rawdbh))
+ {
+ print 'HAS COLLECTION';
+ }
+ else
+ {
+ print 'DO NOT HAVE COLLECTION';
+ }
+}
+
+
+# add a collection_info tuple for the specified user
+sub CreateCollection
+{
+ my ($userId, $rawdbh) = @_;
+
+ my $sql = Sql->new($rawdbh);
+
+ my $query = "INSERT INTO collection_info";
+}
+
+
sub GetHasReleases
{
my ($this) = @_;
Modified: mb_server/branches/Discographies-BRANCH/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Collection.pm
===================================================================
--- mb_server/branches/Discographies-BRANCH/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Collection.pm 2008-07-10 22:38:41 UTC (rev 10087)
+++ mb_server/branches/Discographies-BRANCH/cgi-bin/MusicBrainz/Server/Handlers/WS/1/Collection.pm 2008-07-11 00:51:04 UTC (rev 10088)
@@ -17,12 +17,12 @@
# make sure we are getting POST data
#if($r->method != "POST") print "Only accepting POST data";
-
+ # perhaps the above check should not be done? why not allow GET...
+
+ # store
my %args=$r->args;
- # which user is logged on?
- my $collectionId=123; #for now...
# get the albums from the POST data
my @addAlbums=split(",", $args{addalbums});
@@ -38,8 +38,15 @@
my $mbraw = MusicBrainz->new();
$mbraw->Login(db => 'RAWDATA');
+ my $sqlraw = Sql->new($mbraw->{DBH});
- # instantiate
+ # get collection_info id
+ my $collectionIdQuery="SELECT id FROM collection_info WHERE moderator='". $r->user ."'";
+ my $collectionId=$sqlraw->SelectSingleValue($collectionIdQuery);
+
+
+
+ # instantiate Collection object
my $collection=MusicBrainz::Server::Collection->new($mbro->{DBH}, $mbraw->{DBH}, $collectionId);
# add albums, if the array is not empty...
Modified: mb_server/branches/Discographies-BRANCH/htdocs/show/collection/index.html
===================================================================
--- mb_server/branches/Discographies-BRANCH/htdocs/show/collection/index.html 2008-07-10 22:38:41 UTC (rev 10087)
+++ mb_server/branches/Discographies-BRANCH/htdocs/show/collection/index.html 2008-07-11 00:51:04 UTC (rev 10088)
@@ -10,6 +10,9 @@
my $mbro = $m->comp("/comp/dblogin");
my $mbraw = MusicBrainz->new();
$mbraw->Login(db => 'RAWDATA');
+
+ # make sure the user has a collection_info tuple
+ MusicBrainz::Server::CollectionInfo::AssureCollection($session{uid}, $mbraw->{DBH});
</%perl>
More information about the MusicBrainz-commits
mailing list