You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2021/10/16 23:55:00 UTC

[incubator-ponymail-foal] branch master updated (12dda94 -> 4606f44)

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git.


    from 12dda94  use match_phrase for header matches, it's more accurate.
     new d024a76  simplify logic
     new 4606f44  rename for clarity

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 server/plugins/defuzzer.py | 66 +++++++++++++++++++++++-----------------------
 1 file changed, 33 insertions(+), 33 deletions(-)

[incubator-ponymail-foal] 02/02: rename for clarity

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit 4606f44722d6e55230973ae0d38a81b5bd2a6627
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Sun Oct 17 01:54:48 2021 +0200

    rename for clarity
---
 server/plugins/defuzzer.py | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/server/plugins/defuzzer.py b/server/plugins/defuzzer.py
index ce527b5..f5aa811 100644
--- a/server/plugins/defuzzer.py
+++ b/server/plugins/defuzzer.py
@@ -125,8 +125,8 @@ def defuzz(formdata: dict, nodate: bool = False, list_override: typing.Optional[
         qs = formdata["q"].replace(":", "")
         bits = shlex.split(qs)
 
-        should = []
-        shouldnot = []
+        query_should_match = []
+        query_should_not_match = []
 
         for bit in bits:
             force_positive = False
@@ -136,15 +136,15 @@ def defuzz(formdata: dict, nodate: bool = False, list_override: typing.Optional[
                 bit = bit[1:]
             # Negatives
             if bit[0] == "-" and not force_positive:
-                shouldnot.append(bit[1:])
+                query_should_not_match.append(bit[1:])
             # Positives
             else:
-                should.append(bit)
+                query_should_match.append(bit)
 
-        if should:
-            xshould = []
-            for x in should:
-                xshould.append(
+        if query_should_match:
+            query_should_match_expanded = []
+            for x in query_should_match:
+                query_should_match_expanded.append(
                     {
                         "bool": {
                             "should": [
@@ -159,10 +159,10 @@ def defuzz(formdata: dict, nodate: bool = False, list_override: typing.Optional[
                         }
                     }
                 )
-            xmust = {"bool": {"minimum_should_match": len(should), "should": xshould}}
+            xmust = {"bool": {"minimum_should_match": len(query_should_match), "should": query_should_match_expanded}}
             must.append(xmust)
 
-        for x in shouldnot:
+        for x in query_should_not_match:
             must_not.append(
                 {
                     "match": {
@@ -192,9 +192,9 @@ def defuzz(formdata: dict, nodate: bool = False, list_override: typing.Optional[
             hvalue = formdata[hname]
             must.append({"match_phrase": {header: hvalue}})
 
-    thebool = {"must": must}
+    query_as_bool = {"must": must}
 
     if must_not:
-        thebool["must_not"] = must_not
+        query_as_bool["must_not"] = must_not
 
-    return thebool
+    return query_as_bool

[incubator-ponymail-foal] 01/02: simplify logic

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit d024a764479b8f7a591dbce096727d7c8ccc7971
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Sun Oct 17 01:51:55 2021 +0200

    simplify logic
---
 server/plugins/defuzzer.py | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/server/plugins/defuzzer.py b/server/plugins/defuzzer.py
index 09f3981..ce527b5 100644
--- a/server/plugins/defuzzer.py
+++ b/server/plugins/defuzzer.py
@@ -161,29 +161,29 @@ def defuzz(formdata: dict, nodate: bool = False, list_override: typing.Optional[
                 )
             xmust = {"bool": {"minimum_should_match": len(should), "should": xshould}}
             must.append(xmust)
-        if shouldnot:
-            for x in shouldnot:
-                must_not.append(
-                    {
-                        "match": {
-                            "subject": x,
-                        }
+
+        for x in shouldnot:
+            must_not.append(
+                {
+                    "match": {
+                        "subject": x,
                     }
-                )
-                must_not.append(
-                    {
-                        "match": {
-                            "from": x,
-                        }
+                }
+            )
+            must_not.append(
+                {
+                    "match": {
+                        "from": x,
                     }
-                )
-                must_not.append(
-                    {
-                        "match": {
-                            "body": x,
-                        }
+                }
+            )
+            must_not.append(
+                {
+                    "match": {
+                        "body": x,
                     }
-                )
+                }
+            )
 
     # Header parameters
     for header in ["from", "subject", "body", "to"]:
@@ -194,7 +194,7 @@ def defuzz(formdata: dict, nodate: bool = False, list_override: typing.Optional[
 
     thebool = {"must": must}
 
-    if len(must_not) > 0:
+    if must_not:
         thebool["must_not"] = must_not
 
     return thebool