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/10/25 10:51:06 UTC

[kibble] 01/08: add a gauge for overall mood, change to new indicator

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 b04ec2cdb8a058b84a8dbd8a371517cb6d556947
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Wed Oct 25 12:49:30 2017 +0200

    add a gauge for overall mood, change to new indicator
    
    - add weighted guess of overall moode
    - change indicator to 'relativeMode' to distinguish from..distinguish!
---
 api/pages/mail/mood.py | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/api/pages/mail/mood.py b/api/pages/mail/mood.py
index 852e7b6..07a21cb 100644
--- a/api/pages/mail/mood.py
+++ b/api/pages/mail/mood.py
@@ -165,10 +165,12 @@ def run(API, environ, indata, session):
     global_mood_compiled = {}
     mood_compiled = {}
     txt = "This chart shows the seven mood types as they average on the emails in this period. A score of 100 means a sentiment is highly visible in most emails."
+    gtxt = "This shows the overall estimated mood as a gauage from terrible to good."
     # If we're comparing against all lists, first do a global query
     # and compile moods overall
-    if indata.get('distinguish'):
+    if indata.get('relative'):
         txt = "This chart shows the seven mood types on the selected lists as they compare against all mailing lists in the database. A score of 100 here means the sentiment conforms to averages across all lists."
+        gtxt = "This shows the overall estimated mood copmpared to all lists, as a gauage from terrible to good."
         global_moods = {}
         
         gres = session.DB.ES.search(
@@ -217,11 +219,20 @@ def run(API, environ, indata, session):
             mood_compiled[k] = int(100 * int( (v / max(1,emls)) * 100) / max(1, global_mood_compiled.get(k, 100)))
     else:
         mood_compiled = global_mood_compiled
-        
+    bads = (mood_compiled.get('anger', 0)*1.25 + mood_compiled.get('fear', 0)*1.25 + mood_compiled.get('sadness', 0) + mood_compiled.get('disgust', 0)*1.5) / 4
+    neutrals = (mood_compiled.get('tentative', 0) + mood_compiled.get('analytical', 0) /2)
+    goods = (mood_compiled.get('joy', 0)*1.5 + mood_compiled.get('confident', 0)) / 2
+    swingometer = max(0, min(100, 50 + goods - bads))
+    
     JSON_OUT = {
-        'distinguishable': True,
+        'relativeMode': True,
         'text': txt,
         'counts': mood_compiled,
-        'okay': True
+        'okay': True,
+        'gauge': {
+            'key': 'Happiness',
+            'value': swingometer,
+            'text': gtxt
+        }
     }
     yield json.dumps(JSON_OUT)

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