Git Product home page Git Product logo

lexorank's People

Contributors

bookis avatar dependabot-preview[bot] avatar richardboehme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

lexorank's Issues

Add JRuby to Github Workflow

The current ruby testing workflow of this repository does not mention any JRuby implementations, because sqlite3 needs native extensions that are not supported by JRuby.

To make sure that the gem works with JRuby we should add it to the automated Github workflow.

Add custom `lexorank` column to ActiveRecord

To avoid confusion with the setup of column collations, that is needed to use this gem, it should be as simple as using

class AddRankToPages < ActiveRecord::Migration[7.0]
  def change
    add_column :pages, :rank, :lexorank
    add_index :pages, :rank, unique: true
  end
end

or

$ rails g migration AddRankTo<insert model name here> rank:lexorank:uniq

This can be achieved by adding a custom column type to ActiveRecord. An example can be found in the Money-Rails gem.

ActiveRecord::StatementInvalid: Mysql2::Error: BLOB/TEXT column 'rank' used in key specification without a key length

Well done on putting together this gem. It's something I've theorised about with others as I maintain the acts_as_list and ranked-model gems and both have their downsides. Lexical ranking is kind of like what ranked-model does but with more sparseness between ranks. One of the keys to limiting the amount of rebalancing is to not just go for 50% between surrounding ranks but rather have the concept of a minimum gap. If one doesn't do that in ranked-model land we run out of ranks and have to rebalance after 30 or so appends to the end of the list. Anyway, just something to think about. I haven't actually implemented this in ranked-model yet. It's a bit off topic lol! :)

I had a go at creating a migration on MySQL but got the following error:

ActiveRecord::StatementInvalid: Mysql2::Error: BLOB/TEXT column 'rank' used in key specification without a key length

It seems that indexing a variable length text column isn't possible in MySQL? Have you run into this on your end?

PostgreSQL sorting based on LC_COLLATE causes issues when not using `C`

First of all thanks a lot for this gem :)

This is not really a bug report, but rather a summary of an issue I've stumbled across. I'm not an DB expert and therefore not 100% certain if all this is correct. But, maybe it helps others how run into the same issue.

After integrating your gem everything worked correctly in development/test environment on my local laptop. But, when deploying to Heroku on production it raised duplicate entry errors caused by the unique index on the "rank" column. This was indirectly caused by the wrong sorting order.

On Heroku PostgreSQL LC_COLLATE is set to en_US.UTF-8. But, on my laptop it is set to C.

When using C the sorting order is (I think) what we want, where uppercase letters come before lowercase letters. But, when using en_US.UTF-8 the sorting order is different.

One can solve this at query time in sql order by rank collate "C" asc or in ruby order(Arel.sql('rank collate "C" asc')).

Alternatively, the column collate value can be changed with a migration:

ALTER TABLE items ALTER COLUMN rank TYPE varchar COLLATE "C";

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.