google-code-export / bibapp

Automatically exported from code.google.com/p/bibapp
Other
0 stars 0 forks source link

All Publications listed if any publication has no name #176

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Add a publication with an empty name
2.Go to publications
3.

What is the expected output? What do you see instead?
I expect to see some list of publications (that list might be up for debate), 
but not ALL publications. That takes several minutes to load when you have 
thousands of publication records.
One solution is to make the following change in models>publication.rb, line 189:
  class << self

    # return the first letter of each name, ordered alphabetically
    def letters
      find(
        :all,
        :select => 'DISTINCT SUBSTR(name, 1, 1) AS letter',
        :conditions => 'LENGTH(name) > 0',  #KUMC.JTS prevents returning the whole list for @page
        :order  => 'letter'
      )
    end

The condition above prevents @page from being empty when @page=@a_to_z in 
publications_controller.rb:

@current_objects = Publication.find(
          :all,
          :conditions => ["publications.id = authority_id and upper(name) like ?", "#{@page}%"],
          :order => "upper(name)"
        )

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by stirnam...@gmail.com on 21 Sep 2010 at 7:51

GoogleCodeExporter commented 9 years ago
As far as I can tell, this is still a problem. Sure, it's a problem only if 
you're data is ugly, but that's a problem, too.  I just pushed a commit to my 
Bibapp fork that replaces the SQL condition I suggested earlier with a change 
in publications_controller.rb: 
https://github.com/jstirnaman/BibApp/commit/503c7a0fc30559461860e153a3c59601da52
d44a
Using LENGTH() in the letters method seemed too database-dependent and I 
couldn't come up with a better ActiveRecord way.
What I'm wondering is whether the database or the model shouldn't be allowing 
empty or whitespace values as Publication name. We've had names that are 
zero-length strings, spaces, and tabs. The zero-length string is the one that 
causes all records to be returned in @current_objects.
Jason

Original comment by stirnam...@gmail.com on 3 Mar 2011 at 4:53

GoogleCodeExporter commented 9 years ago
https://github.com/jstirnaman/BibApp/commits/person_is_active_1.0

Original comment by stirnam...@gmail.com on 7 Mar 2011 at 6:15