Merge branch 'fix-search-order' into 'master'

Fix search order

See merge request framasoft/mobilizon!790
This commit is contained in:
Thomas Citharel 2021-01-14 16:28:29 +01:00
commit 6cff21868e
4 changed files with 34 additions and 30 deletions

View File

@ -3,8 +3,9 @@ image: tcitworld/mobilizon-ci
stages: stages:
- install - install
- check - check
- build - build-js
- test - test
- docker
- package - package
- upload - upload
- deploy - deploy
@ -50,6 +51,8 @@ install:
lint-elixir: lint-elixir:
stage: check stage: check
before_script:
- mix deps.get
script: script:
- export EXITVALUE=0 - export EXITVALUE=0
- mix credo --strict -a || export EXITVALUE=1 - mix credo --strict -a || export EXITVALUE=1
@ -57,21 +60,24 @@ lint-elixir:
- exit $EXITVALUE - exit $EXITVALUE
lint-front: lint-front:
image: node:14
stage: check stage: check
before_script: before_script:
- export EXITVALUE=0 - export EXITVALUE=0
- cd js - yarn --cwd "js" install --frozen-lockfile
script: script:
- yarn run lint || export EXITVALUE=1 - yarn --cwd "js" run lint || export EXITVALUE=1
- yarn run prettier -c . || export EXITVALUE=1 - yarn --cwd "js" run prettier -c . || export EXITVALUE=1
- exit $EXITVALUE - exit $EXITVALUE
build-frontend: build-frontend:
stage: build stage: build-js
image: node:14
before_script: before_script:
- apt update - apt update
- apt install -y --no-install-recommends python build-essential webp imagemagick gifsicle jpegoptim optipng pngquant - apt install -y --no-install-recommends python build-essential webp imagemagick gifsicle jpegoptim optipng pngquant
script: script:
- yarn --cwd "js" install --frozen-lockfile
- yarn --cwd "js" run build - yarn --cwd "js" run build
artifacts: artifacts:
expire_in: 5 days expire_in: 5 days
@ -82,6 +88,8 @@ build-frontend:
deps: deps:
stage: check stage: check
before_script:
- mix deps.get
script: script:
- export EXITVALUE=0 - export EXITVALUE=0
- mix hex.outdated || export EXITVALUE=1 - mix hex.outdated || export EXITVALUE=1
@ -99,6 +107,7 @@ exunit:
variables: variables:
MIX_ENV: test MIX_ENV: test
before_script: before_script:
- mix deps.get
- mix ecto.create - mix ecto.create
- mix ecto.migrate - mix ecto.migrate
script: script:
@ -114,6 +123,8 @@ jest:
stage: test stage: test
needs: needs:
- lint-front - lint-front
before_script:
- yarn --cwd "js" install --frozen-lockfile
script: script:
- yarn --cwd "js" run test:unit --no-color --ci --reporters=default --reporters=jest-junit - yarn --cwd "js" run test:unit --no-color --ci --reporters=default --reporters=jest-junit
artifacts: artifacts:
@ -146,14 +157,12 @@ jest:
# - js/tests/e2e/screenshots/**/*.png # - js/tests/e2e/screenshots/**/*.png
# - js/tests/e2e/videos/**/*.mp4 # - js/tests/e2e/videos/**/*.mp4
# pages: pages:
# stage: deploy stage: deploy
# script: script:
# # - mkdir public - mkdir public
# # Mobilizon documentation is now on https://framagit.org/framasoft/joinmobilizon/documentation - mix docs
# # Mix docs disabled because of https://github.com/elixir-lang/ex_doc/issues/1172 - mv doc public/backend
# # - mix docs
# # - mv doc public/backend
# #- yarn run --cwd "js" styleguide:build # #- yarn run --cwd "js" styleguide:build
# #- mv js/styleguide public/frontend # #- mv js/styleguide public/frontend
# rules: # rules:
@ -164,7 +173,7 @@ jest:
# - public # - public
.docker: &docker .docker: &docker
stage: build stage: docker
cache: {} cache: {}
image: image:
name: gcr.io/kaniko-project/executor:debug name: gcr.io/kaniko-project/executor:debug

View File

@ -261,10 +261,12 @@
</div> </div>
<b-message v-else type="is-danger" <b-message v-else type="is-danger"
>{{ $t("No events found") }}<br /> >{{ $t("No events found") }}<br />
<b-icon size="is-small" icon="information-outline" /> <div v-if="goingToEvents.size > 0 || lastWeekEvents.length > 0">
<small v-if="goingToEvents.size > 0 || lastWeekEvents.length > 0">{{ <b-icon size="is-small" icon="information-outline" />
$t("The events you created are not shown here.") <small>{{
}}</small> $t("The events you created are not shown here.")
}}</small>
</div>
</b-message> </b-message>
</section> </section>
</div> </div>

View File

@ -1340,19 +1340,12 @@ defmodule Mobilizon.Events do
end end
@spec events_for_search_query(String.t()) :: Ecto.Query.t() @spec events_for_search_query(String.t()) :: Ecto.Query.t()
defp events_for_search_query(""), do: Event
defp events_for_search_query(search_string) do defp events_for_search_query(search_string) do
Event from(event in Event,
|> do_event_for_search_query(search_string)
end
@spec do_event_for_search_query(Ecto.Query.t(), String.t()) :: Ecto.Query.t()
defp do_event_for_search_query(query, ""), do: query
defp do_event_for_search_query(query, search_string) do
from(event in query,
join: id_and_rank in matching_event_ids_and_ranks(search_string), join: id_and_rank in matching_event_ids_and_ranks(search_string),
on: id_and_rank.id == event.id, on: id_and_rank.id == event.id
order_by: [desc: id_and_rank.rank]
) )
end end

View File

@ -2,6 +2,6 @@
== ==
<%= gettext "%{name} (%{domain}) just requested to follow your instance.", name: @follower.name, domain: @follower.domain %> <%= gettext "%{name} (%{domain}) just requested to follow your instance.", name: @follower.name, domain: @follower.domain %>
<%= gettext "If you accept, this instance will receive all of your public events." %> <%= gettext "If you accept, this instance will receive all of your public events." %>
<%= gettext "Note: %{name} (%{domain}) following you doesn't necessarily imply that you follow this instance, but you can ask to follow them too." %> <%= gettext "Note: %{name} (%{domain}) following you doesn't necessarily imply that you follow this instance, but you can ask to follow them too.", name: @follower.name, domain: @follower.domain %>
<%= gettext "To accept this invitation, head over to the instance's admin settings." %> <%= gettext "To accept this invitation, head over to the instance's admin settings." %>
<%= "#{Mobilizon.Web.Endpoint.url()}/settings/admin/relays/followers" %> <%= "#{Mobilizon.Web.Endpoint.url()}/settings/admin/relays/followers" %>