diff --git a/package-lock.json b/package-lock.json index 04d4e51..5fca370 100644 --- a/package-lock.json +++ b/package-lock.json @@ -474,6 +474,14 @@ "@types/node": "*" } }, + "@types/concat-stream": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@types/concat-stream/-/concat-stream-1.6.0.tgz", + "integrity": "sha1-OU2+C7X+5Gs42JZzXoto7yOQ0A0=", + "requires": { + "@types/node": "*" + } + }, "@types/connect": { "version": "3.4.32", "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.32.tgz", @@ -539,6 +547,14 @@ "express-validator": "*" } }, + "@types/form-data": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-0.0.33.tgz", + "integrity": "sha1-yayFsqX9GENbjIXZ7LUObWyJP/g=", + "requires": { + "@types/node": "*" + } + }, "@types/geojson": { "version": "7946.0.7", "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.7.tgz", @@ -600,8 +616,12 @@ "@types/node": { "version": "12.7.5", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.5.tgz", - "integrity": "sha512-9fq4jZVhPNW8r+UYKnxF1e2HkDWOWKM5bC2/7c9wPV835I0aOrVbS/Hw/pWPk2uKrNXQqg9Z959Kz+IYDd5p3w==", - "dev": true + "integrity": "sha512-9fq4jZVhPNW8r+UYKnxF1e2HkDWOWKM5bC2/7c9wPV835I0aOrVbS/Hw/pWPk2uKrNXQqg9Z959Kz+IYDd5p3w==" + }, + "@types/qs": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.1.tgz", + "integrity": "sha512-lhbQXx9HKZAPgBkISrBcmAcMpZsmpe/Cd/hY7LGZS5OfkySUBItnPZHgQPssWYUET8elF+yCFBbP1Q0RZPTdaw==" }, "@types/range-parser": { "version": "1.2.3", @@ -893,6 +913,11 @@ "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", "dev": true }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" + }, "asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", @@ -955,9 +980,9 @@ "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" }, "aws4": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", - "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.1.tgz", + "integrity": "sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug==" }, "babel-jest": { "version": "24.9.0", @@ -1200,8 +1225,7 @@ "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", - "dev": true + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" }, "bytes": { "version": "3.1.0", @@ -1475,6 +1499,17 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, "configstore": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.2.tgz", @@ -3109,6 +3144,11 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, + "get-port": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/get-port/-/get-port-3.2.0.tgz", + "integrity": "sha1-3Xzn3hh8Bsi/NTeWrHHgmfCYDrw=" + }, "get-stream": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", @@ -3317,6 +3357,17 @@ "whatwg-encoding": "^1.0.1" } }, + "http-basic": { + "version": "8.1.3", + "resolved": "https://registry.npmjs.org/http-basic/-/http-basic-8.1.3.tgz", + "integrity": "sha512-/EcDMwJZh3mABI2NhGfHOGOeOZITqfkEO4p/xK+l3NpyncIHUQBoMvCSF/b5GqvKtySC2srL/GGG3+EtlqlmCw==", + "requires": { + "caseless": "^0.12.0", + "concat-stream": "^1.6.2", + "http-response-object": "^3.0.1", + "parse-cache-control": "^1.0.1" + } + }, "http-errors": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", @@ -3329,6 +3380,21 @@ "toidentifier": "1.0.0" } }, + "http-response-object": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/http-response-object/-/http-response-object-3.0.2.tgz", + "integrity": "sha512-bqX0XTF6fnXSQcEJ2Iuyr75yVakyjIDCqroJQ/aHfSdlM743Cwqoi2nDYMzLGWUcuTWGWy8AAvOKXTfiv6q9RA==", + "requires": { + "@types/node": "^10.0.3" + }, + "dependencies": { + "@types/node": { + "version": "10.17.17", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.17.tgz", + "integrity": "sha512-gpNnRnZP3VWzzj5k3qrpRC6Rk3H/uclhAVo1aIvwzK5p5cOrs9yEyQ8H/HBsBY0u5rrWxXEiVPQ0dEB6pkjE8Q==" + } + } + }, "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", @@ -5197,6 +5263,11 @@ "callsites": "^3.0.0" } }, + "parse-cache-control": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parse-cache-control/-/parse-cache-control-1.0.1.tgz", + "integrity": "sha1-juqz5U+laSD+Fro493+iGqzC104=" + }, "parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", @@ -5358,6 +5429,14 @@ "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", "dev": true }, + "promise": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/promise/-/promise-8.1.0.tgz", + "integrity": "sha512-W04AqnILOL/sPRXziNicCjSNRruLAuIHEOVBazepu0545DDNGYHz7ar9ZgZ1fMU8/MA4mVxp5rkBWRi6OXIy3Q==", + "requires": { + "asap": "~2.0.6" + } + }, "prompts": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.2.1.tgz", @@ -5557,9 +5636,9 @@ "dev": true }, "request": { - "version": "2.88.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", - "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", "requires": { "aws-sign2": "~0.7.0", "aws4": "^1.8.0", @@ -5568,7 +5647,7 @@ "extend": "~3.0.2", "forever-agent": "~0.6.1", "form-data": "~2.3.2", - "har-validator": "~5.1.0", + "har-validator": "~5.1.3", "http-signature": "~1.2.0", "is-typedarray": "~1.0.0", "isstream": "~0.1.2", @@ -5578,29 +5657,15 @@ "performance-now": "^2.1.0", "qs": "~6.5.2", "safe-buffer": "^5.1.2", - "tough-cookie": "~2.4.3", + "tough-cookie": "~2.5.0", "tunnel-agent": "^0.6.0", "uuid": "^3.3.2" }, "dependencies": { - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" - }, "qs": { "version": "6.5.2", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" - }, - "tough-cookie": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", - "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", - "requires": { - "psl": "^1.1.24", - "punycode": "^1.4.1" - } } } }, @@ -6346,6 +6411,24 @@ "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", "dev": true }, + "sync-request": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/sync-request/-/sync-request-6.1.0.tgz", + "integrity": "sha512-8fjNkrNlNCrVc/av+Jn+xxqfCjYaBoHqCsDz6mt030UMxJGr+GSfCV1dQt2gRtlL63+VPidwDVLr7V2OcTSdRw==", + "requires": { + "http-response-object": "^3.0.1", + "sync-rpc": "^1.2.1", + "then-request": "^6.0.0" + } + }, + "sync-rpc": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/sync-rpc/-/sync-rpc-1.3.6.tgz", + "integrity": "sha512-J8jTXuZzRlvU7HemDgHi3pGnh/rkoqR/OZSjhTyyZrEkkYQbk7Z33AXp37mkPfPpfdOuj7Ex3H/TJM1z48uPQw==", + "requires": { + "get-port": "^3.1.0" + } + }, "table": { "version": "5.4.6", "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", @@ -6418,6 +6501,31 @@ "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, + "then-request": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/then-request/-/then-request-6.0.2.tgz", + "integrity": "sha512-3ZBiG7JvP3wbDzA9iNY5zJQcHL4jn/0BWtXIkagfz7QgOL/LqjCEOBQuJNZfu0XYnv5JhKh+cDxCPM4ILrqruA==", + "requires": { + "@types/concat-stream": "^1.6.0", + "@types/form-data": "0.0.33", + "@types/node": "^8.0.0", + "@types/qs": "^6.2.31", + "caseless": "~0.12.0", + "concat-stream": "^1.6.0", + "form-data": "^2.2.0", + "http-basic": "^8.1.1", + "http-response-object": "^3.0.1", + "promise": "^8.0.0", + "qs": "^6.4.0" + }, + "dependencies": { + "@types/node": { + "version": "8.10.59", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.59.tgz", + "integrity": "sha512-8RkBivJrDCyPpBXhVZcjh7cQxVBSmRk9QM7hOketZzp6Tg79c0N8kkpAIito9bnJ3HCVCHVYz+KHTEbfQNfeVQ==" + } + } + }, "throat": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/throat/-/throat-4.1.0.tgz", @@ -6517,7 +6625,6 @@ "version": "2.5.0", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", - "dev": true, "requires": { "psl": "^1.1.28", "punycode": "^2.1.1" @@ -6641,6 +6748,11 @@ "mime-types": "~2.1.24" } }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" + }, "typescript": { "version": "3.6.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.3.tgz", @@ -6822,9 +6934,9 @@ "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" }, "uuid": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", - "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==" + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" }, "v8-compile-cache": { "version": "2.1.0", diff --git a/package.json b/package.json index 3827a8b..19b4958 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,8 @@ "express-validator": "^6.2.0", "express-winston": "^4.0.0", "nspell": "^2.1.2", + "request": "^2.88.2", + "sync-request": "^6.1.0", "twit": "^2.2.11", "washyourmouthoutwithsoap": "^1.0.2", "winston": "^3.2.1" diff --git a/src/calculator/routes.ts b/src/calculator/routes.ts index bb4d931..7b96bc5 100644 --- a/src/calculator/routes.ts +++ b/src/calculator/routes.ts @@ -87,7 +87,7 @@ calculatorRoutes.get('/tweets/scraped', validate('scrapedTweetCredibility'), asy weightSocial: +req.query.weightSocial, }, { - name: '', + name: req.query.name, verified: req.query.verified === 'true', yearJoined: +req.query.yearJoined, followersCount: +req.query.followersCount, diff --git a/src/calculator/service.ts b/src/calculator/service.ts index d3b34a1..6211881 100644 --- a/src/calculator/service.ts +++ b/src/calculator/service.ts @@ -15,6 +15,38 @@ const enDictionaryBase = require.resolve('dictionary-en-us') const frDictionaryBase = require.resolve('dictionary-fr') const esDictionaryBase = require.resolve('dictionary-es') +var userTW={ + 'id_twitter':'', + 'joined_date':'', + 'user_name':'', + 'following':0, + 'followers':0, + 'link':'', + 'location':'', + 'verified':'', + 'extraction_method':'1', + 'followers_impact':0, + 'user_credibility':0 +} + + +var tweetTW={ + 'id_tweet_api':'', + 'text':'', + 'bad_words_filter':'', + 'spam_filter':'', + 'misspelling_filter':'', + 'extraction_method':'1', + 'tweet_credibility':'', + 'retweets':'', + 'favorites':'', + 'replies':'', + 'tweet_url':'', + 'type':'', + 'userAPIid':'' +} + +var Request = require('request') const dictionaries = { en: { @@ -48,6 +80,22 @@ function responseToTwitterUser(response: any) : TwitterUser { } function responseToTweet(response: any) : Tweet { + + userTW = { + 'id_twitter':response.user.id_str, + 'joined_date':response.user.created_at.split(' ').pop(), + 'user_name':response.user.screen_name, + 'following':response.user.friends_count, + 'followers':response.user.followers_count, + 'link':response.user.url, + 'location':response.user.location, + 'verified': (response.user.verified) ? '1': '0', + 'extraction_method':'1', + 'followers_impact':0, + 'user_credibility': 0 + } + + return { text: { text: response.full_text, @@ -207,8 +255,83 @@ async function calculateTweetCredibility(tweetId: string, const userCredibility: number = calculateUserCredibility(user) * params.weightUser const textCredibility: number = (await calculateTextCredibility(tweet.text, params)).credibility * params.weightText const socialCredibility: number = calculateSocialCredibility(user, maxFollowers) * params.weightSocial + console.log(socialCredibility) + await Request.post({ + 'headers': { 'content-type': 'application/json' }, + 'url': 'http://107.170.90.209//web-services/services/createTwitterUser.php', + 'body': JSON.stringify(userTW) + },function optionalCallback(err:string, httpResponse:string, body:boolean) { + if (err) {console.error('upload failed:', err)} + if(body){ getUserTweets(userTW.user_name, userTW.id_twitter)} + }) + + const socialCredibilityNew:number= ((await calculateNewSocialCredibility('http://107.170.90.209//web-services/services/calculateSocialCredibility.php?id_twitter='+userTW.id_twitter)))* params.weightSocial + return { - credibility: userCredibility + textCredibility + socialCredibility + credibility: userCredibility + textCredibility + socialCredibilityNew + } + } catch (e) { + console.log(e) + throw e + } +} + + +function calculateNewSocialCredibility(url: any):Promise { + return new Promise((resolve, reject) => { + Request(url, (error: any, response: { statusCode: string | number }, body: number) => { + if (error) reject(error) + if (response.statusCode != 200) { + reject('Invalid status code ' + response.statusCode + '>') + } + resolve(body) + }) + }) +} + +async function getUserTweets(screenName: string, userId:string){ + const client = buildTwitClient() + try { + const response = await client.get('statuses/user_timeline', {include_rts:false, screen_name: screenName, count:2000}) + var tweetsAPI= (Object.values(response.data)) + for(let element of tweetsAPI){ + if (element=== 'undefined') { + break + } else{ + // (tweetsAPI.forEach(element => { + var media='' + var type='' + // if (typeof element.entities.media === 'undefined') { + // media='' + // type='' + //}else{ + // media=element.entities.media[0].media_url + // type=element.entities.media[0].type + //} + + tweetTW={ + 'id_tweet_api':element.id_str, + 'text':element.text, + 'bad_words_filter':'0', + 'spam_filter':'0', + 'misspelling_filter':'0', + 'extraction_method':'1', + 'tweet_credibility':'0', + 'retweets':element.retweet_count, + 'favorites':element.favorite_count, + 'replies':'0', + 'tweet_url':media, + 'type':type, + 'userAPIid': userId //element.user.id_str + } + Request.post({ + 'headers': { 'content-type': 'application/json' }, + 'url': 'http://107.170.90.209//web-services/services/createTweet.php', + 'body': JSON.stringify( + tweetTW + ) + }) + } } } catch (e) { console.log(e) diff --git a/tests/calculus-endpoints/tweet-api.test.ts b/tests/calculus-endpoints/tweet-api.test.ts index 56efc43..552fa70 100644 --- a/tests/calculus-endpoints/tweet-api.test.ts +++ b/tests/calculus-endpoints/tweet-api.test.ts @@ -14,8 +14,8 @@ describe('/twitter/tweets', () => { full_text: 'mocked testing text', lang: 'en', user: { - id: 91891658, - name: 'Test name', + id: 25073877, + name: 'YuniQuintero', followers_count: 0, friends_count: 0, created_at: 'Mon Feb 21 01:59:02 +0000 2011', diff --git a/tests/calculus-endpoints/user-api.test.ts b/tests/calculus-endpoints/user-api.test.ts index 26ab206..f709c10 100644 --- a/tests/calculus-endpoints/user-api.test.ts +++ b/tests/calculus-endpoints/user-api.test.ts @@ -33,7 +33,7 @@ describe('/twitter/user/:id endpoint', () => { } describe('user 91891658', () => { it('returns credibility=30.76923076923077', () => { - return testCredibilityWithOkData({ credibility: 30.769230 }) + return testCredibilityWithOkData({ credibility: 32.142857142857146 }) }) }) }) diff --git a/tests/calculus-endpoints/validation.test.ts b/tests/calculus-endpoints/validation.test.ts index df1a972..fea6a0d 100644 --- a/tests/calculus-endpoints/validation.test.ts +++ b/tests/calculus-endpoints/validation.test.ts @@ -403,7 +403,7 @@ describe('Input Validation', () => { errorMessage: 'customValidation.WEIGHT_TEXT_CRED_NOT_EQUALS_TO_1', userErrorMessage: 'customValidation.WEIGHT_TEXT_CRED_NOT_EQUALS_TO_1', validationCode: 'customValidation.WEIGHT_TEXT_CRED_NOT_EQUALS_TO_1' } ] - }, { tweetId: 867412932409282560, maxFollowers: 2000, weightSpam: 0, weightBadWords: -1, weightMisspelling: 0, weightText: 0, weightUser: 0.5, weightSocial: 0.5}) + }, { tweetId: 1244647948870455298, maxFollowers: 2000, weightSpam: 0, weightBadWords: -1, weightMisspelling: 0, weightText: 0, weightUser: 0.5, weightSocial: 0.5}) }) it('weightMisspelling.NOT_IN_RANGE', () => { return testTweetCredibility({ @@ -420,7 +420,7 @@ describe('Input Validation', () => { errorMessage: 'customValidation.WEIGHT_TEXT_CRED_NOT_EQUALS_TO_1', userErrorMessage: 'customValidation.WEIGHT_TEXT_CRED_NOT_EQUALS_TO_1', validationCode: 'customValidation.WEIGHT_TEXT_CRED_NOT_EQUALS_TO_1' } ] - }, { tweetId: 867412932409282560, maxFollowers: 2000, weightSpam: 0, weightBadWords: 1, weightMisspelling: 1000, weightText: 0.2, weightUser: 0.3, weightSocial: 0.5}) + }, { tweetId: 1244647948870455298, maxFollowers: 2000, weightSpam: 0, weightBadWords: 1, weightMisspelling: 1000, weightText: 0.2, weightUser: 0.3, weightSocial: 0.5}) }) it('weightSpam.NOT_IN_RANGE', () => { return testTweetCredibility({ @@ -437,7 +437,7 @@ describe('Input Validation', () => { errorMessage: 'customValidation.WEIGHT_TEXT_CRED_NOT_EQUALS_TO_1', userErrorMessage: 'customValidation.WEIGHT_TEXT_CRED_NOT_EQUALS_TO_1', validationCode: 'customValidation.WEIGHT_TEXT_CRED_NOT_EQUALS_TO_1' } ] - }, { tweetId: 867412932409282560, maxFollowers: 2000, weightSpam: -10, weightBadWords: 1, weightMisspelling: 0, weightText: 0.9, weightUser: 0.1, weightSocial: 0}) + }, { tweetId: 1244647948870455298, maxFollowers: 2000, weightSpam: -10, weightBadWords: 1, weightMisspelling: 0, weightText: 0.9, weightUser: 0.1, weightSocial: 0}) }) it('maxFollowers.POSITIVE', () => { return testTweetCredibility({ @@ -450,7 +450,7 @@ describe('Input Validation', () => { errorMessage: 'maxFollowers.POSITIVE', userErrorMessage: 'maxFollowers.POSITIVE', validationCode: 'maxFollowers.POSITIVE' } ] - }, { tweetId: 867412932409282560, maxFollowers: -1, weightSpam: 0, weightBadWords: 1, weightMisspelling: 0, weightText: 0, weightUser: 1, weightSocial: 0}) + }, { tweetId: 1244647948870455298, maxFollowers: -1, weightSpam: 0, weightBadWords: 1, weightMisspelling: 0, weightText: 0, weightUser: 1, weightSocial: 0}) }) it('weightUser.NOT_IN_RANGE', () => { return testTweetCredibility({ @@ -467,7 +467,7 @@ describe('Input Validation', () => { errorMessage: 'customValidation.WEIGHT_TWEET_CRED_NOT_EQUALS_TO_1', userErrorMessage: 'customValidation.WEIGHT_TWEET_CRED_NOT_EQUALS_TO_1', validationCode: 'customValidation.WEIGHT_TWEET_CRED_NOT_EQUALS_TO_1' } ] - }, { tweetId: 867412932409282560, maxFollowers: 2000, weightSpam: 0, weightBadWords: 1, weightMisspelling: 0, weightText: 0, weightUser: -10, weightSocial: 0}) + }, { tweetId: 1244647948870455298, maxFollowers: 2000, weightSpam: 0, weightBadWords: 1, weightMisspelling: 0, weightText: 0, weightUser: -10, weightSocial: 0}) }) it('customValidation.WEIGHT_TEXT_CRED_NOT_EQUALS_TO_1', () => { return testTweetCredibility({ @@ -480,7 +480,7 @@ describe('Input Validation', () => { errorMessage: 'customValidation.WEIGHT_TEXT_CRED_NOT_EQUALS_TO_1', userErrorMessage: 'customValidation.WEIGHT_TEXT_CRED_NOT_EQUALS_TO_1', validationCode: 'customValidation.WEIGHT_TEXT_CRED_NOT_EQUALS_TO_1' } ] - }, { tweetId: 867412932409282560, maxFollowers: 2000, weightSpam: 0.3, weightBadWords: 0.3, weightMisspelling: 0.3, weightText: 0, weightUser: 1, weightSocial: 0}) + }, { tweetId: 1244647948870455298, maxFollowers: 2000, weightSpam: 0.3, weightBadWords: 0.3, weightMisspelling: 0.3, weightText: 0, weightUser: 1, weightSocial: 0}) }) it('customValidation.WEIGHT_TWEET_CRED_SUM_NOT_1', () => { return testTweetCredibility({ @@ -493,7 +493,7 @@ describe('Input Validation', () => { errorMessage: 'customValidation.WEIGHT_TWEET_CRED_NOT_EQUALS_TO_1', userErrorMessage: 'customValidation.WEIGHT_TWEET_CRED_NOT_EQUALS_TO_1', validationCode: 'customValidation.WEIGHT_TWEET_CRED_NOT_EQUALS_TO_1' } ] - }, { tweetId: 867412932409282560, maxFollowers: 2000, weightSpam: 0.3, weightBadWords: 0.3, weightMisspelling: 0.4, weightText: 1, weightUser: 1, weightSocial: 0}) + }, { tweetId: 1244647948870455298, maxFollowers: 2000, weightSpam: 0.3, weightBadWords: 0.3, weightMisspelling: 0.4, weightText: 1, weightUser: 1, weightSocial: 0}) }) }) describe('/GET /calculate/tweets/scraped', () => {