duplicate works query and status

1 view
Skip to first unread message

Jason Stirnaman

unread,
May 1, 2012, 1:53:54 PM5/1/12
to bibap...@googlegroups.com
Howard,
I'm trying to write some tests around matching and merging duplicates. I'm not sure if I'm misunderstanding the way duplicates methods work in index.rb, or the way states get assigned to works, or if I'm not testing what I think I'm testing, or if possible_unaccepted_duplicates method doesn't work as expected.

I'd appreciate your suggestions if you have time. Thanks.

One problem I'm having is that while this returns results as I'd expect:
 Index.fetch("title:#{@work[:title_primary]} AND (#{Work.solr_duplicate_filter})",[],"year","descending",0,0,10)

calling this method returns empty:
Index.possible_unaccepted_duplicate_works(@work)

For the case below, I'd expect that method to return the same results as the query.

Here's some (verbose) sample code:
      # Create a work

      @work = Factory.create(:work, :title_primary => 'Work Title 1', :abstract => 'The abstract of my work.'

                :volume => '1')          

      name_string = Factory.create(:name_string, :name => 'Name String Name')

      Factory.create(:work_name_string, :work => @work, :name_string => name_string)

       #   Create a second work with the same values          

      @work2 = Factory.create(:work, :title_primary => @work[:title_primary], :abstract => @work[:abstract], 

                :volume => @work[:volume])

      @work2.name_strings = @work.name_strings

      

      # Set duplicate state manually

      @work.work_state_id = Work::STATE_DUPLICATE

      @work2.work_state_id = Work::STATE_DUPLICATE

      

      @work.save

      @work2.save      

      # Retrieve duplicate matches using a query similar to the methods in index.rb. This returns duplicates as expected.

      Index.fetch("title:#{@work[:title_primary]} AND (#{Work.solr_duplicate_filter})",[],"year","descending",0,0,10).size.should be > 1

      # possible_accepted_duplicates method in index.rb. This passes, i.e. no matches. I'd expect that... I think.

      Index.possible_accepted_duplicates(@work).size.should eq 0

     # possible_unaccepted_duplicates method in index.rb This fails, i.e. still no matches.  I wouldn't expect that; I'd expect at least 2 works to be found here.

      Index.possible_unaccepted_duplicate_works(@work).size.should be > 1

Reply all
Reply to author
Forward
0 new messages