1. heliostatic
  2. ebook-renamer

Commits

heliostatic  committed 0c16598

gentle cleanup of cleaner

  • Participants
  • Parent commits 41732aa
  • Branches master

Comments (0)

Files changed (1)

File lib/extensions/book_cleaner.rb

View file
 
   module ClassMethods
     def full_search(number_to_check=500)
-      cache = Book.select('DISTINCT author').where('author IS NOT NULL').where('for_review IS NOT TRUE').order(:author).map(&:author)
+      cache = Book.all_authors
       self.no_title.where(for_review: nil).limit(number_to_check).each do |b|
         b.bulk_guess_fields(cache, true)
       end
       if @cache
         author = f if @cache.include?(f)
         author = flip_and_strip(f) if @cache.include?(flip_and_strip(f))
-        if self.author.nil?
-          self.update_attributes(author: author) if author
-        end 
       else
         author = f if Book.where(author: f).where('for_review IS NOT TRUE').any?
         author = flip_and_strip(f) if Book.where(author: flip_and_strip(f)).where('for_review IS NOT TRUE').any?
-        if self.author.nil?
-          self.update_attributes(author: author) if author
-        end 
-      end     
+      end    
+      if self.author.nil?
+        self.update_attributes(author: author) if author
+      end  
       author
     end