-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(bookings): /booked route to return more results
by default, also returns the correct link header for the next set of results
- Loading branch information
Showing
2 changed files
with
8 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,7 +185,8 @@ class Bookings < Application | |
@[AC::Param::Info(description: "the recurring bookings index of the result set. Used to implement pagination with recurring bookings")] | ||
recurrence : Int32 = 0, | ||
@[AC::Param::Info(description: "filters bookings based on the permission level. Options: PRIVATE, OPEN, PUBLIC", example: "PUBLIC")] | ||
permission : String? = nil | ||
permission : String? = nil, | ||
link_ext : String? = nil | ||
) : Array(Booking) | ||
query = Booking.by_tenant(tenant.id) | ||
|
||
|
@@ -265,7 +266,7 @@ class Bookings < Application | |
params["offset"] = range_end.to_s | ||
params["limit"] = limit.to_s | ||
params["recurrence"] = details.next_idx.to_s | ||
response.headers["Link"] = %(<#{base_route}?#{params}>; rel="next") | ||
response.headers["Link"] = %(<#{base_route}/#{link_ext}?#{params}>; rel="next") | ||
end | ||
else | ||
range_end = result.size + offset | ||
|
@@ -276,7 +277,7 @@ class Bookings < Application | |
if range_end < total | ||
params["offset"] = range_end.to_s | ||
params["limit"] = limit.to_s | ||
response.headers["Link"] = %(<#{base_route}?#{params}>; rel="next") | ||
response.headers["Link"] = %(<#{base_route}/#{link_ext}?#{params}>; rel="next") | ||
end | ||
end | ||
|
||
|
@@ -322,8 +323,8 @@ class Bookings < Application | |
event_id : String? = nil, | ||
@[AC::Param::Info(description: "filters bookings associated with an event, such as an Office365 Calendar event ical_uid", example: "[email protected]")] | ||
ical_uid : String? = nil, | ||
@[AC::Param::Info(description: "the maximum number of results to return", example: "10000")] | ||
limit : Int32 = 100, | ||
@[AC::Param::Info(description: "the maximum number of results to return", example: "100000")] | ||
limit : Int32 = 100000, | ||
@[AC::Param::Info(description: "the starting offset of the result set. Used to implement pagination")] | ||
offset : Int32 = 0, | ||
@[AC::Param::Info(description: "filters bookings based on the permission level. Options: PRIVATE, OPEN, PUBLIC", example: "PUBLIC")] | ||
|
@@ -332,7 +333,7 @@ class Bookings < Application | |
result = index(starting: starting, ending: ending, booking_type: booking_type, deleted_flag: false, include_checked_out: false, | ||
checked_out_flag: false, zones: zones, user_email: user_email, user_id: user_id, include_booked_by: include_booked_by, checked_in: checked_in, | ||
created_before: created_before, created_after: created_after, approved: approved, rejected: false, extension_data: extension_data, state: state, | ||
department: department, event_id: event_id, ical_uid: ical_uid, limit: limit, offset: offset, permission: permission) | ||
department: department, event_id: event_id, ical_uid: ical_uid, limit: limit, offset: offset, permission: permission, link_ext: "booked") | ||
asset_ids = [] of String | ||
result.each { |b| asset_ids.concat(b.asset_ids) unless b.checked_in_at || b.deleted } | ||
asset_ids.uniq! | ||
|