5
5
import structlog
6
6
from more_itertools import one
7
7
8
- from autogenerated_graphql_client import GraphQLClient
8
+ from job_function_configurator . autogenerated_graphql_client import GraphQLClient
9
9
from job_function_configurator .config import get_settings
10
10
from job_function_configurator .helper_functions import (
11
11
check_for_blacklisted_engagement_job_function_user_keys ,
@@ -39,10 +39,7 @@ async def process_engagement_events(
39
39
engagement_uuid , settings .email_user_key_for_address_type
40
40
)
41
41
42
- if (
43
- engagement_object_parsed_as_model
44
- or engagement_object_parsed_as_model .objects is None
45
- ):
42
+ if len (engagement_object_parsed_as_model .objects ) == 0 :
46
43
# No objects were found in the GraphQL payload - might be a termination.
47
44
logger .info ("Engagement objects are missing" )
48
45
return
@@ -60,6 +57,7 @@ async def process_engagement_events(
60
57
61
58
# Use the engagements current "from" date to avoid multiple entries in database.
62
59
update_from_date = engagement_objects .validity .from_
60
+ update_to_date = engagement_objects .validity .to
63
61
64
62
# Check whether job functions codes are in blacklist.
65
63
job_function_user_key = engagement_objects .job_function .user_key
@@ -70,6 +68,7 @@ async def process_engagement_events(
70
68
await mo .update_extension_field (
71
69
engagement_uuid ,
72
70
update_from_date ,
71
+ update_to_date ,
73
72
settings .emtpy_content_for_extension_field_update ,
74
73
)
75
74
@@ -90,7 +89,7 @@ async def process_engagement_events(
90
89
)
91
90
job_function_name_from_sd = engagement_objects .job_function .name
92
91
await mo .update_extension_field (
93
- engagement_uuid , update_from_date , job_function_name_from_sd
92
+ engagement_uuid , update_from_date , update_to_date , job_function_name_from_sd
94
93
)
95
94
# We should have passed the check for blacklisted job function codes (user keys)
96
95
# at this point.
@@ -131,7 +130,7 @@ async def process_engagement_events(
131
130
new_job_function = engagement_objects .extension_2
132
131
# Make a mutation, write the contents of extension_2, to extension_x.
133
132
await mo .update_extension_field (
134
- engagement_uuid , update_from_date , new_job_function
133
+ engagement_uuid , update_from_date , update_to_date , new_job_function
135
134
)
136
135
logger .info (
137
136
"An update with the contents of extension_2 was successfully made to"
@@ -142,7 +141,7 @@ async def process_engagement_events(
142
141
# Make mutation, write what is the current job function name to the extension.
143
142
job_function_name_from_sd = engagement_objects .job_function .name
144
143
await mo .update_extension_field (
145
- engagement_uuid , update_from_date , job_function_name_from_sd
144
+ engagement_uuid , update_from_date , update_to_date , job_function_name_from_sd
146
145
)
147
146
logger .info (
148
147
"An update with the job function from SD was successfully made to"
@@ -154,7 +153,7 @@ async def process_engagement_events(
154
153
# job functions name to the new extension.
155
154
job_function_name_from_sd = engagement_objects .job_function .name
156
155
await mo .update_extension_field (
157
- engagement_uuid , update_from_date , job_function_name_from_sd
156
+ engagement_uuid , update_from_date , update_to_date , job_function_name_from_sd
158
157
)
159
158
logger .info (
160
159
"An update with the job function from SD was successfully made to"
0 commit comments