Skip to content

Commit

Permalink
Merge branch 'dev' into lintfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthlogic authored May 23, 2024
2 parents 1efba13 + a0cc4ca commit acaf018
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
13 changes: 3 additions & 10 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const router = Express.Router();
const toList = (apps) => ({ results: apps });

router.use((req, res, next) => {

if (!req.query.country) {
req.query.country = process.env.COUNTRY_OF_QUERY || 'US';
}
Expand Down Expand Up @@ -137,7 +136,8 @@ router.get('/apps/:appId/permissions', function (req, res, next) {

/* App reviews */
router.get('/apps/:appId/reviews', function (req, res, next) {
const opts = Object.assign({ appId: req.params.appId, country: req.query.country }, req.query);
const opts = Object.assign({ appId: req.params.appId, country: req.query.country, num: parseInt(req.query.num) || 100 }, req.query);

const includeUserData = req.query.userdata === 'true';
const includeReplies = req.query.replies === 'true';

Expand Down Expand Up @@ -177,8 +177,7 @@ router.get('/apps/:appId/reviews', function (req, res, next) {
rest.date = rest.date.split('T')[0];
return rest;
});
}
else {
} else {
reviews.data = reviews.data.map(review => {
const { url, ...rest } = review;
rest.date = rest.date.split('T')[0];
Expand All @@ -189,12 +188,6 @@ router.get('/apps/:appId/reviews', function (req, res, next) {
return reviews;
};

// Check if nextPaginationToken is present and not null
if (req.query.nextPaginationToken !== null) {
opts.paginate = true;
opts.nextPaginationToken = req.query.nextPaginationToken;
}

// Sort criteria - Helpful, Most rated, and Newest reviews
// https://github.com/facundoolano/google-play-scraper/blob/89202849f6054f6ac64790a385abc3c18ae98df1/lib/constants.js#L69C7-L69C7
opts.sort = req.query.sort === 'helpful' ? 1 : req.query.sort === 'rated' ? 3 : 2;
Expand Down
34 changes: 21 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"dependencies": {
"express": "^4.19.2",
"google-play-scraper": "^10.0.0",
"google-play-scraper": "https://github.com/srikanthlogic/google-play-scraper.git#c0bdceca9288165f9af625363c621b901f506390",
"morgan": "^1.10.0",
"postman-to-openapi": "^3.0.1",
"swagger-ui-express": "^5.0.0"
Expand Down

0 comments on commit acaf018

Please sign in to comment.