Skip to content

Commit

Permalink
Merge pull request #40 from World-White-Web/feature/cast-everything-t…
Browse files Browse the repository at this point in the history
…o-number

cast string to number where necessary
  • Loading branch information
davideluque authored Nov 25, 2019
2 parents 49e1ca7 + 311fd0d commit 880a9ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/calculator/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ calculatorRoutes.get('/twitter/social/:userId', validate('socialCredibility'), a
if (!errors.isEmpty()){
errorMapper(errors.array())
}
const socialCredibilityVal = await socialCredibility(req.params.userId, req.query.maxFollowers)
const socialCredibilityVal = await socialCredibility(req.params.userId, +req.query.maxFollowers)
res.send(socialCredibilityVal)
}))

Expand All @@ -59,15 +59,15 @@ calculatorRoutes.get('/twitter/tweets', validate('tweetCredibility'), asyncWrap(
weightSocial: +req.query.weightSocial,
weightText: +req.query.weightText,
weightUser: +req.query.weightUser },
req.query.maxFollowers))
+req.query.maxFollowers))
}))

calculatorRoutes.get('/social/scrape', validate('scrapedSocialCredibility'), function(req, res){
const errors = validationResult(req)
if (!errors.isEmpty()){
errorMapper(errors.array())
}
res.send(scrapedSocialCredibility(req.query.followersCount, req.query.friendsCount, req.query.maxFollowers))
res.send(scrapedSocialCredibility(+req.query.followersCount, +req.query.friendsCount, +req.query.maxFollowers))
})

calculatorRoutes.get('/tweets/scraped', validate('scrapedTweetCredibility'), asyncWrap(async function(req, res){
Expand All @@ -92,7 +92,7 @@ calculatorRoutes.get('/tweets/scraped', validate('scrapedTweetCredibility'), asy
yearJoined: +req.query.yearJoined,
followersCount: +req.query.followersCount,
friendsCount: +req.query.friendsCount
}, req.query.maxFollowers))
}, +req.query.maxFollowers))
}))

export default calculatorRoutes
4 changes: 2 additions & 2 deletions tests/calculus-endpoints/social-scrapped.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ describe('/calculate/social/scrape endpoint', () => {
friendsCount: 421,
maxFollowers: 2000000
}
it('returns credibility=30.04999998245834 with', () => {
return testCredibilityWithOkData({ credibility: 30.04999998245834 }, params)
it('returns credibility=79.98246448537638 with', () => {
return testCredibilityWithOkData({ credibility: 79.98246448537638 }, params)
})
})

Expand Down

0 comments on commit 880a9ad

Please sign in to comment.