Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: merge Lorem Fitsum features into Reference Implementation feeds #215

Merged
merged 21 commits into from
Mar 27, 2024

Conversation

civsiv
Copy link
Contributor

@civsiv civsiv commented Sep 20, 2023

This closes #212

It is a port of https://github.com/openactive/lorem-fitsum with a few minor changes outlined below:

  • Location is not randomly generated by hardcoded. This is so that they can grouped together over many facilities/sessions. This is much more useful than 1000 randomly generated locations.
  • All schedules are PartialSchedules. This is because it would require a lot more to have the schedules generate subEvents that can actually be booked. Lorem Fitsum did not have to worry about booking, so could generate all the subEvents it wanted.
  • SessionSeries data does not contain ScheduledSession data like it did in Lorem Fitsum.
  • A few other properties have been removed to the changing of the spec since Lorem Fitsum was written

var facility = new FacilityUseTable
{
Id = seed.Id,
Deleted = false,
Name = facilityUseName,
SellerId = Faker.Random.Bool(0.8f) ? Faker.Random.Long(1, 2) : Faker.Random.Long(3, 5), // distribution: 80% 1-2, 20% 3-5
SellerId = Faker.Random.Bool(0.8f) ? Faker.Random.Long(1, 2) : Faker.Random.Long(3, 4), // distribution: 80% 1-2, 20% 3-5
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seller 5 is an individual seller which doesn't make sense for a facility

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have just spotted a typo, so will fix if this current CI run passes

@@ -1497,13 +1385,13 @@ private static async Task CreateFakeFacilitiesAndSlots(IDbConnection db, bool fa
var slotId = 0;
List<(FacilityUseTable facility, List<SlotTable> slots)> facilitiesAndSlots = opportunitySeeds.Select((seed) =>
{
var facilityUseName = $"{Faker.Commerce.ProductMaterial()} {Faker.PickRandomParam("Sports Hall", "Swimming Pool Hall", "Running Hall", "Jumping Hall")}";
var facilityUseName = $"{Faker.Commerce.ProductMaterial()} {Faker.PickRandomParam("Sports Hall", "Squash Court", "Badminton Court", "Cricket Net")}";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These have matching facility types in the Facility Types JSONLD

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use an enum for these, rather than string matching?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is facility type name, not the Facility Type

@@ -644,118 +644,6 @@ public async Task<(bool, ClassTable, OccurrenceTable, BookedOrderItemInfo)> GetO
}
}

public OpenActive.NET.Place GetPlaceById(long placeId)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this to FeedGenerationHelper as it doesn't really belong in FakeBookingSystem

Modified = result.Item1.Modified,
State = result.Item1.Deleted ? RpdeState.Deleted : RpdeState.Updated,
Data = result.Item1.Deleted ? null : new FacilityUse
var faker = new Faker() { Random = new Randomizer(((int)result.Item1.Modified + (int)result.Item1.Id)) };
Copy link
Contributor

Choose a reason for hiding this comment

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

Apologies I don't have enough context to fully understand this. Two potential issues that I see with the random seed value provided here, though I likely misunderstand things are:

  • modified + id. There will be clashes with items. Maybe that's okay or maybe there won't due to how modified and ID are set.
  • modified + id. Due to the inclusion of the modified value, it looks like all of an item's data will change when modified changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry Luke I don't understand the first point. How would modified+id clash? The ids are unique within the type (SessionSeries/FacilityUse etc) as the id is the primary key in the table they are stored in. Clashing across types is not an issue as they don't have shared fields.

Completely agree however the modified can change. I have changed the seed to just be the id which will be unique

Copy link
Contributor

Choose a reason for hiding this comment

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

I have changed the seed to just be the id which will be unique

Great, that fixes both points!

@@ -166,6 +166,9 @@ public static StoreBookingEngine CreateStoreBookingEngine(AppSettings appSetting
),
HasSingleSeller = appSettings.FeatureFlags.SingleSeller,

// IdempotencyStore used for storing the response to Order Creation B/P requests
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a hangover from a previous PR (#207) where the Core code wasn't copied over to Framework

@@ -0,0 +1,25 @@
using OpenActive.Server.NET.OpenBookingHelper;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a hangover from a previous PR (#207) where the Core code wasn't copied over to Framework

@@ -6,8 +6,7 @@
"profiles": {
"BookingSystem.AspNetCore": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "https://localhost:5001/openactive",
"launchUrl": "https://localhost:5002/openactive",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have just spotted a typo, so will fix if this current CI run passes

Examples/BookingSystem.AspNetCore/README.md Outdated Show resolved Hide resolved
Comment on lines 9 to 18
1. In Visual Studio, run the BookingSystem.AspNetCore project

When it's finished building, it will open a page in your browser with a randomly assigned port e.g. http://localhost:55603/. Make note of this port.

Head to `http://localhost:{PORT}/openactive` to check that the project is running correctly. You should see an Open Data landing page.
2. Head to BookingSystem.AspNetCore project options and add an env var using the port you made note of earlier:

`ApplicationHostBaseUrl: http://localhost:{PORT}`
3. Now, re-run the project. You're good to go 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still true? I think I removed this at some point in a PR because this no longer seems to be true. For example the port assignment. I at some point removed and re-installed the project, run it with dotnet run and it always uses 5001.

The section in CONTRIBUTING.md shows how I run it. I think recommending using dotnet CLI is useful because the IDE in use will always rely on that CLI, and some users will use VSCode, or some users may not use an IDE and just git clone the project and run it.

But I do agree with you that that section focuses on how to run it with Test Suite and thus requires running the IdentityServer. But to run it just as a standalone reference implementation (w/o reference to Test Suite), the IdentityServer part should be ignored

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep since launchSettings.json fixed the port, this has no longer been the case. Have fixed


## Reference Implementation Data Generation

Reference Implementation has three main uses that make it very important in the OpenActive ecosystem:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to do either:

  1. Make it clear that "BookingSystem.AspNetCore" is synonymous with "Reference Implementation", which is not exactly explicit in the top section of this README
  2. Or just always call the project BookingSystem.AspNetCore in the README

My personal opinion is # 2 because OpenActive may need to broaden the meaning of "Reference Implementation" at a later date (e.g. if there are future reference implementations in other languages)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep makes sense, I've added a comment about that.

Comment on lines +24 to +26
- For data publishers / booking systems: It is used to demonstrate the properties and shape of data and APIs, according to the OpenActive specifications
- For data users / brokers: It is used as a trial integration where testing can be done with no ramifications
- For contributors: It is used to ensure the Test Suite tests are correct and passing, for different combinations of Open Booking API features.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is unbelievably useful to finally spell this out — good shout!

Comment on lines +35 to +37
Due to this split of functionality, the sample data in the feeds are created/transformed in both files, depending on whether they are important to booking
or not. For example, `Price` is important to booking and there is generated in FakeBookingSystem at startup and stored in the in-memory database. However `Terms Of Service` is not
needed for booking, and therefore is generated at request time.
Copy link
Contributor

Choose a reason for hiding this comment

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

Also appreciated!

or not. For example, `Price` is important to booking and there is generated in FakeBookingSystem at startup and stored in the in-memory database. However `Terms Of Service` is not
needed for booking, and therefore is generated at request time.

### Lorem Fitsum mode
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this section should refer to how to set Lorem Fitsum mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeh done

State = result.Item1.Deleted ? RpdeState.Deleted : RpdeState.Updated,
Data = result.Item1.Deleted ? null : new FacilityUse
var faker = new Faker() { Random = new Randomizer((int)result.Item1.Id) };
var isGoldenRecord = faker.Random.Bool();
Copy link
Contributor

@lukehesluke lukehesluke Mar 21, 2024

Choose a reason for hiding this comment

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

So does this mean that half of records (in Lorem Fitsum mode) will be golden? I assumed we'd want a lower rate

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeh fair, changed to 75%

var faker = new Faker() { Random = new Randomizer((int)result.Item1.Id) };
// here we randomly decide whether the item is going to be a golden record or not by using Faker
// See the README for more detail on golden records.
var isGoldenRecord = faker.Random.Bool();
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment about isGoldenRecord

@civsiv civsiv merged commit e324d68 into master Mar 27, 2024
19 of 21 checks passed
@civsiv civsiv deleted the feature/merge-lorem-fitsum-into-ref-impl branch March 27, 2024 17:15
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.

Improvements to the diversity of random data included in ref impl - it should cover all of Lorem Fitsum
3 participants