mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
some smaller improvements
This commit is contained in:
@@ -27,16 +27,25 @@ class FredyRuntime {
|
||||
execute() {
|
||||
if (!this._providerConfig.enabled) return Promise.resolve();
|
||||
|
||||
return Promise.resolve(this._providerConfig.url)
|
||||
.then(this._getListings.bind(this))
|
||||
.then(this._normalize.bind(this))
|
||||
.then(this._filter.bind(this))
|
||||
.then(this._findNew.bind(this))
|
||||
.then(this._storeStats.bind(this))
|
||||
.then(this._save.bind(this))
|
||||
.then(this._notify.bind(this))
|
||||
.then(this._updateStates.bind(this))
|
||||
.catch(this._handleError.bind(this));
|
||||
return (
|
||||
Promise.resolve(this._providerConfig.url)
|
||||
//scraping the site and try finding new listings
|
||||
.then(this._getListings.bind(this))
|
||||
//bring them in a proper form (dictated by the provider)
|
||||
.then(this._normalize.bind(this))
|
||||
//filter listings with stuff tagged by the blacklist of the provider
|
||||
.then(this._filter.bind(this))
|
||||
//check if new listings available. if so proceed
|
||||
.then(this._findNew.bind(this))
|
||||
//store update of number of found listings
|
||||
.then(this._storeStats.bind(this))
|
||||
//store everything in db
|
||||
.then(this._save.bind(this))
|
||||
//notify the user using the configured notification adapter
|
||||
.then(this._notify.bind(this))
|
||||
//if an error occurred on the way, handle it here.
|
||||
.catch(this._handleError.bind(this))
|
||||
);
|
||||
}
|
||||
|
||||
_getListings(url) {
|
||||
@@ -73,7 +82,6 @@ class FredyRuntime {
|
||||
const newListings = listings.filter(o => getKnownListings(this._jobKey, this._providerId).indexOf(o.id) === -1);
|
||||
|
||||
if (newListings.length === 0) {
|
||||
this._updateStates([]);
|
||||
throw new NoNewListingsError();
|
||||
}
|
||||
|
||||
@@ -85,10 +93,6 @@ class FredyRuntime {
|
||||
return Promise.all(sendNotifications).then(() => newListings);
|
||||
}
|
||||
|
||||
_updateStates(newListings) {
|
||||
return newListings;
|
||||
}
|
||||
|
||||
_save(newListings) {
|
||||
setKnownListings(this._jobKey, this._providerId, [
|
||||
...getKnownListings(this._jobKey, this._providerId),
|
||||
|
||||
Reference in New Issue
Block a user