refactor: Update ARR body parsing logic

This commit is contained in:
windyboy
2024-07-23 12:34:14 +08:00
parent 3b9b64ec9e
commit 12a9da1ca1
6 changed files with 38 additions and 124 deletions
+18 -26
View File
@@ -4,6 +4,7 @@ package repository
import (
"context"
"encoding/json"
"time"
"github.com/Khan/genqlient/graphql"
@@ -12,29 +13,28 @@ import (
// input type for inserting data into table "aviation.telegrams"
type Aviation_telegrams_insert_input struct {
Body_and_footer string `json:"body_and_footer"`
Body_data string `json:"body_data"`
Category string `json:"category"`
Date_time string `json:"date_time"`
Dispatched_at time.Time `json:"dispatched_at"`
Id int `json:"id"`
Message_id string `json:"message_id"`
Need_dispatch bool `json:"need_dispatch"`
Originator string `json:"originator"`
Originator_date_time string `json:"originator_date_time"`
Parsed_at time.Time `json:"parsed_at"`
Primary_address string `json:"primary_address"`
Priority_indicator string `json:"priority_indicator"`
Received_at time.Time `json:"received_at"`
Secondary_addresses string `json:"secondary_addresses"`
Uuid uuid.UUID `json:"uuid"`
Body_and_footer string `json:"body_and_footer"`
Body_data json.RawMessage `json:"body_data"`
Category string `json:"category"`
Date_time string `json:"date_time"`
Dispatched_at time.Time `json:"dispatched_at"`
Message_id string `json:"message_id"`
Need_dispatch bool `json:"need_dispatch"`
Originator string `json:"originator"`
Originator_date_time string `json:"originator_date_time"`
Parsed_at time.Time `json:"parsed_at"`
Primary_address string `json:"primary_address"`
Priority_indicator string `json:"priority_indicator"`
Received_at time.Time `json:"received_at"`
Secondary_addresses json.RawMessage `json:"secondary_addresses"`
Uuid uuid.UUID `json:"uuid"`
}
// GetBody_and_footer returns Aviation_telegrams_insert_input.Body_and_footer, and is useful for accessing the field via an interface.
func (v *Aviation_telegrams_insert_input) GetBody_and_footer() string { return v.Body_and_footer }
// GetBody_data returns Aviation_telegrams_insert_input.Body_data, and is useful for accessing the field via an interface.
func (v *Aviation_telegrams_insert_input) GetBody_data() string { return v.Body_data }
func (v *Aviation_telegrams_insert_input) GetBody_data() json.RawMessage { return v.Body_data }
// GetCategory returns Aviation_telegrams_insert_input.Category, and is useful for accessing the field via an interface.
func (v *Aviation_telegrams_insert_input) GetCategory() string { return v.Category }
@@ -45,9 +45,6 @@ func (v *Aviation_telegrams_insert_input) GetDate_time() string { return v.Date_
// GetDispatched_at returns Aviation_telegrams_insert_input.Dispatched_at, and is useful for accessing the field via an interface.
func (v *Aviation_telegrams_insert_input) GetDispatched_at() time.Time { return v.Dispatched_at }
// GetId returns Aviation_telegrams_insert_input.Id, and is useful for accessing the field via an interface.
func (v *Aviation_telegrams_insert_input) GetId() int { return v.Id }
// GetMessage_id returns Aviation_telegrams_insert_input.Message_id, and is useful for accessing the field via an interface.
func (v *Aviation_telegrams_insert_input) GetMessage_id() string { return v.Message_id }
@@ -75,7 +72,7 @@ func (v *Aviation_telegrams_insert_input) GetPriority_indicator() string { retur
func (v *Aviation_telegrams_insert_input) GetReceived_at() time.Time { return v.Received_at }
// GetSecondary_addresses returns Aviation_telegrams_insert_input.Secondary_addresses, and is useful for accessing the field via an interface.
func (v *Aviation_telegrams_insert_input) GetSecondary_addresses() string {
func (v *Aviation_telegrams_insert_input) GetSecondary_addresses() json.RawMessage {
return v.Secondary_addresses
}
@@ -95,14 +92,10 @@ func (v *__newMessageInput) GetObject() Aviation_telegrams_insert_input { return
//
// columns and relationships of "aviation.telegrams"
type newMessageInsert_aviation_telegrams_oneAviation_telegrams struct {
Id int `json:"id"`
Message_id string `json:"message_id"`
Uuid uuid.UUID `json:"uuid"`
}
// GetId returns newMessageInsert_aviation_telegrams_oneAviation_telegrams.Id, and is useful for accessing the field via an interface.
func (v *newMessageInsert_aviation_telegrams_oneAviation_telegrams) GetId() int { return v.Id }
// GetMessage_id returns newMessageInsert_aviation_telegrams_oneAviation_telegrams.Message_id, and is useful for accessing the field via an interface.
func (v *newMessageInsert_aviation_telegrams_oneAviation_telegrams) GetMessage_id() string {
return v.Message_id
@@ -128,7 +121,6 @@ func (v *newMessageResponse) GetInsert_aviation_telegrams_one() newMessageInsert
const newMessage_Operation = `
mutation newMessage ($object: aviation_telegrams_insert_input!) {
insert_aviation_telegrams_one(object: $object) {
id
message_id
uuid
}
-1
View File
@@ -1,6 +1,5 @@
mutation newMessage($object: aviation_telegrams_insert_input!) {
insert_aviation_telegrams_one(object: $object) {
id
message_id
uuid
}
+1 -1
View File
@@ -6,7 +6,7 @@ operations:
generated: generated.go
bindings:
jsonb:
type: string
type: encoding/json.RawMessage
timestamp:
type: time.Time
uuid:
+11 -11
View File
@@ -10,11 +10,11 @@
"TotalSpecs": 1,
"SpecsThatWillRun": 1
},
"StartTime": "2024-07-23T12:01:15.75278901+08:00",
"EndTime": "2024-07-23T12:01:15.764655302+08:00",
"RunTime": 11866337,
"StartTime": "2024-07-23T12:33:42.47682339+08:00",
"EndTime": "2024-07-23T12:33:42.480755442+08:00",
"RunTime": 3932052,
"SuiteConfig": {
"RandomSeed": 1721707275,
"RandomSeed": 1721709222,
"RandomizeAllSpecs": false,
"FocusStrings": [
"Repositories Hasura Repository should mutate a parsed message"
@@ -31,7 +31,7 @@
"DryRun": false,
"PollProgressAfter": 0,
"PollProgressInterval": 0,
"Timeout": 3599595734975,
"Timeout": 3599595857926,
"EmitSpecProgress": false,
"OutputInterceptorMode": "",
"SourceRoots": null,
@@ -68,9 +68,9 @@
"LeafNodeLabels": [],
"LeafNodeText": "should mutate a parsed message",
"State": "passed",
"StartTime": "2024-07-23T12:01:15.752849553+08:00",
"EndTime": "2024-07-23T12:01:15.764585492+08:00",
"RunTime": 11735991,
"StartTime": "2024-07-23T12:33:42.476903287+08:00",
"EndTime": "2024-07-23T12:33:42.480729619+08:00",
"RunTime": 3826334,
"ParallelProcess": 1,
"NumAttempts": 1,
"MaxFlakeAttempts": 0,
@@ -84,7 +84,7 @@
},
"TimelineLocation": {
"Order": 1,
"Time": "2024-07-23T12:01:15.752859429+08:00"
"Time": "2024-07-23T12:33:42.476916857+08:00"
},
"Message": "should mutate a parsed message",
"NodeType": "It"
@@ -97,10 +97,10 @@
},
"TimelineLocation": {
"Order": 3,
"Time": "2024-07-23T12:01:15.764576564+08:00"
"Time": "2024-07-23T12:33:42.480726236+08:00"
},
"Message": "should mutate a parsed message",
"Duration": 11717183,
"Duration": 3809380,
"NodeType": "It"
}
]
+2 -1
View File
@@ -33,11 +33,12 @@ func (hr *HasuraRepository) InsertParsedMessage(pm *domain.ParsedMessage) error
variables := Aviation_telegrams_insert_input{
// Id: 10,
Body_and_footer: pm.BodyAndFooter,
Body_data: string(bodyString),
Body_data: bodyString,
Category: pm.Category,
Date_time: pm.DateTime,
Dispatched_at: pm.DispatchedAt,
Uuid: uuid.New(),
Received_at: pm.ReceivedAt,
}
_, err := newMessage(context.Background(), hr.client, variables)
if err != nil {
+6 -84
View File
@@ -108,8 +108,7 @@ type aviation_telegrams {
category: String
date_time: String
dispatched_at: timestamp
id: Int!
message_id: String
message_id: String!
need_dispatch: Boolean
originator: String
originator_date_time: String
@@ -136,17 +135,9 @@ type aviation_telegrams_aggregate {
aggregate fields of "aviation.telegrams"
"""
type aviation_telegrams_aggregate_fields {
avg: aviation_telegrams_avg_fields
count(columns: [aviation_telegrams_select_column!], distinct: Boolean): Int!
max: aviation_telegrams_max_fields
min: aviation_telegrams_min_fields
stddev: aviation_telegrams_stddev_fields
stddev_pop: aviation_telegrams_stddev_pop_fields
stddev_samp: aviation_telegrams_stddev_samp_fields
sum: aviation_telegrams_sum_fields
var_pop: aviation_telegrams_var_pop_fields
var_samp: aviation_telegrams_var_samp_fields
variance: aviation_telegrams_variance_fields
}
"""append existing jsonb value of filtered columns with new jsonb value"""
@@ -155,11 +146,6 @@ input aviation_telegrams_append_input {
secondary_addresses: jsonb
}
"""aggregate avg on columns"""
type aviation_telegrams_avg_fields {
id: Float
}
"""
Boolean expression to filter rows from the table "aviation.telegrams". All fields are combined with a logical 'AND'.
"""
@@ -172,7 +158,6 @@ input aviation_telegrams_bool_exp {
category: String_comparison_exp
date_time: String_comparison_exp
dispatched_at: timestamp_comparison_exp
id: Int_comparison_exp
message_id: String_comparison_exp
need_dispatch: Boolean_comparison_exp
originator: String_comparison_exp
@@ -190,7 +175,7 @@ unique or primary key constraints on table "aviation.telegrams"
"""
enum aviation_telegrams_constraint {
"""
unique or primary key constraint on columns "id"
unique or primary key constraint on columns "message_id"
"""
telegrams_pkey
@@ -224,13 +209,6 @@ input aviation_telegrams_delete_key_input {
secondary_addresses: String
}
"""
input type for incrementing numeric columns in table "aviation.telegrams"
"""
input aviation_telegrams_inc_input {
id: Int
}
"""
input type for inserting data into table "aviation.telegrams"
"""
@@ -240,7 +218,6 @@ input aviation_telegrams_insert_input {
category: String
date_time: String
dispatched_at: timestamp
id: Int
message_id: String
need_dispatch: Boolean
originator: String
@@ -259,7 +236,6 @@ type aviation_telegrams_max_fields {
category: String
date_time: String
dispatched_at: timestamp
id: Int
message_id: String
originator: String
originator_date_time: String
@@ -276,7 +252,6 @@ type aviation_telegrams_min_fields {
category: String
date_time: String
dispatched_at: timestamp
id: Int
message_id: String
originator: String
originator_date_time: String
@@ -314,7 +289,6 @@ input aviation_telegrams_order_by {
category: order_by
date_time: order_by
dispatched_at: order_by
id: order_by
message_id: order_by
need_dispatch: order_by
originator: order_by
@@ -329,7 +303,7 @@ input aviation_telegrams_order_by {
"""primary key columns input for table: aviation.telegrams"""
input aviation_telegrams_pk_columns_input {
id: Int!
message_id: String!
}
"""prepend existing jsonb value of filtered columns with new jsonb value"""
@@ -357,9 +331,6 @@ enum aviation_telegrams_select_column {
"""column name"""
dispatched_at
"""column name"""
id
"""column name"""
message_id
@@ -400,7 +371,6 @@ input aviation_telegrams_set_input {
category: String
date_time: String
dispatched_at: timestamp
id: Int
message_id: String
need_dispatch: Boolean
originator: String
@@ -413,21 +383,6 @@ input aviation_telegrams_set_input {
uuid: uuid
}
"""aggregate stddev on columns"""
type aviation_telegrams_stddev_fields {
id: Float
}
"""aggregate stddev_pop on columns"""
type aviation_telegrams_stddev_pop_fields {
id: Float
}
"""aggregate stddev_samp on columns"""
type aviation_telegrams_stddev_samp_fields {
id: Float
}
"""
Streaming cursor of the table "aviation_telegrams"
"""
@@ -446,7 +401,6 @@ input aviation_telegrams_stream_cursor_value_input {
category: String
date_time: String
dispatched_at: timestamp
id: Int
message_id: String
need_dispatch: Boolean
originator: String
@@ -459,11 +413,6 @@ input aviation_telegrams_stream_cursor_value_input {
uuid: uuid
}
"""aggregate sum on columns"""
type aviation_telegrams_sum_fields {
id: Int
}
"""
update columns of table "aviation.telegrams"
"""
@@ -483,9 +432,6 @@ enum aviation_telegrams_update_column {
"""column name"""
dispatched_at
"""column name"""
id
"""column name"""
message_id
@@ -536,9 +482,6 @@ input aviation_telegrams_updates {
"""
_delete_key: aviation_telegrams_delete_key_input
"""increments the numeric columns with given value of the filtered values"""
_inc: aviation_telegrams_inc_input
"""prepend existing jsonb value of filtered columns with new jsonb value"""
_prepend: aviation_telegrams_prepend_input
@@ -549,21 +492,6 @@ input aviation_telegrams_updates {
where: aviation_telegrams_bool_exp!
}
"""aggregate var_pop on columns"""
type aviation_telegrams_var_pop_fields {
id: Float
}
"""aggregate var_samp on columns"""
type aviation_telegrams_var_samp_fields {
id: Float
}
"""aggregate variance on columns"""
type aviation_telegrams_variance_fields {
id: Float
}
"""user for test simple graphql"""
type aviation_user {
email: String!
@@ -859,7 +787,7 @@ type mutation_root {
"""
delete single row from the table: "aviation.telegrams"
"""
delete_aviation_telegrams_by_pk(id: Int!): aviation_telegrams
delete_aviation_telegrams_by_pk(message_id: String!): aviation_telegrams
"""
delete data from the table: "aviation.user"
@@ -940,9 +868,6 @@ type mutation_root {
"""
_delete_key: aviation_telegrams_delete_key_input
"""increments the numeric columns with given value of the filtered values"""
_inc: aviation_telegrams_inc_input
"""prepend existing jsonb value of filtered columns with new jsonb value"""
_prepend: aviation_telegrams_prepend_input
@@ -975,9 +900,6 @@ type mutation_root {
"""
_delete_key: aviation_telegrams_delete_key_input
"""increments the numeric columns with given value of the filtered values"""
_inc: aviation_telegrams_inc_input
"""prepend existing jsonb value of filtered columns with new jsonb value"""
_prepend: aviation_telegrams_prepend_input
@@ -1094,7 +1016,7 @@ type query_root {
"""
fetch data from the table: "aviation.telegrams" using primary key columns
"""
aviation_telegrams_by_pk(id: Int!): aviation_telegrams
aviation_telegrams_by_pk(message_id: String!): aviation_telegrams
"""
fetch data from the table: "aviation.user"
@@ -1184,7 +1106,7 @@ type subscription_root {
"""
fetch data from the table: "aviation.telegrams" using primary key columns
"""
aviation_telegrams_by_pk(id: Int!): aviation_telegrams
aviation_telegrams_by_pk(message_id: String!): aviation_telegrams
"""
fetch data from the table in a streaming manner: "aviation.telegrams"