Skip to content

Commit e324d68

Browse files
civsivlukehesluke
andauthored
feat: merge Lorem Fitsum features into Reference Implementation feeds (#215)
* feat: merge Lorem Fitsum features into Reference Implementation feeds * remove comment and fix port change * fix seed logic * feed validator checks * fix typo * update framework from cire * remove modified from faker seed * update Node version for CI * fix feed generation * fix typos and update framework * add IS_CI env var and make minimal versions of rpde items * revert opportunity count * invert IS_CI to IS_LOREM_FITSUM_MODE * fix builf * Update Examples/BookingSystem.AspNetCore/README.md Co-authored-by: Luke Winship <luke.winship@gmail.com> * add some fixes to readme * review changes --------- Co-authored-by: Luke Winship <luke.winship@gmail.com>
1 parent 7e88fdf commit e324d68

18 files changed

Lines changed: 1468 additions & 620 deletions

File tree

Examples/BookingSystem.AspNetCore/BookingSystem.AspNetCore.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<UserSecretsId>aspnet-BookingSystem.AspNetCore-443B4F82-A20C-41CE-9924-329A0BCF0D14</UserSecretsId>
6+
<Configurations>Release;Debug</Configurations>
67
</PropertyGroup>
78

89
<ItemGroup>
@@ -22,4 +23,5 @@
2223
<NoWarn>1701;1702;1591</NoWarn>
2324
</PropertyGroup>
2425

26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
2527
</Project>

Examples/BookingSystem.AspNetCore/Feeds/FacilitiesFeeds.cs

Lines changed: 203 additions & 136 deletions
Large diffs are not rendered by default.

Examples/BookingSystem.AspNetCore/Feeds/SessionsFeeds.cs

Lines changed: 321 additions & 108 deletions
Large diffs are not rendered by default.

Examples/BookingSystem.AspNetCore/Helpers/FeedGenerationHelper.cs

Lines changed: 306 additions & 0 deletions
Large diffs are not rendered by default.

Examples/BookingSystem.AspNetCore/Properties/launchSettings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"profiles": {
77
"BookingSystem.AspNetCore": {
88
"commandName": "Project",
9-
"launchBrowser": true,
109
"launchUrl": "https://localhost:5001/openactive",
1110
"applicationUrl": "https://localhost:5001",
1211
"environmentVariables": {

Examples/BookingSystem.AspNetCore/README.md

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,68 @@
22

33
An example OpenActive.Server.NET implementation.
44

5-
This implementation is also used as a reference implementation for the [Test Suite](https://github.com/openactive/openactive-test-suite) to run its tests against.
5+
This implementation is also used as a reference implementation for the [Test Suite](https://github.com/openactive/openactive-test-suite) to run its tests against and therefore is often to as Reference Implementation.
6+
Until there are more reference implementations, all references to Reference Implementation refer to this implementation and Reference Implementation and BookingSystem.AspNetCore can be used interchangeably.
67

7-
## Running Locally
8+
## Running Locally using Visual Studio
9+
10+
In Visual Studio, run the BookingSystem.AspNetCore project
11+
12+
When it's finished building, it will open a page in your browser on port 5001.
13+
14+
Head to `http://localhost:5001/openactive` to check that the project is running correctly. You should see an Open Data landing page.
815

916
See the [project contribution documentation](/CONTRIBUTING.md) for details on how to run BookingSystem.AspNetCore locally.
17+
18+
## Running Locally using the CLI
19+
20+
Open a terminal in `Examples/BookingSystem.AspNetCore` directory
21+
22+
Run:
23+
24+
```sh
25+
dotnet run
26+
```
27+
28+
If you want to start BookingSystem.AspNetCore in a specific environment run the following:
29+
30+
```sh
31+
ASPNETCORE_ENVIRONMENT=no-auth dotnet run --no-launch-profile --project ./BookingSystem.AspNetCore.csproj --configuration Release --no-build
32+
```
33+
34+
The above example starts the BookingSystem.AspNetCore in `no-auth` mode.
35+
36+
## BookingSystem.AspNetCore Data Generation
37+
38+
BookingSystem.AspNetCore has three main uses that make it very important in the OpenActive ecosystem:
39+
- For data publishers / booking systems: It is used to demonstrate the properties and shape of data and APIs, according to the OpenActive specifications
40+
- For data users / brokers: It is used as a trial integration where testing can be done with no ramifications
41+
- For contributors: It is used to ensure the Test Suite tests are correct and passing, for different combinations of Open Booking API features.
42+
43+
The data for the sample feeds are generated in two places:
44+
- BookingSystem.AspNetCore/Feeds/*Feeds.cs
45+
- OpenActive.FakeDatabase.NET/Fakes/FakeBookingSystem.cs
46+
47+
The FakeBookingSystem within OpenActive.FakeDatabase.NET acts as the interface to an example database.
48+
The example Feeds within BookingSystem.AspNetCore query this interface and translate the data to conform with the OpenActive Modelling Spec.
49+
50+
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
51+
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
52+
needed for booking, and therefore is generated at request time.
53+
54+
### Lorem Fitsum mode
55+
When BookingSystem.AspNetCore is run in Lorem Fitsum (a play on [Lorem Ipsum](https://en.wikipedia.org/wiki/Lorem_ipsum)) mode, the data generated contains all the possible fields specified by the OpenActive Modelling Specification.
56+
They are unrealistic representations of data, and the presence of all the fields should not be relied on when developing front-end representations of the data.
57+
However it is very useful for data consumers and deciding on how to present the data to the users.
58+
59+
Lorem Fitsum mode can be running by setting the environment variable `IS_LOREM_FITSUM_MODE` to `true`.
60+
In Visual Studio this can be done in Properties > BookingSystem.AspNetCore Properties > Run > Default > Environment Variables.
61+
In the CLI this can be done by running the following command for example:
62+
63+
```sh
64+
IS_LOREM_FITSUM_MODE=true dotnet run --no-launch-profile --project ./BookingSystem.AspNetCore.csproj --configuration Release --no-build
65+
```
66+
67+
### Golden Records
68+
Golden records are randomly generated records that have maximally enriched properties in the generated data. For example where a record might have one image normally, a golden record will have four.
69+

Examples/BookingSystem.AspNetCore/Settings/AppSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class FeatureSettings
2020
public bool OnlyFreeOpportunities { get; set; } = false;
2121
public bool PrepaymentAlwaysRequired { get; set; } = false;
2222
public bool FacilityUseHasSlots { get; set; } = false;
23+
public bool IsLoremFitsumMode { get; set; } = false;
2324
}
2425

2526
public class PaymentSettings

Examples/BookingSystem.AspNetCore/Startup.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,22 @@ public Startup(IConfiguration configuration)
2020
configuration.Bind(AppSettings);
2121

2222
// Provide a simple way to disable token auth for some testing scenarios
23-
if (System.Environment.GetEnvironmentVariable("DISABLE_TOKEN_AUTH") == "true") {
23+
if (System.Environment.GetEnvironmentVariable("DISABLE_TOKEN_AUTH") == "true")
24+
{
2425
AppSettings.FeatureFlags.EnableTokenAuth = false;
2526
}
2627

2728
// Provide a simple way to enable FacilityUseHasSlots for some testing scenarios
28-
if (System.Environment.GetEnvironmentVariable("FACILITY_USE_HAS_SLOTS") == "true") {
29+
if (System.Environment.GetEnvironmentVariable("FACILITY_USE_HAS_SLOTS") == "true")
30+
{
2931
AppSettings.FeatureFlags.FacilityUseHasSlots = true;
3032
}
33+
34+
// Provide a simple way to enable CI mode
35+
if (System.Environment.GetEnvironmentVariable("IS_LOREM_FITSUM_MODE") == "true")
36+
{
37+
AppSettings.FeatureFlags.IsLoremFitsumMode = true;
38+
}
3139
}
3240

3341
public AppSettings AppSettings { get; }

Examples/BookingSystem.AspNetCore/Stores/FacilityStore.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading.Tasks;
5+
using BookingSystem.AspNetCore.Helpers;
56
using OpenActive.DatasetSite.NET;
67
using OpenActive.FakeDatabase.NET;
78
using OpenActive.NET;
@@ -320,7 +321,7 @@ protected override async Task GetOrderItems(List<OrderItemContext<FacilityOpport
320321
}),
321322
Name = facility.Name,
322323
Url = new Uri("https://example.com/events/" + slot.FacilityUseId),
323-
Location = _fakeBookingSystem.Database.GetPlaceById(facility.PlaceId),
324+
Location = FeedGenerationHelper.GetPlaceById(facility.PlaceId),
324325
FacilityType = new List<Concept> {
325326
new Concept
326327
{
@@ -374,11 +375,11 @@ protected override async Task GetOrderItems(List<OrderItemContext<FacilityOpport
374375
// Note this should always be driven from the database, with new FacilityOpportunity's instantiated
375376
Id = RenderOpportunityId(new FacilityOpportunity
376377
{
377-
OpportunityType = _appSettings.FeatureFlags.FacilityUseHasSlots ? OpportunityType.FacilityUseSlot : OpportunityType.IndividualFacilityUseSlot,
378+
OpportunityType = _appSettings.FeatureFlags.FacilityUseHasSlots ? OpportunityType.FacilityUseSlot : OpportunityType.IndividualFacilityUseSlot,
378379
FacilityUseId = slot.FacilityUseId,
379380
SlotId = slot.Id,
380381
IndividualFacilityUseId = !_appSettings.FeatureFlags.FacilityUseHasSlots ? slot.IndividualFacilityUseId : null,
381-
}),
382+
}),
382383
FacilityUse = slotParent,
383384
StartDate = (DateTimeOffset)slot.Start,
384385
EndDate = (DateTimeOffset)slot.End,

Examples/BookingSystem.AspNetCore/Stores/SessionStore.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
using OpenActive.FakeDatabase.NET;
99
using RequiredStatusType = OpenActive.FakeDatabase.NET.RequiredStatusType;
1010
using System.Threading.Tasks;
11-
11+
using BookingSystem.AspNetCore.Helpers;
1212

1313
namespace BookingSystem
1414
{
@@ -361,7 +361,7 @@ protected override async Task GetOrderItems(List<OrderItemContext<SessionOpportu
361361
}),
362362
Name = @class.Title,
363363
Url = new Uri("https://example.com/events/" + occurrence.ClassId),
364-
Location = _fakeBookingSystem.Database.GetPlaceById(@class.PlaceId),
364+
Location = FeedGenerationHelper.GetPlaceById(@class.PlaceId),
365365
Activity = new List<Concept>
366366
{
367367
new Concept

0 commit comments

Comments
 (0)