diff --git a/js/src/i18n/en_US.json b/js/src/i18n/en_US.json index c7459ab08..43630c71d 100644 --- a/js/src/i18n/en_US.json +++ b/js/src/i18n/en_US.json @@ -1232,5 +1232,6 @@ "This profile is from another instance, the informations shown here may be incomplete.": "This profile is from another instance, the informations shown here may be incomplete.", "View full profile": "View full profile", "Any type": "Any type", - "In person": "In person" + "In person": "In person", + "In the past": "In the past" } diff --git a/js/src/i18n/fr_FR.json b/js/src/i18n/fr_FR.json index 1b92dcdfc..48bae4f31 100644 --- a/js/src/i18n/fr_FR.json +++ b/js/src/i18n/fr_FR.json @@ -1336,5 +1336,6 @@ "This profile is from another instance, the informations shown here may be incomplete.": "Ce profil provient d'une autre instance, les informations montrées ici peuvent être incomplètes.", "View full profile": "Voir le profil complet", "Any type": "N'importe quel type", - "In person": "En personne" + "In person": "En personne", + "In the past": "Dans le passé" } diff --git a/js/src/views/Search.vue b/js/src/views/Search.vue index e0521cca7..93e7d607c 100644 --- a/js/src/views/Search.vue +++ b/js/src/views/Search.vue @@ -213,7 +213,7 @@ import debounce from "lodash/debounce"; interface ISearchTimeOption { label: string; - start?: Date; + start?: Date | null; end?: Date | null; } @@ -292,6 +292,11 @@ export default class Search extends Vue { location: IAddress = new Address(); dateOptions: Record = { + past: { + label: this.$t("In the past") as string, + start: null, + end: new Date(), + }, today: { label: this.$t("Today") as string, start: new Date(), @@ -346,7 +351,7 @@ export default class Search extends Vue { data(): Record { return { - debouncedUpdateSearchQuery: debounce(this.updateSearchQuery, 200), + debouncedUpdateSearchQuery: debounce(this.updateSearchQuery, 500), }; } @@ -525,7 +530,7 @@ export default class Search extends Vue { } }; - get start(): Date | undefined { + get start(): Date | undefined | null { if (this.dateOptions[this.when]) { return this.dateOptions[this.when].start; } diff --git a/lib/mobilizon/events/events.ex b/lib/mobilizon/events/events.ex index 2b8510170..52e89a275 100644 --- a/lib/mobilizon/events/events.ex +++ b/lib/mobilizon/events/events.ex @@ -1258,23 +1258,27 @@ defmodule Mobilizon.Events do defp events_for_begins_on(query, args) do begins_on = Map.get(args, :begins_on, DateTime.utc_now()) - query - |> where([q], q.begins_on >= ^begins_on) + if is_nil(begins_on) do + query + else + where(query, [q], q.begins_on >= ^begins_on) + end end @spec events_for_ends_on(Ecto.Queryable.t(), map()) :: Ecto.Query.t() defp events_for_ends_on(query, args) do ends_on = Map.get(args, :ends_on) - if is_nil(ends_on), - do: query, - else: - where( - query, - [q], - (is_nil(q.ends_on) and q.begins_on <= ^ends_on) or - q.ends_on <= ^ends_on - ) + if is_nil(ends_on) do + query + else + where( + query, + [q], + (is_nil(q.ends_on) and q.begins_on <= ^ends_on) or + q.ends_on <= ^ends_on + ) + end end @spec events_for_tags(Ecto.Queryable.t(), map()) :: Ecto.Query.t()