Skip to content

Commit

Permalink
add: control flag to enable/disable enrichment
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgelionis committed May 22, 2024
1 parent 7a68ad3 commit 1110c2f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ExternalSearch.Providers.GoogleMaps/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public struct KeyName
{
public const string ApiToken = "apiToken";
public const string AcceptedEntityType = "acceptedEntityType";
public const string ControlFlag = "controlFlag";
public const string OrgNameKey = "orgNameKey";
public const string OrgAddressKey = "orgAddressKey";
public const string OrgZipCodeKey = "orgZipCodeKey";
Expand Down Expand Up @@ -52,6 +53,13 @@ public struct KeyName
name = KeyName.AcceptedEntityType
},
new Control()
{
displayName = "Vocabulary Key used to control whether it should be enriched",
type = "input",
isRequired = false,
name = KeyName.ControlFlag
},
new Control()
{
displayName = "Organization Name vocab key",
type = "input",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public GoogleMapsExternalSearchJobData(IDictionary<string, object> configuration
{
ApiToken = GetValue<string>(configuration, Constants.KeyName.ApiToken);
AcceptedEntityType = GetValue<string>(configuration, Constants.KeyName.AcceptedEntityType);
ControlFlag = GetValue<string>(configuration, Constants.KeyName.ControlFlag);
OrgNameKey = GetValue<string>(configuration, Constants.KeyName.OrgNameKey);
OrgAddressKey = GetValue<string>(configuration, Constants.KeyName.OrgAddressKey);
OrgZipCodeKey = GetValue<string>(configuration, Constants.KeyName.OrgZipCodeKey);
Expand All @@ -28,6 +29,7 @@ public GoogleMapsExternalSearchJobData(IDictionary<string, object> configuration
return new Dictionary<string, object> {
{ Constants.KeyName.ApiToken, ApiToken },
{ Constants.KeyName.AcceptedEntityType, AcceptedEntityType },
{ Constants.KeyName.ControlFlag, ControlFlag },
{ Constants.KeyName.OrgNameKey, OrgNameKey },
{ Constants.KeyName.OrgAddressKey, OrgAddressKey },
{ Constants.KeyName.OrgZipCodeKey, OrgZipCodeKey },
Expand All @@ -45,6 +47,7 @@ public GoogleMapsExternalSearchJobData(IDictionary<string, object> configuration

public string ApiToken { get; set; }
public string AcceptedEntityType { get; set; }
public string ControlFlag { get; set; }
public string OrgNameKey { get; set; }
public string OrgAddressKey { get; set; }
public string OrgZipCodeKey { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ private IEnumerable<IExternalSearchQuery> InternalBuildQueries(ExecutionContext
else if (!this.Accepts(request.EntityMetaData.EntityType))
yield break;

if (config.TryGetValue(Constants.KeyName.ControlFlag, out var controlFlag) && !string.IsNullOrWhiteSpace(controlFlag?.ToString()))
{
if (request.EntityMetaData.Properties.GetValue(controlFlag.ToString()) != "true")
{
context.Log.LogTrace($"Skipped enrichment for record {request.EntityMetaData.OriginEntityCode} because VocabularyKey {controlFlag} value was not true. Actual value: {request.EntityMetaData.Properties.GetValue(controlFlag.ToString())}");
yield break;
}
}

//var entityType = request.EntityMetaData.EntityType;

//if (string.IsNullOrEmpty(this.TokenProvider.ApiToken))
Expand Down

0 comments on commit 1110c2f

Please sign in to comment.