Chained scopes with "$nin" does not group values together.

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Major - P3
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Both scopes without_bad_urls and unscraped_diffbot are checking an array field (parsing_tags) for a specific value, but are not combined when chained. The last scope is the only one added.

      Unable to find source-code formatter for language: `ruby. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      irb(main):004:0> page_detail = PageDetail.missing_attrs.without_bad_urls.unscraped_diffbot
      => #<Mongoid::Criteria
        selector: {"$or"=>[{"author"=>nil}, {"title"=>nil}, {"keywords"=>nil}, {"keywords"=>{"$size"=>0}}, {"wordcount"=>nil}], "parsing_tags"=>{"$nin"=>["diffbot_scraped"]}}
        options:  {}
        class:    PageDetail
        embedded: false>
      
      irb(main):005:0> page_detail = PageDetail.missing_attrs.without_bad_urls
      => #<Mongoid::Criteria
        selector: {"$or"=>[{"author"=>nil}, {"title"=>nil}, {"keywords"=>nil}, {"keywords"=>{"$size"=>0}}, {"wordcount"=>nil}], "parsing_tags"=>{"$nin"=>["bad url"]}}
        options:  {}
        class:    PageDetail
        embedded: false>
      
      irb(main):006:0> page_detail = PageDetail.missing_attrs.unscraped_diffbot.without_bad_urls
      => #<Mongoid::Criteria
        selector: {"$or"=>[{"author"=>nil}, {"title"=>nil}, {"keywords"=>nil}, {"keywords"=>{"$size"=>0}}, {"wordcount"=>nil}], "parsing_tags"=>{"$nin"=>["bad url"]}}
        options:  {}
        class:    PageDetail
        embedded: false>
      
      irb(main):007:0> reload!
      Reloading...
      => true
      irb(main):008:0> page_detail = PageDetail.missing_attrs.without_bad_urls.unscraped_diffbot                                                                                                                                                                                                                                                                                  
      => #<Mongoid::Criteria
        selector: {"$or"=>[{"author"=>nil}, {"title"=>nil}, {"keywords"=>nil}, {"keywords"=>{"$size"=>0}}, {"wordcount"=>nil}], "parsing_tags"=>{"$nin"=>["diffbot_scraped"]}}
        options:  {}
        class:    PageDetail
        embedded: false>
      
      

      `

      not sure if this affects other scopes on Array fields

            Assignee:
            Dianna Hohensee (Inactive)
            Reporter:
            lorgio
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: