Skip to content

Commit

Permalink
Expose attributes in procedural payload for events
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephVolosin authored and pranav-super committed Jan 22, 2025
1 parent f31e76f commit 09cb8eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ data class ExternalEvent(
/** The source this event comes from. */
@JvmField
val source: ExternalSource,
/** The attributes of the event. */
@JvmField
val attributes: Map<String, SerializedValue>,
override val interval: Interval,
): IntervalLike<ExternalEvent> {
override fun withNewInterval(i: Interval) = ExternalEvent(key, type, source, i)
override fun withNewInterval(i: Interval) = ExternalEvent(key, type, source, attributes, i)
}
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ public Map<String, List<ExternalEvent>> getExternalEvents(final PlanId planId, f
final var eventsRequest = """
query DerivedEventsForPlan {
derived_events(where: {derivation_group_name: {_in: %s}}) {
attributes
source_key
event_type_name
event_key
Expand Down Expand Up @@ -1183,13 +1184,22 @@ private List<ExternalEvent> parseExternalEvents(final JsonArray eventsJson, fina
horizonStart.until(ZonedDateTime.parse(e.getString("start_time")).toInstant(), ChronoUnit.MICROS)
);
final var end = start.plus(Duration.fromString(e.getString("duration")));
final var attributesJson = e.getJsonObject("attributes");
final var attributes = new HashMap<String, SerializedValue>();
for (final var attributeJson: attributesJson.entrySet()) {
attributes.put(
attributeJson.getKey(),
serializedValueP.parse(attributeJson.getValue()).getSuccessOrThrow()
);
}
result.add(new ExternalEvent(
e.getString("event_key"),
e.getString("event_type_name"),
new ExternalSource(
e.getString("source_key"),
e.getString("derivation_group_name")
),
attributes,
Interval.between(start, end)
));
}
Expand Down

0 comments on commit 09cb8eb

Please sign in to comment.