How to contribute

Copy Markdown

Report a bug or a problem

Report in the issue tracker at https://codeberg.org/ArthurClemens/refine/issues

Suggest a code improvement

  • Set up your development environment - see below.
  • Create a branch with your code changes.
  • Make sure to run tests to ensure new code won't break them. When adding code, fix current tests when needed, or add new tests.
  • Run mix qa to perform formatting and checks.
  • Open a new pull request at https://codeberg.org/ArthurClemens/refine/pulls.

Development environment

Setup

Clone this repository.

mix deps.get
mix init_dev_repo
iex -S mix

Add test data

alias Refine.Test.{Database, Factory}
alias Refine.Dev.Repo

Database.init()
Factory.init_resources(article_count: 10)

Create a facets table. Below is a simple example; see the tests for more examples.

alias Refine.Dev.Repo

config = %{
  facets_table: "articles_facets",
  source_table: "articles",
  add_identity_column_if_not_exists: true,
  identity_column: "identity",
  facets: [
    %{facet_name: "draft"}
  ]
}

Refine.create_facets_table(config, repo: Repo)

When starting an iex session from here, first start the database:

alias Refine.Test.Database

Database.start()

Minimal example:

alias Refine.Dev.Repo

Refine.search(config, repo: Repo)

Search with options:

import Ecto.Query
alias Refine.Dev.Repo

term = "%memory%"
base_query = from a in Refine.Test.EctoSchemas.Article,
  where: ilike(a.title, ^term) or ilike(a.summary, ^term),
  select: %{id: a.id, title: a.title, summary: a.summary, draft: a.draft}
facets = %{draft: ["true"]}

Refine.search(config, base_query: base_query, facets: facets, repo: Repo)