Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relevant search issue #143

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/danger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Danger
on: [pull_request]
jobs:
danger:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- run: |
# Personal access token for dangerpr-bot - public, but base64 encoded to avoid tripping up GitHub
TOKEN=$(echo -n Z2hwX0xNQ3VmanBFeTBvYkZVTWh6NVNqVFFBOEUxU25abzBqRUVuaAo= | base64 --decode)
DANGER_GITHUB_API_TOKEN=$TOKEN bundle exec danger --verbose
13 changes: 13 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Rubocop
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- run: bundle exec rubocop
61 changes: 61 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Test

on: [push, pull_request]

jobs:
test:

strategy:
fail-fast: false
matrix:
entry:
- { ruby: '2.6.6', mongo: 'mongo:4.4', mongoid: '5' }
# - { ruby: 'jruby-9.1.17.0', mongo: 'mongo:4.4', mongoid: '5' }
- { ruby: 'jruby-9.2.11.1', mongo: 'mongo:4.4', mongoid: '5' }
- { ruby: '2.6.6', mongo: 'mongo:4.4', mongoid: '6' }
- { ruby: '2.7.1', mongo: 'mongo:4.4', mongoid: '6' }
- { ruby: '3.0.5', mongo: 'mongo:4.4', mongoid: '6' }
- { ruby: '3.1.3', mongo: 'mongo:4.4', mongoid: '6' }
- { ruby: 'jruby-9.2.11.1', mongo: 'mongo:4.4', mongoid: '6' }
- { ruby: '2.6.6', mongo: 'mongo:4.4', mongoid: '7', coverage: 'true' }
- { ruby: '2.7.1', mongo: 'mongo:4.4', mongoid: '7' }
- { ruby: '3.0.5', mongo: 'mongo:4.4', mongoid: '7' }
- { ruby: '3.1.3', mongo: 'mongo:4.4', mongoid: '7' }
- { ruby: 'jruby-9.2.11.1', mongo: 'mongo:4.4', mongoid: '7' }
- { ruby: '2.6.6', mongo: 'mongo:4.4', mongoid: '8' }
- { ruby: '2.7.1', mongo: 'mongo:4.4', mongoid: '8' }
- { ruby: '3.0.5', mongo: 'mongo:4.4', mongoid: '8' }
- { ruby: '3.1.3', mongo: 'mongo:4.4', mongoid: '8' }
experimental: [false]

name: test (ruby=${{ matrix.entry.ruby }}, mongo=${{ matrix.entry.mongo }}, mongoid=${{ matrix.entry.mongoid }})
runs-on: ubuntu-latest

continue-on-error: ${{ matrix.experimental }}

services:
mongo:
image: ${{ matrix.entry.mongo }}
ports: ["27017:27017"]

env:
MONGOID_VERSION: ${{ matrix.entry.mongoid }}
COVERAGE: ${{ matrix.entry.coverage }}

steps:
- uses: actions/checkout@v3

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.entry.ruby }}
bundler-cache: true

- name: Run tests
run: bundle exec rspec

- name: Code Climate
if: ${{ env.CC_TEST_REPORTER_ID != '' && success() && matrix.entry.coverage == 'true' }}
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ vars.CC_TEST_REPORTER_ID }}
2 changes: 1 addition & 1 deletion lib/mongoid_search/mongoid_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def search_without_relevance(query, options)
end

def search_relevant(query, options)
results_with_relevance(query, options).sort { |o| o['value'] }.map do |r|
results_with_relevance(query, options) { |o| o['value'] }.map do |r|
new(r['_id'].merge(relevance: r['value'])) do |o|
# Need to match the actual object
o.instance_variable_set('@new_record', false)
Expand Down