Allow to search for past events
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
a46372094c
commit
f55ca90c35
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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é"
|
||||
}
|
||||
|
|
|
@ -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<string, ISearchTimeOption> = {
|
||||
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<string, unknown> {
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue