Skip to content

Commit

Permalink
Changes provider to producer and addresses smaller comments in PR.
Browse files Browse the repository at this point in the history
  • Loading branch information
eibakke committed Nov 5, 2024
1 parent 49eb22f commit 31e3bbd
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* data.
* @param routeCreation true if an added trip cannot be registered under an existing route
* and a new route must be created.
* @param provider the provider of the real-time update.
* @param producer the producer of the real-time update.
*/
public record RealTimeTripUpdate(
TripPattern pattern,
Expand All @@ -30,7 +30,7 @@ public record RealTimeTripUpdate(
@Nullable TripOnServiceDate addedTripOnServiceDate,
boolean tripCreation,
boolean routeCreation,
String provider
@Nullable String producer
) {
public RealTimeTripUpdate {
Objects.requireNonNull(pattern);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public Result<UpdateSuccess, UpdateError> update(RealTimeTripUpdate realTimeTrip
}

// The time tables are finished during the commit
return Result.success(UpdateSuccess.noWarnings(realTimeTripUpdate.provider()));
return Result.success(UpdateSuccess.noWarnings(realTimeTripUpdate.producer()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public static <T> Result<T, UpdateError> toResult(DataValidationException error)

public static <T> Result<T, UpdateError> toResult(
DataValidationException error,
String provider
String producer
) {
if (error.error() instanceof TimetableValidationError tt) {
return Result.failure(
new UpdateError(tt.trip().getId(), mapTimeTableError(tt.code()), tt.stopIndex(), provider)
new UpdateError(tt.trip().getId(), mapTimeTableError(tt.code()), tt.stopIndex(), producer)
);
}
// The mapper should handle all possible errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public record UpdateError(
@Nullable FeedScopedId tripId,
UpdateErrorType errorType,
@Nullable Integer stopIndex,
@Nullable String provider
@Nullable String producer
) {
public UpdateError(@Nullable FeedScopedId tripId, UpdateErrorType errorType) {
this(tripId, errorType, null, null);
Expand All @@ -21,8 +21,8 @@ public UpdateError(@Nullable FeedScopedId tripId, UpdateErrorType errorType) {
public UpdateError(@Nullable FeedScopedId tripId, UpdateErrorType errorType, Integer stopIndex) {
this(tripId, errorType, stopIndex, null);
}
public UpdateError(@Nullable FeedScopedId tripId, UpdateErrorType errorType, String provider) {
this(tripId, errorType, null, provider);
public UpdateError(@Nullable FeedScopedId tripId, UpdateErrorType errorType, String producer) {
this(tripId, errorType, null, producer);
}

public String debugId() {
Expand Down Expand Up @@ -67,9 +67,9 @@ public static <T> Result<T, UpdateError> result(FeedScopedId tripId, UpdateError
public static <T> Result<T, UpdateError> result(
FeedScopedId tripId,
UpdateErrorType errorType,
String provider
String producer
) {
return Result.failure(new UpdateError(tripId, errorType, provider));
return Result.failure(new UpdateError(tripId, errorType, producer));
}

public static UpdateError noTripId(UpdateErrorType errorType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* ought to be looked at but didn't prevent the application of the update and the provider of the
* update.
*/
public record UpdateSuccess(List<WarningType> warnings, String provider) {
public record UpdateSuccess(List<WarningType> warnings, String producer) {
/**
* Create an instance with no warnings and no provider.
*/
Expand All @@ -21,15 +21,15 @@ public static UpdateSuccess noWarnings() {
/**
* Create an instance with no warnings, but a provider.
*/
public static UpdateSuccess noWarnings(String provider) {
return new UpdateSuccess(List.of(), provider);
public static UpdateSuccess noWarnings(String producer) {
return new UpdateSuccess(List.of(), producer);
}

/**
* Return a copy of the instance with the provided warnings added.
*/
public UpdateSuccess addWarnings(Collection<WarningType> addedWarnings) {
return new UpdateSuccess(ListUtils.combine(this.warnings, addedWarnings), this.provider);
return new UpdateSuccess(ListUtils.combine(this.warnings, addedWarnings), this.producer);
}

public enum WarningType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private void setFailuresByTypeAndProvider(UpdateResult result) {
.stream()
.collect(
Collectors.groupingBy(
error -> Pair.of(error.provider(), error.errorType()),
error -> Pair.of(error.producer(), error.errorType()),
Collectors.counting()
)
);
Expand All @@ -121,16 +121,16 @@ private void setSuccessesByProvider(UpdateResult result) {
Map<String, Long> successCountByProvider = result
.successes()
.stream()
.collect(Collectors.groupingBy(UpdateSuccess::provider, Collectors.counting()));
.collect(Collectors.groupingBy(UpdateSuccess::producer, Collectors.counting()));

for (var entry : successCountByProvider.entrySet()) {
Counter counter = successesByProvider.get(entry.getKey());
if (Objects.isNull(counter)) {
counter =
getCounter(
"successes_by_provider",
"Total successful trip updates by provider",
Tag.of("provider", entry.getKey())
"Total successful trip updates by producer",
Tag.of("producer", entry.getKey())
);
successesByProvider.put(entry.getKey(), counter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void testAddedTrip() {
SHORT_NAME,
HEADSIGN,
List.of(),
"TST"
"DATASOURCE"
)
.build();

Expand Down Expand Up @@ -249,7 +249,7 @@ void testAddedTripOnAddedRoute() {
SHORT_NAME,
HEADSIGN,
List.of(),
"TST"
"DATASOURCE"
)
.build();

Expand Down Expand Up @@ -278,7 +278,7 @@ void testAddedTripOnAddedRoute() {
SHORT_NAME,
HEADSIGN,
List.of(),
"TST"
"DATASOURCE"
)
.build();

Expand Down Expand Up @@ -321,7 +321,7 @@ void testAddedTripOnExistingRoute() {
SHORT_NAME,
HEADSIGN,
List.of(),
"TST"
"DATASOURCE"
)
.build();

Expand Down Expand Up @@ -356,7 +356,7 @@ void testAddedTripWithoutReplacedRoute() {
SHORT_NAME,
HEADSIGN,
List.of(),
"TST"
"DATASOURCE"
)
.build();

Expand Down Expand Up @@ -401,7 +401,7 @@ void testAddedTripFailOnMissingServiceId() {
SHORT_NAME,
HEADSIGN,
List.of(),
"TST"
"DATASOURCE"
)
.build();

Expand Down Expand Up @@ -457,7 +457,7 @@ void testAddedTripFailOnNonIncreasingDwellTime() {
SHORT_NAME,
HEADSIGN,
List.of(),
"TST"
"DATASOURCE"
)
.build();

Expand Down Expand Up @@ -497,7 +497,7 @@ void testAddedTripFailOnTooFewCalls() {
SHORT_NAME,
HEADSIGN,
List.of(),
"TST"
"DATASOURCE"
)
.build();

Expand Down Expand Up @@ -545,7 +545,7 @@ void testAddedTripFailOnUnknownStop() {
SHORT_NAME,
HEADSIGN,
List.of(),
"TST"
"DATASOURCE"
)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void testUpdateNoCalls() {
false,
null,
false,
"TST"
"DATASOURCE"
)
.build();

Expand Down Expand Up @@ -205,7 +205,7 @@ void testUpdateCancellation() {
true,
null,
false,
"TST"
"DATASOURCE"
)
.build();

Expand Down Expand Up @@ -250,7 +250,7 @@ void testUpdateSameStops() {
false,
null,
false,
"TST"
"DATASOURCE"
)
.build();

Expand Down Expand Up @@ -301,7 +301,7 @@ void testUpdateValidationFailure() {
false,
null,
false,
"TST"
"DATASOURCE"
)
.build();

Expand Down Expand Up @@ -350,7 +350,7 @@ void testUpdateSameStopsDepartEarly() {
false,
null,
false,
"TST"
"DATASOURCE"
)
.build();

Expand Down Expand Up @@ -401,7 +401,7 @@ void testUpdateUpdatedStop() {
false,
null,
false,
"TST"
"DATASOURCE"
)
.build();

Expand Down Expand Up @@ -458,7 +458,7 @@ void testUpdateCascading() {
false,
null,
false,
"TST"
"DATASOURCE"
)
.build();

Expand Down Expand Up @@ -504,7 +504,7 @@ void testUpdateCascading() {
false,
null,
false,
"TST"
"DATASOURCE"
)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public SiriEtBuilder(DateTimeHelper dateTimeHelper) {

// Set default values
evj.setMonitored(true);
evj.setDataSource("TST");
evj.setDataSource("DATASOURCE");
}

public List<EstimatedTimetableDeliveryStructure> buildEstimatedTimetableDeliveries() {
Expand Down

0 comments on commit 31e3bbd

Please sign in to comment.