Add a random order for initial page load.

main
Joshua Potter 2023-12-07 08:12:32 -07:00
parent 8d7a2e4853
commit 2e7efa5c49
3 changed files with 16 additions and 3 deletions

View File

@ -86,7 +86,7 @@ defmodule BoardWise.Coaches do
|> selected_as(:score)
}
)
|> order_by(desc: selected_as(:score), asc: :username)
|> order_by(desc: selected_as(:score), asc: :position, asc: :username, asc: :id)
|> limit(^page_size)
|> offset(^((page_no - 1) * page_size))
|> Repo.all(prefix: @prefix)

View File

@ -24,9 +24,10 @@ defmodule BoardWise.Coaches.Coach do
field :image_url, :string
field :title, :string
field :languages, {:array, :string}
field :rapid, :integer
field :blitz, :integer
field :bullet, :integer
field :rapid, :integer
field :position, :integer
# virtual fields
field :score, :integer, virtual: true
@ -44,7 +45,8 @@ defmodule BoardWise.Coaches.Coach do
:languages,
:rapid,
:blitz,
:bullet
:bullet,
:position
])
|> validate_required([:site, :username])
|> unique_constraint(:site_username_unique, name: :site_username_unique)

View File

@ -0,0 +1,11 @@
defmodule BoardWise.Repo.Migrations.Position do
use Ecto.Migration
@prefix "coach_scraper"
def change do
alter table(:export, prefix: @prefix) do
add :position, :integer
end
end
end