Working select filters with include and exclude logic
This commit is contained in:
Binary file not shown.
@@ -19,9 +19,16 @@ def buildOperation(definition):
|
||||
if skipStep(definition, action, outputs):
|
||||
continue
|
||||
|
||||
if hasattr(action, "recursive"):
|
||||
for item in outputs[action.recursive["source"]]:
|
||||
#target = outputs[action.recursive["source"]["target"]
|
||||
outputs, response = buildAction(action, outputs)
|
||||
#print(outputs["message"])
|
||||
return outputs
|
||||
outputs, response = buildAction(action, outputs)
|
||||
responses.append(response)
|
||||
|
||||
#except Exception as error:
|
||||
#outputs = manageFailure(error, action, outputs)
|
||||
#print(outputs["message"])
|
||||
return outputs
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
from core.runtime import buildSelect, buildSelect2, buildOutput, buildSave, buildLog
|
||||
|
||||
from core.runtime.select import buildSelect3
|
||||
#select_data = {}
|
||||
|
||||
def buildRuntimeAttr(action, outputs, response):
|
||||
@@ -15,7 +15,7 @@ def buildRuntimeAttr(action, outputs, response):
|
||||
outputs = buildOutput(response, action, outputs)#, select_data)
|
||||
|
||||
if hasattr(action, "select"):
|
||||
select_data, action, outputs = buildSelect2(action, outputs)
|
||||
select_data, action, outputs = buildSelect3(action, outputs)
|
||||
#print("AFTER buildOutput:", type(outputs))
|
||||
#print("DEBUG buildSave")
|
||||
#print("outputs type:", type(outputs))
|
||||
|
||||
+88
-1
@@ -18,6 +18,7 @@ def buildSelect(response, action, outputs):
|
||||
|
||||
return selection, action, outputs
|
||||
|
||||
|
||||
def buildSelect2(action, outputs):
|
||||
#print(outputs)
|
||||
select_data = []
|
||||
@@ -25,10 +26,29 @@ def buildSelect2(action, outputs):
|
||||
selectmethod = action.select["selectmethod"]
|
||||
targetkey = action.select["key"]
|
||||
targetvalue = action.select["value"]
|
||||
|
||||
if isinstance(targetvalue, dict):
|
||||
for resolvekey, resolveval in targetvalue.items():
|
||||
print(resolvekey)
|
||||
print(resolveval)
|
||||
#outputtarget = outputs[resolvekey]
|
||||
#for thing in resolveval:
|
||||
outputtarget = outputs[resolvekey][resolveval[0]][resolveval[1]]
|
||||
print (outputtarget)
|
||||
targetvalue = outputtarget
|
||||
#for item in target:
|
||||
for item in target:
|
||||
#print (item)
|
||||
for key, value in item.items():
|
||||
#if isinstance(targetvalue, dict):
|
||||
#for resolvekey, resolveval in targetvalue.items():
|
||||
#print(resolvekey)
|
||||
#print(resolveval)
|
||||
#outputtarget = outputs[resolvekey]
|
||||
#for thing in resolveval:
|
||||
#outputtarget = outputs[resolvekey][resolveval[0]][resolveval[1]]
|
||||
#print (outputtarget)
|
||||
#outputtarget = targetvalue
|
||||
if selectmethod == "exclude":
|
||||
if targetkey == key and item[key] != targetvalue:
|
||||
select_data.append(item)
|
||||
@@ -37,9 +57,76 @@ def buildSelect2(action, outputs):
|
||||
if targetkey == key and item[key] == targetvalue:
|
||||
select_data.append(item)
|
||||
#print(item)
|
||||
print(select_data)
|
||||
outputs[action.select["source"]] = select_data
|
||||
#print(outputs)
|
||||
return select_data, action, outputs
|
||||
#for item in outputs[output_name]:
|
||||
#for key, value in action.select.include.items():
|
||||
#if key in item and item[key] == value:
|
||||
#select_data.append(item)
|
||||
|
||||
def buildSelect3(action, outputs):
|
||||
#print(outputs)
|
||||
select_data = []
|
||||
target = outputs[action.select["source"]]
|
||||
#selectmethod = action.select["selectmethod"]
|
||||
includekey = action.select["include"]["key"]
|
||||
includevalue = action.select["include"]["value"]
|
||||
excludekey = action.select["exclude"]["key"]
|
||||
excludevalue = action.select["exclude"]["value"]
|
||||
#if isinstance(targetvalue, dict):
|
||||
#for resolvekey, resolveval in targetvalue.items():
|
||||
#print(resolvekey)
|
||||
#print(resolveval)
|
||||
#outputtarget = outputs[resolvekey]
|
||||
#for thing in resolveval:
|
||||
#outputtarget = outputs[resolvekey][resolveval[0]][resolveval[1]]
|
||||
#print (outputtarget)
|
||||
#targetvalue = outputtarget
|
||||
#for item in target:
|
||||
#include_match = True
|
||||
#exclude_match = True
|
||||
|
||||
for item in target:
|
||||
include_match = True
|
||||
exclude_match = True
|
||||
|
||||
if includekey:
|
||||
include_match = item[includekey] == includevalue
|
||||
|
||||
if excludekey:
|
||||
exclude_match = item[excludekey] != excludevalue
|
||||
|
||||
if include_match and exclude_match:
|
||||
select_data.append(item)
|
||||
#print (item)
|
||||
#for key, value in item.items():
|
||||
#if isinstance(targetvalue, dict):
|
||||
#for resolvekey, resolveval in targetvalue.items():
|
||||
#print(resolvekey)
|
||||
#print(resolveval)
|
||||
#outputtarget = outputs[resolvekey]
|
||||
#for thing in resolveval:
|
||||
#outputtarget = outputs[resolvekey][resolveval[0]][resolveval[1]]
|
||||
#print (outputtarget)
|
||||
#outputtarget = targetvalue
|
||||
#if selectmethod == "exclude":
|
||||
#if item[excludekey] != excludevalue:# and item[includekey] == includevalue:
|
||||
#if includekey == key and item[key] == includevalue:
|
||||
#if item[excludekey] == excludevalue:
|
||||
#continue
|
||||
#select_data.append(item)
|
||||
#if item[includekey] == includevalue:
|
||||
#if includekey == key and item[key] == includevalue:
|
||||
#continue
|
||||
#select_data.append(item)
|
||||
#if excludekey == key and item[key] != excludevalue:
|
||||
#select_data.append(item)
|
||||
#print(item)
|
||||
#if selectmethod == "include":
|
||||
#if excludekey == key and item[key] == excludevalue:
|
||||
#select_data.append(item)
|
||||
#print(item)
|
||||
outputs[action.select["source"]] = select_data
|
||||
print(select_data)
|
||||
return select_data, action, outputs
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,7 @@
|
||||
import os
|
||||
|
||||
#getoutputs = {"emails": [0, "id"]}
|
||||
|
||||
name = "Get message"
|
||||
|
||||
kind = "action"
|
||||
@@ -8,29 +10,8 @@ kind = "action"
|
||||
|
||||
showstatus = True
|
||||
|
||||
#skipstep = {
|
||||
# "checkavailable": "validTo >= 3600"
|
||||
#}
|
||||
|
||||
#availabletime = int(os.environ.get("AVAILABLE_DURATION",3))
|
||||
|
||||
#duration = availabletime - 1
|
||||
|
||||
#keys = [
|
||||
# {
|
||||
# "keytitle": "option",
|
||||
# "keyvalue": 1,
|
||||
# },
|
||||
# {
|
||||
# "keytitle": "duration",
|
||||
# "keyvalue": duration,
|
||||
# },
|
||||
#]
|
||||
|
||||
method = "GET"
|
||||
|
||||
#messageid = 49971192
|
||||
|
||||
#path = f"https://rentmasseur.com/api/v1/mailbox/{messageid}"
|
||||
#path = [
|
||||
# "https://rentmasseur.com/api/v1/mailbox/",
|
||||
@@ -40,7 +21,7 @@ method = "GET"
|
||||
path = [
|
||||
"https://rentmasseur.com/api/v1/mailbox/",
|
||||
{
|
||||
"output": "messageid",
|
||||
"output": "emails",
|
||||
"keys": [0, "id"]
|
||||
}
|
||||
]
|
||||
@@ -54,10 +35,36 @@ headers = {
|
||||
},
|
||||
}
|
||||
|
||||
outputs = {
|
||||
"conversation": "messages"
|
||||
recursive = {
|
||||
"source": "emails",
|
||||
"target": "id"
|
||||
}
|
||||
|
||||
|
||||
outputs = {
|
||||
"message": "messages"
|
||||
}
|
||||
|
||||
#select = {
|
||||
# "source": "message",
|
||||
# "selectmethod": "include",
|
||||
#"key": "id",
|
||||
# "key": "seen",
|
||||
#"value": {"emails": [0, "id"]},
|
||||
# "value": "false",
|
||||
#}
|
||||
|
||||
select = {
|
||||
"source": "message",
|
||||
"include": {
|
||||
"key": "seen",
|
||||
"value": False,
|
||||
},
|
||||
"exclude": {
|
||||
"key": "senderId",
|
||||
"value": 238302,
|
||||
}
|
||||
}
|
||||
#prints = {
|
||||
# "message": "messages"
|
||||
#}
|
||||
|
||||
@@ -29,6 +29,16 @@ method = "GET"
|
||||
|
||||
#path = "https://rentmasseur.com/api/v1/mailbox?page=1&folder=1&sort=1"
|
||||
path = "https://rentmasseur.com/api/v1/mailbox"
|
||||
|
||||
|
||||
#path = [
|
||||
# "https://rentmasseur.com/api/v1/mailbox/",
|
||||
# {
|
||||
# "output": "emails",
|
||||
# "keys": [0, "id"]
|
||||
# }
|
||||
#]
|
||||
|
||||
headers = {
|
||||
"Authorization": {
|
||||
"output": "access_token",
|
||||
@@ -36,11 +46,23 @@ headers = {
|
||||
},
|
||||
}
|
||||
|
||||
#select = {
|
||||
# "source": "emails",
|
||||
# "selectmethod": "exclude",
|
||||
# "key": "unread",
|
||||
# "value": 0,
|
||||
#}
|
||||
|
||||
select = {
|
||||
"source": "emails",
|
||||
"selectmethod": "exclude",
|
||||
"key": "unread",
|
||||
"value": 0,
|
||||
"include": {
|
||||
"key": {},
|
||||
"value": {},
|
||||
},
|
||||
"exclude": {
|
||||
"key": "unread",
|
||||
"value": 0,
|
||||
}
|
||||
}
|
||||
|
||||
outputs = {
|
||||
|
||||
Binary file not shown.
@@ -7,7 +7,7 @@ kind = "operation"
|
||||
actions = [
|
||||
refresh_tokens,
|
||||
pullmessagelist,
|
||||
#getmessage,
|
||||
getmessage,
|
||||
#setavailable,
|
||||
]
|
||||
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTE4MTU5NzksIm5iZiI6MTc5MTgxNTc5OSwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MTgxNTg1OX0.oxYvEJrX9lQRiHtaOndLLv8bZGo1AVboC6xjKljnrHmXSJe52-urHrQsTyc1XlJV08a5z_1ctYR8yGmYejwjeQ", "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3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