Merge branch 'master' into 32-camunda-reporting-input-format
authorDavid Kaufmann <david.kaufmann@student.tuwien.ac.at>
Tue, 11 Dec 2018 14:11:30 +0000 (15:11 +0100)
committerDavid Kaufmann <david.kaufmann@student.tuwien.ac.at>
Tue, 11 Dec 2018 14:11:30 +0000 (15:11 +0100)
CONTRIBUTING.md
service-analysis/README.md
service-analysis/sentiment_analysis.py
service-twitter/src/main/java/at/aic18/g6t4/servicetwitter/configuration/Twitter4jProperties.java
service-twitter/src/main/java/at/aic18/g6t4/servicetwitter/exception/SearchException.java [deleted file]
service-twitter/src/main/java/at/aic18/g6t4/servicetwitter/service/TwitterService.java
service-twitter/src/main/resources/application.yml

index d3a65477d27b182c36b7bdb097c74330c60b1856..ee52a52b40d5ba5d496fb11a543ecc4e744de1f1 100644 (file)
@@ -1,3 +1,16 @@
 # Contribution Guide
 
-TODO
+
+## Guidelines
+
+* Don't push directly to the `master` branch.
+* Create a new branch from `master` for new features. For best pratice, prefix it with the name of your service, e.g. `twitter-fix-something`.
+* Use Merge Requests (MRs) instead of directly pushing to master.
+* Don't accept your own MRs, unless they are actually minor, like changing a `README` file. Otherwise ask someone else to test it.
+
+
+## Don't do this
+
+* Force pushing to remote branches, especially master. It's usually uncessary, just fix your own feature branch.
+* Rebasing or resetting remote branches. Doing it locally is fine. If you want to undo an already pushed commit, push a revert commit.
+* Squashing commits. I'm personally fine with it, but I think someone was against it? Not sure if it was a tutor, or not.
index fb414facdeaefcf0091aa27e6bf9e16b4cbbaf37..a4d4cc4e353fb4f1c5096c55508c5167e4c4d627 100644 (file)
@@ -31,7 +31,7 @@ JSON string may contain more value-key pairs than 'text', but 'text' is needed f
 
 ## run with docker
 - `docker build -t sentiment_analysis .`
-- `docker run -d -p YOUR_PORT:8081 sentiment_analysis`
+- `docker container run -d -p YOUR_PORT:8081 sentiment_analysis`
 
 ## run local
 ### requirements
index 933ce9c3114804a85a6f64487bfafd4cf5b703cc..2a013e943a63174c62de7ddde25b3da8177478ee 100644 (file)
@@ -2,7 +2,7 @@
 import json
 import indicoio
 
-from flask import Flask, request, jsonify
+from flask import Flask, request, jsonify, Response
 from flask_restful import Resource, Api, output_json, abort
 
 app = Flask(__name__)
@@ -10,15 +10,15 @@ api = Api(app)
 
 indicoio.config.api_key = '525f16078717a430f9dac17cdc9dbaa3'
 
-input_error_409 = 'Input must be a JSON string. JSON objects must contain contain key text.'
+input_error_409 = 'Input must be a list of JSON objects. JSON objects must contain contain key text.'
 service_error_503 = 'The sentiment analysis service is currently unavailable.'
 
 class Sentiment_Analysis(Resource):
        def get(self):
-               return "POST a JSON string as content-type: application/json. JSON objects must contain key 'text'."
+               return "POST a list of JSON objects as content-type: application/json. JSON objects must contain key 'text'.", 405, {'Allow': 'GET'}
                
        def post(self):
-               if not request.json:
+               if not request.json or not isinstance(request.json, (list,)):
                        return abort(409, message=input_error_409)
                texts = request.json
                text_array = []
@@ -34,7 +34,7 @@ class Sentiment_Analysis(Resource):
                        return make_error(503, message=service_error_503)
                sentiment = value/len(text_array)
                data = {'sentiment': sentiment}
-               return output_json(json.dumps(data), 200)
+               return data
                                
 api.add_resource(Sentiment_Analysis, '/')
 
index 3196f98c9150c35507f1245f27371ebde6cd8c8e..8e2ae24fb11069a356b57a5ccb5cfb1aaa9200fd 100644 (file)
@@ -1,5 +1,7 @@
 package at.aic18.g6t4.servicetwitter.configuration;
 
+import lombok.Getter;
+import lombok.Setter;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.validation.annotation.Validated;
 
@@ -8,23 +10,15 @@ import javax.validation.constraints.NotEmpty;
 
 @ConfigurationProperties(prefix = "twitter4j")
 @Validated
+@Getter
+@Setter
 public class Twitter4jProperties {
 
     @Valid private final OAuth oauth = new OAuth();
     private boolean debug = false;
 
-    public OAuth getOauth() {
-        return oauth;
-    }
-
-    public boolean isDebug() {
-        return debug;
-    }
-
-    public void setDebug(boolean debug) {
-        this.debug = debug;
-    }
-
+    @Getter
+    @Setter
     public static class OAuth {
 
         @NotEmpty private String consumerKey;
@@ -32,38 +26,6 @@ public class Twitter4jProperties {
         @NotEmpty private String accessToken;
         @NotEmpty private String accessTokenSecret;
 
-        public String getConsumerKey() {
-            return consumerKey;
-        }
-
-        public void setConsumerKey(String consumerKey) {
-            this.consumerKey = consumerKey;
-        }
-
-        public String getConsumerSecret() {
-            return consumerSecret;
-        }
-
-        public void setConsumerSecret(String consumerSecret) {
-            this.consumerSecret = consumerSecret;
-        }
-
-        public String getAccessToken() {
-            return accessToken;
-        }
-
-        public void setAccessToken(String accessToken) {
-            this.accessToken = accessToken;
-        }
-
-        public String getAccessTokenSecret() {
-            return accessTokenSecret;
-        }
-
-        public void setAccessTokenSecret(String accessTokenSecret) {
-            this.accessTokenSecret = accessTokenSecret;
-        }
-
     }
 
 }
diff --git a/service-twitter/src/main/java/at/aic18/g6t4/servicetwitter/exception/SearchException.java b/service-twitter/src/main/java/at/aic18/g6t4/servicetwitter/exception/SearchException.java
deleted file mode 100644 (file)
index b69d7ab..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-package at.aic18.g6t4.servicetwitter.exception;
-
-public class SearchException extends Exception {
-
-    public SearchException() {
-        super();
-    }
-
-    public SearchException(String message) {
-        super(message);
-    }
-
-    public SearchException(String message, Throwable cause) {
-        super(message, cause);
-    }
-
-    public SearchException(Throwable cause) {
-        super(cause);
-    }
-
-}
index d676835fd0b8570f1bb4ca360d0556f323b1ac3e..f10c2dc1ff6eeae1566699be083c924cdea7f472 100644 (file)
@@ -18,7 +18,8 @@ public class TwitterService {
     }
 
     public List<Tweet> searchTweets(String queryString) throws TwitterException {
-        Query query = new Query(queryString);
+        String excludeRetweets = " exclude:retweets";
+        Query query = new Query(queryString + excludeRetweets);
         query.count(10);
         QueryResult queryResult = twitter.search(query);
         List<Status> statusList = queryResult.getTweets();
index 6941e324e4b1a2b1e077af487ac39a5167882ae0..ac49b95b5459a867fcc931041d4fd1564d1e2342 100644 (file)
@@ -1,4 +1,4 @@
-debug: true
+debug: false
 
 spring:
   jackson:
@@ -8,7 +8,7 @@ server:
   port: 8084
 
 twitter4j:
-  debug: true
+  debug: false
   oauth:
     consumer-key: "DnmBShVqvJ2xfnRjkAWtq644Z"
     consumer-secret: "YbP2oAdU9IyuYMAUxbyJn1NNKZ91jnOz1CpNKMSCjCR0Pu8JlJ"