Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ ReviewMe requires a config file. A simple config looks something like:
* **botIcon** An image url to use for the bot avatar
* **showAppIcon** Determines if app icon will be displayed (overrides botIcon)
* **channel** Overrides the default Slack channel messages will be posted to
* **interval** The interval (in seconds) to check for new reviews. Default: `300`.
* **interval** The interval (in seconds) to check for new reviews. Default: 300.
* **cronStyleSchedule** CronJob style schedule to check for new reviews(Can be used instead of interval). Default: `00 * * * *`.
* **apps** A list of apps to fetch reviews for. See App Options below
* **publisherKey** *Android Only* The path to a Google Play Publisher private key (`.json` file). Used for accessing the Google Play Publisher API.

Expand Down
19 changes: 14 additions & 5 deletions appstorereviews.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const controller = require('./reviews');
const fs = require('fs');
var request = require('request');
var schedule = require('node-schedule');
require('./constants');

exports.startReview = function (config, first_run) {
Expand All @@ -16,8 +17,8 @@ exports.startReview = function (config, first_run) {
config.regions = ["us"];
}

if (!config.interval) {
config.interval = DEFAULT_INTERVAL_SECONDS
if (!config.schedule) {
config.schedule = DEFAULT_INTERVAL_SECONDS;
}

// Find the app information to get a icon URL
Expand Down Expand Up @@ -50,15 +51,23 @@ exports.startReview = function (config, first_run) {
}

//calculate the interval with an offset, to avoid spamming the server
var interval_seconds = config.interval + (i * 10);
var interval_seconds = typeof config.schedule === 'number' ? config.schedule + (i * 10) : i * 10;

setInterval(function (config, appInformation) {
var fetch = function (config, appInformation) {
if (config.verbose) console.log("INFO: [" + config.appId + "] Fetching App Store reviews");

exports.fetchAppStoreReviews(config, appInformation, function (reviews) {
exports.handleFetchedAppStoreReviews(config, appInformation, reviews);
});
}, interval_seconds * 1000, config, appInformation);
};

if (typeof config.schedule === 'number') {
setInterval(fetch, interval_seconds * 1000, config, appInformation);
} else {
schedule.scheduleJob(config.schedule, function () {
setTimeout(fetch, interval_seconds * 1000, config, appInformation);
});
}
});
}
});
Expand Down
15 changes: 11 additions & 4 deletions googleplayreviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,24 @@ exports.startReview = function (config, first_run) {
exports.handleFetchedGooglePlayReviews(config, appInformation, reviews);
}

var interval_seconds = config.interval ? config.interval : DEFAULT_INTERVAL_SECONDS;
if (!config.schedule) {
config.schedule = DEFAULT_INTERVAL_SECONDS;
}

setInterval(function (config, appInformation) {
var fetch = function (config, appInformation) {
if (config.verbose) console.log("INFO: [" + config.appId + "] Fetching Google Play reviews");

exports.fetchGooglePlayReviews(config, appInformation, function (reviews) {
exports.handleFetchedGooglePlayReviews(config, appInformation, reviews);
});
}, interval_seconds * 1000, config, appInformation);
});
}

if (typeof config.schedule === 'number') {
setInterval(fetch, config.schedule * 1000, config, appInformation);
} else {
schedule.scheduleJob(config.schedule, fetch(config, appInformation));
}
});
});
};

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports.start = function start(config) {
slackHook: config.slackHook,
verbose: config.verbose,
dryRun: config.dryRun,
interval: config.interval,
schedule: config.interval || config.cronStyleSchedule,
botIcon: app.botIcon || config.botIcon,
showAppIcon: app.showAppIcon || config.showAppIcon,
channel: app.channel || config.channel,
Expand Down
77 changes: 70 additions & 7 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"commander": "^4.1.1",
"google-play-scraper": "^8.0.2",
"googleapis": "^52.1.0",
"node-schedule": "^1.3.2",
"request": "^2.88.0"
}
}