Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 476a5d7

Browse files
reidmitTeal Stannard
andcommitted
We are now using ONLY relational operator.
[#173671473] Co-authored-by: Reid Mitchell <rmitchell@pivotal.io> Co-authored-by: Teal Stannard <tstannard@pivotal.io>
1 parent 2cd0e5f commit 476a5d7

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

app/messages/events_list_message.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,24 @@ def validate(record)
1111
end
1212
else
1313
unless record.created_ats.is_a?(Hash)
14-
record.errors[:created_ats] << 'comparison operator and timestamp must be specified'
14+
record.errors[:created_ats] << 'relational operator and timestamp must be specified'
1515
return
1616
end
1717

18-
valid_comparision_operators = [
18+
valid_relational_operators = [
1919
Event::LESS_THAN_COMPARATOR,
2020
Event::GREATER_THAN_COMPARATOR,
2121
Event::LESS_THAN_OR_EQUAL_COMPARATOR,
2222
Event::GREATER_THAN_OR_EQUAL_COMPARATOR,
2323
]
2424

25-
record.created_ats.each do |comparison_operator, timestamp|
26-
unless valid_comparision_operators.include?(comparison_operator)
27-
record.errors[:created_ats] << "Invalid comparison operator: '#{comparison_operator}'"
25+
record.created_ats.each do |relational_operator, timestamp|
26+
unless valid_relational_operators.include?(relational_operator)
27+
record.errors[:created_ats] << "Invalid relational operator: '#{relational_operator}'"
2828
end
2929

3030
if timestamp.to_s.include?(',')
31-
record.errors[:created_ats] << 'only accepts one value when using an inequality filter'
31+
record.errors[:created_ats] << 'only accepts one value when using a relational operator'
3232
next
3333
end
3434

docs/v3/source/includes/concepts/_filters.md.erb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ This will return all routes with hostname `"hostname1"`, `""` OR `"hostname2"`.
4747

4848
#### Relational Operators (Experimental)
4949

50-
Fields can be filtered using inequality when listing resources. Currently, this is supported only on
51-
the `created_at` field, using the `created_ats` filter.
50+
Fields can be filtered using relational operators when listing resources. Currently, this is
51+
supported only on the `created_at` field, using the `created_ats` filter.
5252

5353
For example, a response to `/v3/audit_events?created_ats[lt]=2020-06-30T12:34:56Z` will contain
5454
audit events with a `created_at` timestamp strictly earlier than `2020-06-30T12:34:56Z`.
@@ -59,7 +59,7 @@ will return all audit events occurring on New Year's Day.
5959

6060
Timestamps must be in [standard timestamp format](#timestamps).
6161

62-
##### Valid inequality operators
62+
##### Valid relational operators
6363

6464
**Operator** | **Description**
6565
-------------|-----------------
@@ -68,8 +68,8 @@ Timestamps must be in [standard timestamp format](#timestamps).
6868
**gt** | Return resources strictly greater than the given value for the filtered attribute
6969
**gte** | Return resources greater than or equal to the given value for the filtered attribute
7070

71-
##### Resources with inequalities
71+
##### Resources with relational operators
7272

73-
The following resources can filter using inequality operators:
73+
The following resources can filter using relational operators:
7474

7575
- **[audit_events](#list-audit-events)**

spec/request/events_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@
445445
get "/v3/audit_events?created_ats[goat]=#{timestamp}", nil, admin_header
446446

447447
expect(last_response).to have_status_code(400)
448-
expect(last_response).to have_error_message("Invalid comparison operator: 'goat'")
448+
expect(last_response).to have_error_message("Invalid relational operator: 'goat'")
449449
end
450450
end
451451

spec/unit/messages/events_list_message_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ module VCAP::CloudController
6868
it 'requires a hash or an array of timestamps' do
6969
message = EventsListMessage.from_params({ created_ats: 47 })
7070
expect(message).not_to be_valid
71-
expect(message.errors[:created_ats]).to include('comparison operator and timestamp must be specified')
71+
expect(message.errors[:created_ats]).to include('relational operator and timestamp must be specified')
7272
end
7373

74-
it 'requires a valid comparison operator' do
74+
it 'requires a valid relational operator' do
7575
message = EventsListMessage.from_params({ created_ats: { garbage: Time.now.utc.iso8601 } })
7676
expect(message).not_to be_valid
77-
expect(message.errors[:created_ats]).to include("Invalid comparison operator: 'garbage'")
77+
expect(message.errors[:created_ats]).to include("Invalid relational operator: 'garbage'")
7878
end
7979

8080
context 'requires a valid timestamp' do
@@ -131,7 +131,7 @@ module VCAP::CloudController
131131
it 'does not allow multiple timestamps with an operator' do
132132
message = EventsListMessage.from_params({ created_ats: { gte: "#{Time.now.utc.iso8601},#{Time.now.utc.iso8601}" } })
133133
expect(message).not_to be_valid
134-
expect(message.errors[:created_ats]).to include('only accepts one value when using an inequality filter')
134+
expect(message.errors[:created_ats]).to include('only accepts one value when using a relational operator')
135135
end
136136

137137
context 'when the operator is an equals operator' do

0 commit comments

Comments
 (0)