You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kibble.apache.org by hu...@apache.org on 2017/12/06 23:03:06 UTC

[kibble] branch master updated (2905e1f -> c8eb541)

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/kibble.git.


    from 2905e1f  regenerate openapi.yaml
     new fce6b92  let sources API use the yaml for determining creds needed
     new c8eb541  add azure moods to the mix

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:
 api/pages/mail/mood-timeseries.py | 17 ++++++++++++++++-
 api/pages/mail/mood.py            | 21 ++++++++++++++++++---
 api/pages/sources.py              | 14 ++++++++------
 3 files changed, 42 insertions(+), 10 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
['"commits@kibble.apache.org" <co...@kibble.apache.org>'].

[kibble] 01/02: let sources API use the yaml for determining creds needed

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/kibble.git

commit fce6b92498230a5d046d66cfa9efe5c1aaa2c1f2
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Sun Dec 3 14:10:13 2017 +0100

    let sources API use the yaml for determining creds needed
    
    instead of hardcoding username, password etc, use the
    sourcetypes.yaml file for determining what may be needed.
    This also allows us to reject unknown source types.
---
 api/pages/sources.py | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/api/pages/sources.py b/api/pages/sources.py
index 0d08ea7..9e4856c 100644
--- a/api/pages/sources.py
+++ b/api/pages/sources.py
@@ -130,6 +130,7 @@ import json
 import re
 import time
 import hashlib
+import yaml
 
 def canModifySource(session):
     """ Determine if the user can edit sources in this org """
@@ -216,16 +217,17 @@ def run(API, environ, indata, session):
         if canModifySource(session):
             new = 0
             old = 0
+            stypes = yaml.load(open("yaml/sourcetypes.yaml"))
             for source in indata.get('sources', []):
                 sourceURL = source['sourceURL']
                 sourceType = source['type']
                 creds = {}
-                if 'username' in source and len(source['username']) > 0:
-                    creds['username'] = source['username']
-                if 'password' in source and len(source['password']) > 0:
-                    creds['password'] = source['password']
-                if 'cookie' in source and len(source['cookie']) > 0:
-                    creds['cookie'] = source['cookie']
+                if not sourceType in stypes:
+                    raise API.exception(400, "Attempt to add unknown source type!")
+                if 'optauth' in stypes[sourceType]:
+                    for el in stypes[sourceType]['optauth']:
+                        if el in source and len(source[el]) > 0:
+                            creds[el] = source[el]
                 sourceID = hashlib.sha224( ("%s-%s" % (sourceType, sourceURL)).encode('utf-8') ).hexdigest()
                 
                 dOrg = session.user['defaultOrganisation'] or "apache"

-- 
To stop receiving notification emails like this one, please contact
"commits@kibble.apache.org" <co...@kibble.apache.org>.

[kibble] 02/02: add azure moods to the mix

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/kibble.git

commit c8eb541b02446abd029e625d3159a3dace6d95b2
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Thu Dec 7 00:02:56 2017 +0100

    add azure moods to the mix
    
    will likely need to adjust this later
---
 api/pages/mail/mood-timeseries.py | 17 ++++++++++++++++-
 api/pages/mail/mood.py            | 21 ++++++++++++++++++---
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/api/pages/mail/mood-timeseries.py b/api/pages/mail/mood-timeseries.py
index 257a1d9..79c245b 100644
--- a/api/pages/mail/mood-timeseries.py
+++ b/api/pages/mail/mood-timeseries.py
@@ -168,6 +168,21 @@ def run(API, environ, indata, session):
                     'sum': {
                         'field': 'mood.analytical'
                     }                
+                },
+                'positive': {
+                    'sum': {
+                        'field': 'mood.positive'
+                    }                
+                },
+                'neutral': {
+                    'sum': {
+                        'field': 'mood.neutral'
+                    }                
+                },
+                'negative': {
+                    'sum': {
+                        'field': 'mood.negative'
+                    }                
                 }
             }
          }
@@ -180,7 +195,7 @@ def run(API, environ, indata, session):
         )
     
     timeseries = []
-    M = ['joy', 'sadness', 'tentative', 'confident', 'anger', 'fear', 'analytical', 'disgust']
+    M = ['joy', 'sadness', 'tentative', 'confident', 'anger', 'fear', 'analytical', 'disgust', 'positive', 'neutral', 'negative']
     
     for tz in res['aggregations']['history']['buckets']:
         moods = {}
diff --git a/api/pages/mail/mood.py b/api/pages/mail/mood.py
index 57191eb..5f5332a 100644
--- a/api/pages/mail/mood.py
+++ b/api/pages/mail/mood.py
@@ -158,6 +158,21 @@ def run(API, environ, indata, session):
                     'sum': {
                         'field': 'mood.analytical'
                     }                
+                },
+                'positive': {
+                    'sum': {
+                        'field': 'mood.positive'
+                    }                
+                },
+                'neutral': {
+                    'sum': {
+                        'field': 'mood.neutral'
+                    }                
+                },
+                'negative': {
+                    'sum': {
+                        'field': 'mood.negative'
+                    }                
                 }
     }
     
@@ -222,7 +237,7 @@ def run(API, environ, indata, session):
     
     # If relative mode and a field is missing, assume 100 (norm)
     if indata.get('relative'):
-        for M in ['joy', 'sadness', 'tentative', 'confident', 'anger', 'fear', 'analytical', 'disgust']:
+        for M in ['joy', 'sadness', 'tentative', 'confident', 'anger', 'fear', 'analytical', 'disgust', 'negative', 'neutral', 'positive']:
             if mood_compiled.get(M, 0) == 0:
                 mood_compiled[M] = 100
     
@@ -230,14 +245,14 @@ def run(API, environ, indata, session):
     MAX = max(max(mood_compiled.values()),1)
     X = 100 if indata.get('relative') else 0
     bads = X
-    for B in ['sadness', 'anger', 'fear', 'disgust']:
+    for B in ['sadness', 'anger', 'fear', 'disgust', 'negative']:
         if mood_compiled.get(B) and mood_compiled[B] > X:
             bads += mood_compiled[B]
     
     happ = 50
     
     goods = X
-    for B in ['joy', 'confident']:
+    for B in ['joy', 'confident', 'positive']:
         if mood_compiled.get(B) and mood_compiled[B] > X:
             goods += mood_compiled[B]
     MAX = max(MAX, bads, goods)

-- 
To stop receiving notification emails like this one, please contact
"commits@kibble.apache.org" <co...@kibble.apache.org>.