Skip to content

Commit ad420c5

Browse files
committed
fix(annotators): only Filters can SelectFields at the top level
1 parent f61165a commit ad420c5

File tree

11 files changed

+36
-81
lines changed

11 files changed

+36
-81
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ prevent messages from reaching further steps and Receivers will take the
1111
resulting message and Send it somewhere external to ACARS-Processor. See
1212
[Filters](#available-filters), [Annotators](#available-annotators), and
1313
[Receivers](#available-receivers) for more information on what's available. You
14-
can also use `SelectedFields` in any Filter or Annotate step to limit what
15-
fields are provided to subsequent steps, and you may also have a separate step
16-
with only `SelectedFields` if you wish.
14+
can also use `SelectedFields` at the top level in any Filter step to limit what
15+
fields are provided to subsequent steps, and you may also have a separate Filter
16+
step with only `SelectedFields` if you wish with remove fields between other
17+
steps
1718

1819
# General Configuration
1920

@@ -93,8 +94,8 @@ in it.
9394
- Yes/no question about the message: "Is this message above 50 in terms of the
9495
anger rating?" (combined with the first example).
9596
- Processing text: "Process this text to remove excessive caps, spelling
96-
errors and remove anything that isn't prose so it reads naturally
97-
and logically"
97+
errors and remove anything that isn't prose so it reads naturally and
98+
logically"
9899

99100
## Available Receivers
100101

acarshub_acars.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ func (a ACARSMessage) GetDefaultFields() APMessage {
2121
// This is the format ACARSHub sends for ACARS messages
2222
type ACARSMessage struct {
2323
gorm.Model
24-
ProcessingStartedAt time.Time
25-
ProcessingFinishedAt time.Time
26-
Processed bool
24+
ProcessingStartedAt time.Time
25+
ProcessingFinishedAt time.Time
26+
Processed bool
2727

2828
// The rest of the struct is the actual message from ACARSHub
29-
FrequencyMHz float64 `json:"freq" ap:"FrequencyMhz"`
29+
FrequencyMHz float64 `json:"freq" ap:"FrequencyMHz"`
3030
Channel int `json:"channel" ap:"Channel"`
3131
ErrorCode int `json:"error"`
3232
SignaldBm float64 `json:"level" ap:"SignalLeveldBm"`
@@ -64,7 +64,7 @@ func (a ACARSMessage) Prepare() (result APMessage) {
6464

6565
// Sometimes tail numbers lead with periods, chop them off
6666
result[ACARSProcessorPrefix+"TailCode"] = strings.TrimLeft(a.AircraftTailCode, ".")
67-
67+
6868
// Extra helper or common fields
6969
result[ACARSProcessorPrefix+"TrackingLink"] = FlightAwareRoot + a.AircraftTailCode
7070
result[ACARSProcessorPrefix+"PhotosLink"] = FlightAwarePhotos + a.AircraftTailCode

acarshub_vdlm2.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ func (v VDLM2Message) GetDefaultFields() APMessage {
2424
// This is the format VDLM2Hub sends
2525
type VDLM2Message struct {
2626
gorm.Model
27-
ProcessingStartedAt time.Time
28-
ProcessingFinishedAt time.Time
29-
Processed bool
27+
ProcessingStartedAt time.Time
28+
ProcessingFinishedAt time.Time
29+
Processed bool
3030
// The rest of the struct is the actual message from ACARSHub
3131
VDL2 struct {
3232
App struct {
@@ -94,8 +94,8 @@ func (v VDLM2Message) Prepare() (result APMessage) {
9494
}
9595
result = FormatAsAPMessage(v, v.Name())
9696

97-
// Sometimes tail numbers lead with periods, chop them off
98-
result[ACARSProcessorPrefix+"TailCode"] = strings.TrimPrefix(v.VDL2.AVLC.ACARS.Registration, ".")
97+
// Sometimes tail numbers lead with periods, chop them off
98+
result[ACARSProcessorPrefix+"TailCode"] = strings.TrimPrefix(v.VDL2.AVLC.ACARS.Registration, ".")
9999

100100
// Extra helper or common fields
101101
result[ACARSProcessorPrefix+"TrackingLink"] = FlightAwareRoot + v.VDL2.AVLC.ACARS.Registration
@@ -105,7 +105,7 @@ func (v VDLM2Message) Prepare() (result APMessage) {
105105
result[ACARSProcessorPrefix+"TranslateLink"] = fmt.Sprintf(GoogleTranslateLink, url.QueryEscape(v.VDL2.AVLC.ACARS.MessageText))
106106
result[ACARSProcessorPrefix+"ACARSDramaTailNumberLink"] = fmt.Sprintf(ACARSDramaTailNumberLink, v.VDL2.AVLC.ACARS.Registration)
107107
result[ACARSProcessorPrefix+"UnixTimestamp"] = int64(v.VDL2.Timestamp.UnixTimestamp)
108-
result[ACARSProcessorPrefix+"FrequencyHz"] =float64(v.VDL2.FrequencyHz) / 1000000
108+
result[ACARSProcessorPrefix+"FrequencyMHz"] = float64(v.VDL2.FrequencyHz) / 1000000
109109
result[ACARSProcessorPrefix+"From"] = AircraftOrTower(v.VDL2.AVLC.ACARS.FlightNumber)
110110

111111
selectedFields := config.ACARSProcessorSettings.ACARSHub.ACARS.SelectedFields

annotators.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"fmt"
5-
"slices"
65

76
log "github.com/sirupsen/logrus"
87
)
@@ -31,13 +30,5 @@ func (as AnnotateStep) Annotate(m APMessage) APMessage {
3130
}
3231
m = MergeAPMessages(m, nm)
3332
}
34-
// Only keep SelectedFields
35-
if len(as.SelectedFields) > 0 {
36-
for messageField := range m {
37-
if !slices.Contains(as.SelectedFields, messageField) {
38-
delete(m, messageField)
39-
}
40-
}
41-
}
4233
return m
4334
}

config.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ type AnnotateStep struct {
180180
Ollama OllamaAnnotator
181181
// // Look up geolocation, including distance from a reference point to aircraft, from ADSB-Exchange
182182
ADSB ADSBExchangeAnnotator
183-
// Remove all but these fields for this annotator step. You can have an annotate step that only selects fields.
184-
SelectedFields []string
185183
}
186184

187185
type ReceiverStep struct {

config_all_options.yaml

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ ACARSProcessorSettings:
3030
Port: 15550
3131
# Only provide these fields to configured steps.
3232
SelectedFields:
33-
- ACARSMessage.ACARSDramaTailNumberLink
3433
- ACARSMessage.ASSStatus
3534
- ACARSMessage.Acknowledge
3635
- ACARSMessage.AircraftTailCode
@@ -44,30 +43,22 @@ ACARSProcessorSettings:
4443
- ACARSMessage.Channel
4544
- ACARSMessage.ErrorCode
4645
- ACARSMessage.FlightNumber
47-
- ACARSMessage.FrequencyHz
4846
- ACARSMessage.FrequencyMHz
49-
- ACARSMessage.From
50-
- ACARSMessage.ImageLink
5147
- ACARSMessage.Label
5248
- ACARSMessage.MessageNumber
5349
- ACARSMessage.MessageText
5450
- ACARSMessage.Mode
5551
- ACARSMessage.Model.DeletedAt.Valid
5652
- ACARSMessage.Model.ID
57-
- ACARSMessage.PhotosLink
5853
- ACARSMessage.Processed
5954
- ACARSMessage.SignaldBm
6055
- ACARSMessage.StationID
61-
- ACARSMessage.ThumbnailLink
6256
- ACARSMessage.Timestamp
63-
- ACARSMessage.TrackingLink
64-
- ACARSMessage.TranslateLink
65-
- ACARSMessage.UnixTimestamp
6657
- ACARSProcessor.ACARSDramaTailNumberLink
6758
- ACARSProcessor.Channel
6859
- ACARSProcessor.FlightNumber
6960
- ACARSProcessor.FrequencyHz
70-
- ACARSProcessor.FrequencyMhz
61+
- ACARSProcessor.FrequencyMHz
7162
- ACARSProcessor.From
7263
- ACARSProcessor.ImageLink
7364
- ACARSProcessor.MessageText
@@ -90,7 +81,7 @@ ACARSProcessorSettings:
9081
- ACARSProcessor.ACARSDramaTailNumberLink
9182
- ACARSProcessor.FlightNumber
9283
- ACARSProcessor.FrequencyHz
93-
- ACARSProcessor.FrequencyMhz
84+
- ACARSProcessor.FrequencyMHz
9485
- ACARSProcessor.From
9586
- ACARSProcessor.ImageLink
9687
- ACARSProcessor.MessageText
@@ -102,17 +93,9 @@ ACARSProcessorSettings:
10293
- ACARSProcessor.TrackingLink
10394
- ACARSProcessor.TranslateLink
10495
- ACARSProcessor.UnixTimestamp
105-
- VDLM2Message.ACARSDramaTailNumberLink
106-
- VDLM2Message.FrequencyMHz
107-
- VDLM2Message.From
108-
- VDLM2Message.ImageLink
10996
- VDLM2Message.Model.DeletedAt.Valid
11097
- VDLM2Message.Model.ID
111-
- VDLM2Message.PhotosLink
11298
- VDLM2Message.Processed
113-
- VDLM2Message.ThumbnailLink
114-
- VDLM2Message.TrackingLink
115-
- VDLM2Message.TranslateLink
11699
- VDLM2Message.VDL2.AVLC.ACARS.Acknowledge
117100
- VDLM2Message.VDL2.AVLC.ACARS.BlockID
118101
- VDLM2Message.VDL2.AVLC.ACARS.CRCOK
@@ -346,8 +329,6 @@ Steps:
346329
- ADSBExchangeAnnotator.Message
347330
- ADSBExchangeAnnotator.ServerProcessingTime
348331
- ADSBExchangeAnnotator.TotalAircraftResults
349-
# Remove all but these fields for this annotator step. You can have an annotate step that only selects fields.
350-
SelectedFields: []
351332
# Send the message to one or more receivers in this step
352333
Send:
353334
# Send messages to a Discord channel using a webhook created from that channel.

config_example.yaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# yaml-language-server: $schema=./schema.json
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/tyzbit/acars-processor/refs/heads/main/schema.json
22

3-
# Purpose: Forward all human-created messages to Discord
43
# Environment variables are substituted at runtime by acars-processor
54
ACARSProcessorSettings:
65
Database:
@@ -15,7 +14,7 @@ ACARSProcessorSettings:
1514
SelectedFields: &selectedfields
1615
- ACARSProcessor.ACARSDramaTailNumberLink
1716
- ACARSProcessor.FlightNumber
18-
- ACARSProcessor.FrequencyMhz
17+
- ACARSProcessor.FrequencyMHz
1918
- ACARSProcessor.From
2019
- ACARSProcessor.ImageLink
2120
- ACARSProcessor.MessageText
@@ -33,7 +32,7 @@ ACARSProcessorSettings:
3332
SelectedFields: *selectedfields
3433

3534
Steps:
36-
# HIGHLY recommended if you care about message text
35+
# HIGHLY recommended if you only care about message text.
3736
- Filter: { Builtin: { HasText: true } }
3837
- Filter: { Builtin: { DictionaryPhraseLengthMinimum: 2 } }
3938
- Filter:
@@ -49,14 +48,16 @@ Steps:
4948
- Filter:
5049
Builtin:
5150
# If we don't have geolocation for an aircraft, the message stops here
52-
# Anything that gets past this point came from an aircraft with 100
51+
# because of FilterOnFailure.
52+
# Anything that gets past this point came from an aircraft within 100
5353
# miles of the reference geolocation.
5454
FilterOnFailure: true
5555
BelowDistanceMi: 100.0
5656
- Filter:
5757
Ollama:
5858
Model: &ollamamodel qwen3:30b-a3b
5959
URL: &ollamaurl http://ollama:11434
60+
# If Ollama doesn't respond, the message stops.
6061
FilterOnFailure: true
6162
MaxRetryAttempts: 1
6263
MaxRetryDelaySeconds: 5
@@ -138,11 +139,11 @@ Steps:
138139
- ACARSProcessor.LLMProcessedNumber
139140
- ACARSProcessor.LLMProcessedText
140141
- ACARSProcessor.LLMYesNoQuestionAnswer
141-
- Annotate:
142+
- Filter:
142143
SelectedFields:
143144
- ACARSProcessor.ACARSDramaTailNumberLink
144145
- ACARSProcessor.AircraftDistanceMi
145-
- ACARSProcessor.FrequencyMhz
146+
- ACARSProcessor.FrequencyMHz
146147
- ACARSProcessor.From
147148
- ACARSProcessor.ImageLink
148149
- ACARSProcessor.MessageText
@@ -161,9 +162,9 @@ Steps:
161162
# each message will be one color or the other - which colors are not
162163
# guaranteed, but right now it's orangeish and yellow.
163164
EmbedColorFacetFields: [ACARSProcessor.From]
164-
# # Uncomment this to have the message differently colored in a
165-
# # generally neutral to critical color scheme based on the
166-
# # number the LLM came up with earlier
165+
# Uncomment this to have the message differently colored in a
166+
# generally neutral to critical color scheme based on the
167+
# number rating the LLM came up with earlier
167168
# EmbedColorGradientField: ACARSProcessor.LLMProcessedNumber
168169
URL: "${acars_discord_webhook}"
169170
FormatText: true

default_fields.md

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
### ACARS Messages
1717

18-
- ACARSMessage.ACARSDramaTailNumberLink
1918
- ACARSMessage.ASSStatus
2019
- ACARSMessage.Acknowledge
2120
- ACARSMessage.AircraftTailCode
@@ -29,30 +28,22 @@
2928
- ACARSMessage.Channel
3029
- ACARSMessage.ErrorCode
3130
- ACARSMessage.FlightNumber
32-
- ACARSMessage.FrequencyHz
3331
- ACARSMessage.FrequencyMHz
34-
- ACARSMessage.From
35-
- ACARSMessage.ImageLink
3632
- ACARSMessage.Label
3733
- ACARSMessage.MessageNumber
3834
- ACARSMessage.MessageText
3935
- ACARSMessage.Mode
4036
- ACARSMessage.Model.DeletedAt.Valid
4137
- ACARSMessage.Model.ID
42-
- ACARSMessage.PhotosLink
4338
- ACARSMessage.Processed
4439
- ACARSMessage.SignaldBm
4540
- ACARSMessage.StationID
46-
- ACARSMessage.ThumbnailLink
4741
- ACARSMessage.Timestamp
48-
- ACARSMessage.TrackingLink
49-
- ACARSMessage.TranslateLink
50-
- ACARSMessage.UnixTimestamp
5142
- ACARSProcessor.ACARSDramaTailNumberLink
5243
- ACARSProcessor.Channel
5344
- ACARSProcessor.FlightNumber
5445
- ACARSProcessor.FrequencyHz
55-
- ACARSProcessor.FrequencyMhz
46+
- ACARSProcessor.FrequencyMHz
5647
- ACARSProcessor.From
5748
- ACARSProcessor.ImageLink
5849
- ACARSProcessor.MessageText
@@ -70,7 +61,7 @@
7061
- ACARSProcessor.ACARSDramaTailNumberLink
7162
- ACARSProcessor.FlightNumber
7263
- ACARSProcessor.FrequencyHz
73-
- ACARSProcessor.FrequencyMhz
64+
- ACARSProcessor.FrequencyMHz
7465
- ACARSProcessor.From
7566
- ACARSProcessor.ImageLink
7667
- ACARSProcessor.MessageText
@@ -82,17 +73,9 @@
8273
- ACARSProcessor.TrackingLink
8374
- ACARSProcessor.TranslateLink
8475
- ACARSProcessor.UnixTimestamp
85-
- VDLM2Message.ACARSDramaTailNumberLink
86-
- VDLM2Message.FrequencyMHz
87-
- VDLM2Message.From
88-
- VDLM2Message.ImageLink
8976
- VDLM2Message.Model.DeletedAt.Valid
9077
- VDLM2Message.Model.ID
91-
- VDLM2Message.PhotosLink
9278
- VDLM2Message.Processed
93-
- VDLM2Message.ThumbnailLink
94-
- VDLM2Message.TrackingLink
95-
- VDLM2Message.TranslateLink
9679
- VDLM2Message.VDL2.AVLC.ACARS.Acknowledge
9780
- VDLM2Message.VDL2.AVLC.ACARS.BlockID
9881
- VDLM2Message.VDL2.AVLC.ACARS.CRCOK

filter_builtin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ var (
170170
return !flightNumberMatches, reason, nil
171171
},
172172
"Frequency": func(f BuiltinFilter, m APMessage) (filter bool, reason string, err error) {
173-
fmhz := GetAPMessageCommonFieldAsFloat64(m, "FrequencyMhz")
173+
fmhz := GetAPMessageCommonFieldAsFloat64(m, "FrequencyMHz")
174174
fhz := GetAPMessageCommonFieldAsFloat64(m, "FrequencyHz")
175175
if fmhz == 0.0 && fhz == 0.0 {
176-
return false, "FrequencyMhz and FrequencyHz were empty", nil
176+
return false, "FrequencyMHz and FrequencyHz were empty", nil
177177
}
178178
if fmhz != 0.0 && fhz == 0.0 {
179179
fmhz = fmhz * 1000000

schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,4 +363,4 @@ func extractStructFieldComments() (commentMap, error) {
363363
}
364364

365365
return comments, nil
366-
}
366+
}

0 commit comments

Comments
 (0)