by Mizery_Made » Thu Apr 09, 2009 12:39 am
I got a little bored and did some digging around.
Code: Select all
'Totals
strSQL = "SELECT Count(*) AS Nombre FROM Artists WHERE ID <> 0 AND Tracks>0" ' Track artists only
Set qryStats = SDB.Database.OpenSQL(strSQL)
intArtistsCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0))
' process background threads
SDB.ProcessMessages
strSQL = "SELECT Count(Distinct Artists.ID) AS CountOfID FROM Artists WHERE Artists.ID IN ( SELECT ArtistsSongs.IDArtist FROM ArtistsSongs WHERE ArtistsSongs.IDSong IN ( SELECT Played.IDSong FROM Played))"
Set qryStats = SDB.Database.OpenSQL(strSQL)
intArtistsCountPlayed = CLng(NoNull(qryStats.ValueByName("CountOfID"),0))
There's the code snippet from the original file. Looking at the SQL that finds the number of Artists in the library, it bases it off of the Artists.Tracks column, which a Person only has a number <> 0 in this column if they are an Artist for a track and not just a conductor or composer, etc (since they have their own columns). Thus, while it's only counting artists, the other that pulls the played one is pulling any person that has an entry in the Played table, regardless if they're a Artist, Conductor, etc. Toying with it, I got this to work as expected:
Code: Select all
'Totals
strSQL = "SELECT Count(*) AS Nombre FROM Artists WHERE ID <> 0 AND Tracks>0" ' Track artists only
Set qryStats = SDB.Database.OpenSQL(strSQL)
intArtistsCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0))
' process background threads
SDB.ProcessMessages
strSQL = "SELECT Count(Distinct Artists.ID) AS CountOfID FROM Artists WHERE Artists.ID IN ( SELECT ArtistsSongs.IDArtist FROM ArtistsSongs WHERE ArtistsSongs.IDSong IN ( SELECT Played.IDSong FROM Played) AND PersonType=1)"
Set qryStats = SDB.Database.OpenSQL(strSQL)
intArtistsCountPlayed = CLng(NoNull(qryStats.ValueByName("CountOfID"),0))
As you can see, I've added a "PersonType" clause to the Played SQL, which only accounts for people that are Artists (or I believe, Album Artists), which gives me a number that matches the one from the Library query. It seems the "Top Artists" problem can be fixed with a "PersonType" clause too:
Original:
Code: Select all
strSQL = "SELECT Sum(PlayCounter) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength, Artists.Artist "
strSQL = strSQL & "FROM ArtistsSongs, Songs, Artists "
strSQL = strSQL & "WHERE Songs.ID = ArtistsSongs.IDSong AND Songs.ID IN (SELECT Played.IDSong FROM Played) AND ArtistsSongs.IDArtist = Artists.ID "
strSQL = strSQL & "GROUP BY ArtistsSongs.IDArtist "
strSQL = strSQL & "ORDER BY Sum(PlayCounter) DESC LIMIT " & intTopCount & ""
Set qryStats = SDB.Database.OpenSQL(strSQL)
While Not qryStats.EOF
Edit:
Code: Select all
strSQL = "SELECT Sum(PlayCounter) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength, Artists.Artist "
strSQL = strSQL & "FROM ArtistsSongs, Songs, Artists "
strSQL = strSQL & "WHERE Songs.ID = ArtistsSongs.IDSong AND Songs.ID IN (SELECT Played.IDSong FROM Played) AND ArtistsSongs.IDArtist = Artists.ID AND ArtistsSongs.PersonType=1 "
strSQL = strSQL & "GROUP BY ArtistsSongs.IDArtist "
strSQL = strSQL & "ORDER BY Sum(PlayCounter) DESC LIMIT " & intTopCount & ""
Set qryStats = SDB.Database.OpenSQL(strSQL)
While Not qryStats.EOF
Again, this returns expected results for me, the "Top # Artists" section now only lists Artists, so I no longer have a Top 10 where half of the entries are producers who rarely if ever appear in the Artist field. I went ahead and set up a Top 10 for my producers too, since I have them stored in the Conductor field (yeah, I know... odd place, but it works for me), with a "PersonType=4" in place of "PersonType=1", woo, go me!
That's really only the beginning of the problems, I think, because in running the script over and over, I began to look closer at other numbers. Some of their purposes make no sense to me at all, or aren't acting as they should be expected to. Take for instance the "Top # Genre" columns. The regular "Top # Genre" and "Top # Genre played" entries are exactly the same. With 33,534 entries in my Played table and a tendency to play my Rap files more than my others, I know Rap should show more than being played 10,003 times when, you guessed it, I have 10,003 Rap files in my Genre, all of which have been played once, and some of which have been played upwards of 30 or 40 times. This Played entry doesn't act like the Artist played entry, which isn't really expected. My Top Artist only has 722 tracks in the library, but in the played entry, shows 3,709 plays, which if it acted like the Genre entry (which I don't think it should), it would only be showing 722 plays.
Another thing I find odd is the Averages section. Since I've played each track in my library once, the Average & Average Played columns show identical information, the only thing different is the "Played Per Day" entry for obvious reasons. Not really sure what this section was going for, but I would expect Played Averages to fluctuate with what I listen to, not to become static once I've played everything once, because then it's no longer relevant information because I could then just look at the Library entry. If my Year average is 1996, I would expect that if I play everything once, then the played Year Average would be 1996, but if I go playing a lot of 2008 files, then I would expect my continued listening to have some kind of impact, such as the average sliding more-so toward what I listen to most (since the older files would have one play each, while the newer ones would have more plays and thus would be closer to the average that I listen to)
After all, if I play two files, one from 1990 and one from 2008 each one time, the average would be 1999. If I then play that second file again, then the average of what I have played would actually be 2002, no? Not still 1999. It's late, so if my math is way off... oops.
Though, it's late, and I've been staring at VBScript coding for a while now (something I barely understand, and that would be stretching it), so maybe my mind has went off into loopy-land and I'm making no sense as everything is viewed as working perfectly fine to the rest of you. *shrugs*
PS -- Rating is the exact same way as Genre down in the Top # sections.
EDIT: I told you it was late, right? Cause I just realized that I had been messing with the Stats script that comes with Monkey, not your modified version. Haha. Though, I doubt you changed much in regards to what I pointed out, since your script when unfiltered presents the same results as the MM Bundled Version.
I got a little bored and did some digging around.
[code] 'Totals
strSQL = "SELECT Count(*) AS Nombre FROM Artists WHERE ID <> 0 AND Tracks>0" ' Track artists only
Set qryStats = SDB.Database.OpenSQL(strSQL)
intArtistsCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0))
' process background threads
SDB.ProcessMessages
strSQL = "SELECT Count(Distinct Artists.ID) AS CountOfID FROM Artists WHERE Artists.ID IN ( SELECT ArtistsSongs.IDArtist FROM ArtistsSongs WHERE ArtistsSongs.IDSong IN ( SELECT Played.IDSong FROM Played))"
Set qryStats = SDB.Database.OpenSQL(strSQL)
intArtistsCountPlayed = CLng(NoNull(qryStats.ValueByName("CountOfID"),0))[/code]
There's the code snippet from the original file. Looking at the SQL that finds the number of Artists in the library, it bases it off of the Artists.Tracks column, which a Person only has a number <> 0 in this column if they are an Artist for a track and not just a conductor or composer, etc (since they have their own columns). Thus, while it's only counting artists, the other that pulls the played one is pulling any person that has an entry in the Played table, regardless if they're a Artist, Conductor, etc. Toying with it, I got this to work as expected:
[code] 'Totals
strSQL = "SELECT Count(*) AS Nombre FROM Artists WHERE ID <> 0 AND Tracks>0" ' Track artists only
Set qryStats = SDB.Database.OpenSQL(strSQL)
intArtistsCount = CLng(NoNull(qryStats.ValueByName("Nombre"),0))
' process background threads
SDB.ProcessMessages
strSQL = "SELECT Count(Distinct Artists.ID) AS CountOfID FROM Artists WHERE Artists.ID IN ( SELECT ArtistsSongs.IDArtist FROM ArtistsSongs WHERE ArtistsSongs.IDSong IN ( SELECT Played.IDSong FROM Played) AND PersonType=1)"
Set qryStats = SDB.Database.OpenSQL(strSQL)
intArtistsCountPlayed = CLng(NoNull(qryStats.ValueByName("CountOfID"),0))[/code]
As you can see, I've added a "PersonType" clause to the Played SQL, which only accounts for people that are Artists (or I believe, Album Artists), which gives me a number that matches the one from the Library query. It seems the "Top Artists" problem can be fixed with a "PersonType" clause too:
Original:
[code] strSQL = "SELECT Sum(PlayCounter) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength, Artists.Artist "
strSQL = strSQL & "FROM ArtistsSongs, Songs, Artists "
strSQL = strSQL & "WHERE Songs.ID = ArtistsSongs.IDSong AND Songs.ID IN (SELECT Played.IDSong FROM Played) AND ArtistsSongs.IDArtist = Artists.ID "
strSQL = strSQL & "GROUP BY ArtistsSongs.IDArtist "
strSQL = strSQL & "ORDER BY Sum(PlayCounter) DESC LIMIT " & intTopCount & ""
Set qryStats = SDB.Database.OpenSQL(strSQL)
While Not qryStats.EOF
[/code]
Edit:
[code] strSQL = "SELECT Sum(PlayCounter) AS CountOfID, Sum(SongLength) AS TotalLength, Sum(FileLength) AS TotalFileLength, Artists.Artist "
strSQL = strSQL & "FROM ArtistsSongs, Songs, Artists "
strSQL = strSQL & "WHERE Songs.ID = ArtistsSongs.IDSong AND Songs.ID IN (SELECT Played.IDSong FROM Played) AND ArtistsSongs.IDArtist = Artists.ID AND ArtistsSongs.PersonType=1 "
strSQL = strSQL & "GROUP BY ArtistsSongs.IDArtist "
strSQL = strSQL & "ORDER BY Sum(PlayCounter) DESC LIMIT " & intTopCount & ""
Set qryStats = SDB.Database.OpenSQL(strSQL)
While Not qryStats.EOF
[/code]
Again, this returns expected results for me, the "Top # Artists" section now only lists Artists, so I no longer have a Top 10 where half of the entries are producers who rarely if ever appear in the Artist field. I went ahead and set up a Top 10 for my producers too, since I have them stored in the Conductor field (yeah, I know... odd place, but it works for me), with a "PersonType=4" in place of "PersonType=1", woo, go me! :P
That's really only the beginning of the problems, I think, because in running the script over and over, I began to look closer at other numbers. Some of their purposes make no sense to me at all, or aren't acting as they should be expected to. Take for instance the "Top # Genre" columns. The regular "Top # Genre" and "Top # Genre played" entries are exactly the same. With 33,534 entries in my Played table and a tendency to play my Rap files more than my others, I know Rap should show more than being played 10,003 times when, you guessed it, I have 10,003 Rap files in my Genre, all of which have been played once, and some of which have been played upwards of 30 or 40 times. This Played entry doesn't act like the Artist played entry, which isn't really expected. My Top Artist only has 722 tracks in the library, but in the played entry, shows 3,709 plays, which if it acted like the Genre entry (which I don't think it should), it would only be showing 722 plays.
Another thing I find odd is the Averages section. Since I've played each track in my library once, the Average & Average Played columns show identical information, the only thing different is the "Played Per Day" entry for obvious reasons. Not really sure what this section was going for, but I would expect Played Averages to fluctuate with what I listen to, not to become static once I've played everything once, because then it's no longer relevant information because I could then just look at the Library entry. If my Year average is 1996, I would expect that if I play everything once, then the played Year Average would be 1996, but if I go playing a lot of 2008 files, then I would expect my continued listening to have some kind of impact, such as the average sliding more-so toward what I listen to most (since the older files would have one play each, while the newer ones would have more plays and thus would be closer to the average that I listen to)
After all, if I play two files, one from 1990 and one from 2008 each one time, the average would be 1999. If I then play that second file again, then the average of what I have played would actually be 2002, no? Not still 1999. It's late, so if my math is way off... oops.
Though, it's late, and I've been staring at VBScript coding for a while now (something I barely understand, and that would be stretching it), so maybe my mind has went off into loopy-land and I'm making no sense as everything is viewed as working perfectly fine to the rest of you. *shrugs*
PS -- Rating is the exact same way as Genre down in the Top # sections.
EDIT: I told you it was late, right? Cause I just realized that I had been messing with the Stats script that comes with Monkey, not your modified version. Haha. Though, I doubt you changed much in regards to what I pointed out, since your script when unfiltered presents the same results as the MM Bundled Version.