Skip to content

Commit

Permalink
Remove pause logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dnhn committed Apr 29, 2020
1 parent 480cafa commit 5c0e9b3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
19 changes: 1 addition & 18 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@ const FAH = `${HOST}:7396`;

let workData = {};

const minuteValue = att =>
att.indexOf('min') !== -1 ?
att.slice(0, att.indexOf('min')).trim() :
0;

// Proxy server
app.use(proxy(FAH, {
userResDecorator: (_, proxyData, userReq) => {
if (userReq.path === '/api/updates' && proxyData) {
const data = JSON.parse(proxyData.toString('utf-8'))[0];
if (data[0] === '/api/slots') workData = data[1][0];
if (data[0] === '/api/slots') workData = data[1];
}
return new Promise(resolve => resolve(proxyData));
}
Expand All @@ -33,16 +28,4 @@ setInterval(_ => {

// Simulate actions on web page to prevent it from sleeping
browser.elements.keepAlive.click();

// Reduce waiting time to retrieve new work unit
// When the client is paused then unpaused,
// the waiting time will reduce significantly.
if (workData.waitingon === 'WS Assignment' &&
minuteValue(workData.nextattempt) > 0) {
browser.elements.btnStop.click();
setTimeout(_ => browser.elements.btnPause.click(), 2000);
console.log('paused');
setTimeout(_ => browser.elements.btnRun.click(), 10000);
console.log('unpaused');
}
}, 120000);
6 changes: 0 additions & 6 deletions browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ const driver = new webdriver.Builder()
.build();

module.exports = {
elements: {
btnPause: driver.findElement(webdriver.By.className('button red stop')),
btnRun: driver.findElement(webdriver.By.id('btn-run')),
btnStop: driver.findElement(webdriver.By.id('btn-stop')),
keepAlive: driver.findElement(webdriver.By.id('slots')),
},
open: () => {
driver.get('http://127.0.0.1:4444');
driver.manage().window().minimize();
Expand Down

0 comments on commit 5c0e9b3

Please sign in to comment.