Merge branch 'search-fixes' into 'main'

Don't add empty search parameters to global search engine

See merge request framasoft/mobilizon!1289
This commit is contained in:
Thomas Citharel 2022-10-12 18:03:44 +00:00
commit 199add5743
8 changed files with 45 additions and 65 deletions

View File

@ -342,11 +342,9 @@ multi-arch-release:
- ARCH: ["arm", "arm64"]
rules:
# arm64 is allowed to fail
- if: '$CI_PROJECT_NAMESPACE == "framasoft" && $CI_PIPELINE_SOURCE == "schedule" && $ARCH == "arm64"'
when: on_success
- if: '$CI_PROJECT_NAMESPACE == "framasoft" && ($CI_PIPELINE_SOURCE == "schedule" || $CI_COMMIT_TAG != null) && $ARCH == "arm64"'
allow_failure: true
- if: '$CI_PROJECT_NAMESPACE == "framasoft" && $CI_PIPELINE_SOURCE == "schedule" && $ARCH'
when: on_success
- if: '$CI_PROJECT_NAMESPACE == "framasoft" && ($CI_PIPELINE_SOURCE == "schedule" || $CI_COMMIT_TAG != null) && $ARCH'
allow_failure: false
timeout: 3h
allow_failure: true

View File

@ -20,7 +20,6 @@
"@absinthe/socket": "^0.2.1",
"@absinthe/socket-apollo-link": "^0.2.1",
"@apollo/client": "^3.3.16",
"@headlessui/vue": "^1.6.7",
"@oruga-ui/oruga-next": "^0.5.5",
"@sentry/tracing": "^7.1",
"@sentry/vue": "^7.1",
@ -58,8 +57,6 @@
"apollo-absinthe-upload-link": "^1.5.0",
"autoprefixer": "^10",
"blurhash": "^2.0.0",
"bulma": "^0.9.4",
"bulma-divider": "^0.2.0",
"date-fns": "^2.16.0",
"date-fns-tz": "^1.1.6",
"floating-vue": "^2.0.0-beta.17",
@ -85,7 +82,6 @@
"vue-i18n": "9",
"vue-material-design-icons": "^5.1.2",
"vue-matomo": "^4.1.0",
"vue-meta": "^2.3.1",
"vue-plausible": "^1.3.1",
"vue-router": "4",
"vue-scrollto": "^2.17.1",

View File

@ -377,7 +377,6 @@ const isConnected = computed((): boolean => {
<style lang="scss" scoped>
// @use "@/styles/_mixins" as *;
// // @import "node_modules/bulma/sass/utilities/mixins.sass";
// form.new-comment {
// padding-bottom: 1rem;

View File

@ -85,7 +85,6 @@ const isBeforeLastWeek = computed((): boolean => {
</script>
<style lang="scss" scoped>
@use "@/styles/_mixins" as *;
// @import "node_modules/bulma/sass/utilities/mixins.sass";
// .post-minimalist-card-wrapper {
// display: grid;

View File

@ -188,12 +188,7 @@ import {
EVENT_PERSON_PARTICIPATION,
// EVENT_PERSON_PARTICIPATION_SUBSCRIPTION_CHANGED,
} from "@/graphql/event";
import {
displayName,
IActor,
IPerson,
usernameWithDomain,
} from "@/types/actor";
import { displayName, IPerson, usernameWithDomain } from "@/types/actor";
import DateCalendarIcon from "@/components/Event/DateCalendarIcon.vue";
import MultiCard from "@/components/Event/MultiCard.vue";
import RouteName from "@/router/name";

View File

@ -512,17 +512,6 @@
:isLoggedIn="currentUser?.isLoggedIn"
mode="row"
/>
<o-pagination
v-if="searchGroups && searchGroups?.total > GROUP_PAGE_LIMIT"
:total="searchGroups?.total"
v-model:current="groupPage"
:per-page="GROUP_PAGE_LIMIT"
:aria-next-label="t('Next page')"
:aria-previous-label="t('Previous page')"
:aria-page-label="t('Page')"
:aria-current-label="t('Current page')"
>
</o-pagination>
</div>
<o-notification v-else-if="searchLoading === false" variant="danger">
{{ t("No groups found") }}
@ -539,18 +528,22 @@
}"
class="my-4"
/>
<o-pagination
v-if="searchEvents && searchEvents?.total > EVENT_PAGE_LIMIT"
:total="searchEvents.total"
v-model:current="eventPage"
:per-page="EVENT_PAGE_LIMIT"
:aria-next-label="t('Next page')"
:aria-previous-label="t('Previous page')"
:aria-page-label="t('Page')"
:aria-current-label="t('Current page')"
>
</o-pagination>
</div>
<o-pagination
v-if="
(searchEvents && searchEvents?.total > EVENT_PAGE_LIMIT) ||
(searchGroups && searchGroups?.total > GROUP_PAGE_LIMIT)
"
:total="
Math.max(searchEvents?.total ?? 0, searchGroups?.total ?? 0)
"
v-model:current="page"
:per-page="EVENT_PAGE_LIMIT"
:aria-next-label="t('Next page')"
:aria-previous-label="t('Previous page')"
:aria-page-label="t('Page')"
:aria-current-label="t('Current page')"
/>
<o-notification v-else-if="searchLoading === false" variant="info">
<p>{{ t("No events found") }}</p>
<p v-if="searchIsUrl && !currentUser?.id">
@ -770,6 +763,7 @@ const arrayTransformer: RouteQueryTransformer<string[]> = {
},
};
const page = useRouteQuery("page", 1, integerTransformer);
const eventPage = useRouteQuery("eventPage", 1, integerTransformer);
const groupPage = useRouteQuery("groupPage", 1, integerTransformer);
@ -783,6 +777,21 @@ const contentType = useRouteQuery(
ContentType.ALL,
enumTransformer(ContentType)
);
watch(contentType, (newContentType: ContentType) => {
switch (newContentType) {
case ContentType.ALL:
page.value = 1;
break;
case ContentType.EVENTS:
eventPage.value = 1;
break;
case ContentType.GROUPS:
groupPage.value = 1;
break;
}
});
const isOnline = useRouteQuery("isOnline", false, booleanTransformer);
const categoryOneOf = useRouteQuery("categoryOneOf", [], arrayTransformer);
const statusOneOf = useRouteQuery(
@ -1168,8 +1177,10 @@ const { result: searchElementsResult, loading: searchLoading } = useQuery<{
beginsOn: start.value,
endsOn: end.value,
radius: geoHashLocation.value ? radius.value : undefined,
eventPage: eventPage.value,
groupPage: groupPage.value,
eventPage:
contentType.value === ContentType.ALL ? page.value : eventPage.value,
groupPage:
contentType.value === ContentType.ALL ? page.value : groupPage.value,
limit: EVENT_PAGE_LIMIT,
type: isOnline.value ? "ONLINE" : undefined,
categoryOneOf: categoryOneOf.value,

View File

@ -1073,11 +1073,6 @@
resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.1.1.tgz#076d78ce99822258cf813ecc1e7fa460fa74d052"
integrity sha512-NQ17ii0rK1b34VZonlmT2QMJFI70m0TRwbknO/ihlbatXyaktDhN/98vBiUU6kNBPljqGqyIrl2T4nY2RpFANg==
"@headlessui/vue@^1.6.7":
version "1.7.3"
resolved "https://registry.yarnpkg.com/@headlessui/vue/-/vue-1.7.3.tgz#116d13391552436ea1e9e88c69f0e9d7d2585c45"
integrity sha512-Is4iakKts9u9E0+jEZNzoJpBjwq2SamwEIoEl2RlyYSu6Zco536GsPXaQEfg/o7Eyc1GUUlcL+dJd4Rt7qyf7A==
"@histoire/app@^0.11.3":
version "0.11.3"
resolved "https://registry.yarnpkg.com/@histoire/app/-/app-0.11.3.tgz#6b353a4b60a61eef4170c6c91e8e997d69caf0bc"
@ -2546,16 +2541,6 @@ builtin-modules@^3.1.0:
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.3.0.tgz#cae62812b89801e9656336e46223e030386be7b6"
integrity sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==
bulma-divider@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/bulma-divider/-/bulma-divider-0.2.0.tgz#a9b4d9fe8b270c7cb7573023c575062bc62616f3"
integrity sha512-REe3k56GECRfDaqFjC8cwLhV4RxXmV0RubuzDJqwior9wlJcdHlN0qfW0tvUX+qphikaTQegIeRuhjRIAqkjkw==
bulma@^0.9.4:
version "0.9.4"
resolved "https://registry.yarnpkg.com/bulma/-/bulma-0.9.4.tgz#0ca8aeb1847a34264768dba26a064c8be72674a1"
integrity sha512-86FlT5+1GrsgKbPLRRY7cGDg8fsJiP/jzTqXXVqiUZZ2aZT8uemEOHlU1CDU+TxklPEZ11HZNNWclRBBecP4CQ==
c8@^7.12.0:
version "7.12.0"
resolved "https://registry.yarnpkg.com/c8/-/c8-7.12.0.tgz#402db1c1af4af5249153535d1c84ad70c5c96b14"
@ -6404,13 +6389,6 @@ vue-matomo@^4.1.0:
resolved "https://registry.yarnpkg.com/vue-matomo/-/vue-matomo-4.2.0.tgz#d65e369e4ead1d95ef790bef3627512cac3d25e9"
integrity sha512-m5hCw7LH3wPDcERaF4sp/ojR9sEx7Rl8TpOyH/4jjQxMF2DuY/q5pO+i9o5Dx+BXLSa9+IQ0qhAbWYRyESQXmA==
vue-meta@^2.3.1:
version "2.4.0"
resolved "https://registry.yarnpkg.com/vue-meta/-/vue-meta-2.4.0.tgz#a419fb4b4135ce965dab32ec641d1989c2ee4845"
integrity sha512-XEeZUmlVeODclAjCNpWDnjgw+t3WA6gdzs6ENoIAgwO1J1d5p1tezDhtteLUFwcaQaTtayRrsx7GL6oXp/m2Jw==
dependencies:
deepmerge "^4.2.2"
vue-plausible@^1.3.1:
version "1.3.2"
resolved "https://registry.yarnpkg.com/vue-plausible/-/vue-plausible-1.3.2.tgz#c797ee03a7c8849dc847e706c5250aa10908dd0f"

View File

@ -70,7 +70,7 @@ defmodule Mobilizon.Service.GlobalSearch.SearchMobilizon do
:count,
:sortBy
])
|> Keyword.reject(fn {_key, val} -> is_nil(val) end)
|> Keyword.reject(fn {_key, val} -> is_nil(val) or val == "" end)
events_url = "#{search_endpoint()}#{@search_events_api}?#{encode(options)}"
Logger.debug("Calling global search engine url #{events_url}")
@ -117,7 +117,7 @@ defmodule Mobilizon.Service.GlobalSearch.SearchMobilizon do
:bbox,
:sortBy
])
|> Keyword.reject(fn {_key, val} -> is_nil(val) end)
|> Keyword.reject(fn {_key, val} -> is_nil(val) or val == "" end)
groups_url = "#{search_endpoint()}#{@search_groups_api}?#{encode(options)}"
Logger.debug("Calling global search engine url #{groups_url}")
@ -187,7 +187,11 @@ defmodule Mobilizon.Service.GlobalSearch.SearchMobilizon do
ends_on: parse_date(data["endTime"]),
url: data["url"],
picture: picture,
category: String.to_existing_atom(Categories.get_category(data["category"])),
category:
data["category"]
|> Categories.get_category()
|> String.downcase()
|> String.to_existing_atom(),
organizer_actor: %Actor{
id: data["creator"]["id"],
name: data["creator"]["displayName"],