Skip to content

feat: B/P Detailed Errors, race condition fixes, and preliminary support for the Customer Account API#177

Merged
nickevansuk merged 37 commits intomasterfrom
coverage/b-detailed-errors
Jun 6, 2022
Merged

feat: B/P Detailed Errors, race condition fixes, and preliminary support for the Customer Account API#177
nickevansuk merged 37 commits intomasterfrom
coverage/b-detailed-errors

Conversation

@nickevansuk
Copy link
Copy Markdown
Contributor

@nickevansuk nickevansuk commented May 27, 2022

This PR includes:

  1. Very early work to add preliminary CustomerAccount support based on the ongoing conversations around the Customer Accounts proposal, to inform the OpenActive specification work for Customer Accounts with implementation feedback.
  2. B/P detailed errors (Return detailed errors from B, same as C2 open-booking-api#218)
  3. Prevention of race conditions from feat: Fixing issues with race conditions #164

Migration required for users of the library as follows:

  • Find-and-replace (case sensitive) all instances of SellerIdComponents with SimpleIdComponents
  • Find-and-replace all instances of SellerIdLong with IdLong
  • Find-and-replace all instances of SellerIdGuid with IdGuid
  • Find-and-replace all instances of SellerIdString with IdString
  • Find-and-replace all instances of (string clientId, Uri sellerId) = User.GetAccessTokenOpenBookingClaims(); with (string clientId, Uri sellerId, _) = User.GetAccessTokenOpenBookingClaims();

@nickevansuk nickevansuk changed the title feat: P/B Detailed Errors and preliminary support for the Customer Account API feat: B/P Detailed Errors and preliminary support for the Customer Account API May 27, 2022
@nickevansuk nickevansuk changed the title feat: B/P Detailed Errors and preliminary support for the Customer Account API feat: B/P Detailed Errors, race condition fixes, and preliminary support for the Customer Account API May 27, 2022
Copy link
Copy Markdown
Contributor Author

@nickevansuk nickevansuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few notes

"applicationUrl": "https://localhost:5001",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_ENVIRONMENT": "no-auth",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suspect this shouldn't have been left in?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have removed that in the next commit

orderItem.Status == BookingStatus.Absent ? OrderItemStatus.AttendeeAbsent : (OrderItemStatus?)null,
Attendee = hasAttendeeDetails ? new Person
{
GivenName = orderItem.AttendeeGivenName ?? null,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure ?? null has any affect here? If it's already null, then null will be assigned

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh fair

long numberOfSpaces,
bool proposal
bool proposal,
List<string> attendeeEmail,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a set of List<string> and not a List<> of a structured object?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was following the pattern already set for speed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, addLease and addOrder have exactly the same "string instead of structured object" pattern. I suspect this is because there's isn't a API<->DB translation layer (unless I've missed something)

Comment thread Examples/BookingSystem.AspNetFramework/Web.config Outdated
Copy link
Copy Markdown
Contributor Author

@nickevansuk nickevansuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@civsiv a few more minor fixes here

Comment thread Examples/BookingSystem.AspNetCore/Stores/FacilityStore.cs Outdated
Comment on lines +580 to +588
.Where(x => x.RequestOrderItem.Attendee != null)
.Select(x => new FakeDbPerson
{
GivenName = x.RequestOrderItem.Attendee.GivenName,
FamilyName = x.RequestOrderItem.Attendee.FamilyName,
Email = x.RequestOrderItem.Attendee.Email,
Telephone = x.RequestOrderItem.Attendee.Telephone,
})
.ToList(),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@civsiv will this not cause issues with the attendees not being stored against the correct OrderItems if only some attendees are specified.

e.g. at P

1: Bob
2: Null
3: Alex

then B would be

1: Bob
2: Alex
3: Null

So we'd actually want something more like the below:?

Suggested change
.Where(x => x.RequestOrderItem.Attendee != null)
.Select(x => new FakeDbPerson
{
GivenName = x.RequestOrderItem.Attendee.GivenName,
FamilyName = x.RequestOrderItem.Attendee.FamilyName,
Email = x.RequestOrderItem.Attendee.Email,
Telephone = x.RequestOrderItem.Attendee.Telephone,
})
.ToList(),
.Select(x => x.RequestOrderItem.Attendee == null ? null : new FakeDbPerson
{
GivenName = x.RequestOrderItem.Attendee.GivenName,
FamilyName = x.RequestOrderItem.Attendee.FamilyName,
Email = x.RequestOrderItem.Attendee.Email,
Telephone = x.RequestOrderItem.Attendee.Telephone,
})
.ToList(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep that's a good catch. I'll make two additional fixes here too:

  1. Make this change for OrderItemIntakeFormResponse as that has the same logic
  2. Turn this into the Serialize/Deserialize logic used for OrderItemIntakeFormResponse so that FakeDbPerson can be removed.

Comment on lines +567 to +575
.Where(x => x.RequestOrderItem.Attendee != null)
.Select(x => new FakeDbPerson
{
GivenName = x.RequestOrderItem.Attendee.GivenName,
FamilyName = x.RequestOrderItem.Attendee.FamilyName,
Email = x.RequestOrderItem.Attendee.Email,
Telephone = x.RequestOrderItem.Attendee.Telephone,
})
.ToList(),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as above?

Comment on lines +632 to +640
.Where(x => x.RequestOrderItem.Attendee != null)
.Select(x => new FakeDbPerson
{
GivenName = x.RequestOrderItem.Attendee.GivenName,
FamilyName = x.RequestOrderItem.Attendee.FamilyName,
Email = x.RequestOrderItem.Attendee.Email,
Telephone = x.RequestOrderItem.Attendee.Telephone,
})
.ToList(),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as above?

Comment on lines +515 to +523
.Where(x => x.RequestOrderItem.Attendee != null)
.Select(x => new FakeDbPerson
{
GivenName = x.RequestOrderItem.Attendee.GivenName,
FamilyName = x.RequestOrderItem.Attendee.FamilyName,
Email = x.RequestOrderItem.Attendee.Email,
Telephone = x.RequestOrderItem.Attendee.Telephone,
})
.ToList(),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as below?

MeetingId = thisClass.AttendanceMode != AttendanceMode.Offline ? Faker.Random.String(length: 10, minChar: '0', maxChar: '9') : null,
MeetingPassword = thisClass.AttendanceMode != AttendanceMode.Offline ? Faker.Random.String(length: 10, minChar: '0', maxChar: '9') : null
MeetingPassword = thisClass.AttendanceMode != AttendanceMode.Offline ? Faker.Random.String(length: 10, minChar: '0', maxChar: '9') : null,
AttendeeEmail = attendees.Count > 0 ? attendees[i].Email : null,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this check make sense? Could we be out-of-bounds of the array if i was 2 and the attendee count was 1 (due to the Where clause flagged earlier).

Perhaps something more defensive such as:

Suggested change
AttendeeEmail = attendees.Count > 0 ? attendees[i].Email : null,
AttendeeEmail = attendees.Count > i ? attendees[i].Email : null,

Also note any amends to this pattern need to be replicated below also

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to change this to be a serialised string which will remove all of these issues

Comment thread Examples/BookingSystem.AspNetFramework/Stores/SessionStore.cs Outdated
Comment thread Examples/BookingSystem.AspNetCore/Stores/SessionStore.cs Outdated
@nickevansuk nickevansuk merged commit d7bed9d into master Jun 6, 2022
@nickevansuk nickevansuk deleted the coverage/b-detailed-errors branch June 6, 2022 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants