mirror of
https://github.com/discourse/discourse.git
synced 2026-09-05 04:40:41 -05:00
DEV: Remove the post event format filter (#43287)
Previously, the events finder could filter events by whether they had a URL, a location, or both, exposed as the `event_format` parameter added in #43131. We are still figuring how should we define the event_format
This commit is contained in:
@@ -200,7 +200,6 @@ module DiscourseEvents
|
|||||||
:tags,
|
:tags,
|
||||||
:search,
|
:search,
|
||||||
:status,
|
:status,
|
||||||
:event_format,
|
|
||||||
tags: [],
|
tags: [],
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ module DiscourseEvents
|
|||||||
.then { |query| filter_by_tags(query, params, guardian) }
|
.then { |query| filter_by_tags(query, params, guardian) }
|
||||||
.then { |query| filter_by_search(query, params) }
|
.then { |query| filter_by_search(query, params) }
|
||||||
.then { |query| filter_by_status(query, params) }
|
.then { |query| filter_by_status(query, params) }
|
||||||
.then { |query| filter_by_format(query, params) }
|
|
||||||
.then { |query| apply_ordering(query, params) }
|
.then { |query| apply_ordering(query, params) }
|
||||||
.then { |query| apply_limit(query, params) }
|
.then { |query| apply_limit(query, params) }
|
||||||
end
|
end
|
||||||
@@ -254,21 +253,6 @@ module DiscourseEvents
|
|||||||
events.where(status: statuses)
|
events.where(status: statuses)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.filter_by_format(events, params)
|
|
||||||
case params[:event_format]
|
|
||||||
when nil, ""
|
|
||||||
events
|
|
||||||
when "virtual"
|
|
||||||
events.where.not(url: nil).where(location: [nil, ""])
|
|
||||||
when "in_person"
|
|
||||||
events.where(url: [nil, ""]).where.not(location: nil).where.not(location: "")
|
|
||||||
when "hybrid"
|
|
||||||
events.where.not(url: [nil, ""]).where.not(location: [nil, ""])
|
|
||||||
else
|
|
||||||
events.none
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.apply_ordering(events, params)
|
def self.apply_ordering(events, params)
|
||||||
order_direction = params[:order] == "desc" ? "DESC" : "ASC"
|
order_direction = params[:order] == "desc" ? "DESC" : "ASC"
|
||||||
events.order(
|
events.order(
|
||||||
|
|||||||
@@ -132,15 +132,6 @@ RSpec.describe "events" do
|
|||||||
},
|
},
|
||||||
description: "Filter by event attendance status"
|
description: "Filter by event attendance status"
|
||||||
|
|
||||||
parameter name: :event_format,
|
|
||||||
in: :query,
|
|
||||||
required: false,
|
|
||||||
schema: {
|
|
||||||
type: :string,
|
|
||||||
enum: %w[virtual in_person hybrid],
|
|
||||||
},
|
|
||||||
description: "Filter by whether the event has a URL, location, or both"
|
|
||||||
|
|
||||||
produces "application/json"
|
produces "application/json"
|
||||||
|
|
||||||
response "200", "success response (basic)" do
|
response "200", "success response (basic)" do
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ module DiscourseEvents::Events
|
|||||||
expect(response.parsed_body["events"]).not_to be_empty
|
expect(response.parsed_body["events"]).not_to be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
it "filters by tags, text, status, and format" do
|
it "filters by tags, text, and status" do
|
||||||
tag = Fabricate(:tag, name: "launch")
|
tag = Fabricate(:tag, name: "launch")
|
||||||
tagged_event =
|
tagged_event =
|
||||||
Fabricate(
|
Fabricate(
|
||||||
@@ -149,13 +149,6 @@ module DiscourseEvents::Events
|
|||||||
status: DiscourseEvents::Events::Event.statuses[:private],
|
status: DiscourseEvents::Events::Event.statuses[:private],
|
||||||
url: "https://example.com/meeting",
|
url: "https://example.com/meeting",
|
||||||
)
|
)
|
||||||
hybrid_event =
|
|
||||||
Fabricate(
|
|
||||||
:event,
|
|
||||||
original_starts_at: 3.days.from_now,
|
|
||||||
url: "https://example.com/meeting",
|
|
||||||
location: "Room 6",
|
|
||||||
)
|
|
||||||
|
|
||||||
get "/discourse-post-event/events.json", params: { tags: [tag.name] }
|
get "/discourse-post-event/events.json", params: { tags: [tag.name] }
|
||||||
expect(response.parsed_body["events"].pluck("id")).to contain_exactly(tagged_event.id)
|
expect(response.parsed_body["events"].pluck("id")).to contain_exactly(tagged_event.id)
|
||||||
@@ -165,9 +158,6 @@ module DiscourseEvents::Events
|
|||||||
|
|
||||||
get "/discourse-post-event/events.json", params: { status: "private" }
|
get "/discourse-post-event/events.json", params: { status: "private" }
|
||||||
expect(response.parsed_body["events"].pluck("id")).to contain_exactly(private_event.id)
|
expect(response.parsed_body["events"].pluck("id")).to contain_exactly(private_event.id)
|
||||||
|
|
||||||
get "/discourse-post-event/events.json", params: { event_format: "hybrid" }
|
|
||||||
expect(response.parsed_body["events"].pluck("id")).to contain_exactly(hybrid_event.id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return events in ics format" do
|
it "should return events in ics format" do
|
||||||
|
|||||||
Reference in New Issue
Block a user