How to use updateOriginGroupLifetime method in devicefarmer-stf

Best JavaScript code snippet using devicefarmer-stf

index.js

Source:index.js Github

copy

Full Screen

...8const dbapi = require('../../../db/api')9const r = require('rethinkdb')10module.exports = function() {11 const log = logger.createLogger('groups-scheduler')12 function updateOriginGroupLifetime(group) {13 const lock = {}14 return dbapi.adminLockGroup(group.id, lock).then(function(lockingSuccessed) {15 if (lockingSuccessed) {16 const now = Date.now()17 return db.run(r.table('groups').get(group.id).update({18 dates: [{19 start: new Date(now)20 , stop: new Date(now + (group.dates[0].stop - group.dates[0].start))21 }]22 }))23 }24 return false25 })26 .finally(function() {27 return dbapi.adminUnlockGroup(lock)28 })29 }30 function deleteUserGroup(group) {31 const lock = {}32 return dbapi.adminLockGroup(group.id, lock).then(function(lockingSuccessed) {33 if (lockingSuccessed) {34 return dbapi.deleteUserGroup(group.id)35 }36 else {37 return db.run(r.table('groups').get(group.id).update({38 isActive: false39 , state: apiutil.WAITING40 }))41 }42 })43 .finally(function() {44 return dbapi.adminUnlockGroup(lock)45 })46 }47 function updateGroupDates(group, incr, isActive) {48 const repetitions = group.repetitions - incr49 const dates = group.dates.slice(incr)50 const duration = group.devices.length * (dates[0].stop - dates[0].start) * (repetitions + 1)51 return db.run(r.table('groups').get(group.id).update({52 dates: dates53 , repetitions: repetitions54 , duration: duration55 , isActive: isActive56 , state: apiutil.READY57 }))58 .then(function() {59 return dbapi.updateUserGroupDuration(group.owner.email, group.duration, duration)60 })61 }62 function doBecomeUnactiveGroup(group) {63 const lock = {}64 return dbapi.adminLockGroup(group.id, lock).then(function(lockingSuccessed) {65 if (lockingSuccessed) {66 return updateGroupDates(group, 1, false)67 }68 else {69 return db.run(r.table('groups').get(group.id).update({70 isActive: false71 , state: apiutil.WAITING72 }))73 }74 })75 .finally(function() {76 return dbapi.adminUnlockGroup(lock)77 })78 }79 function doCleanElapsedGroupDates(group, incr) {80 const lock = {}81 return dbapi.adminLockGroup(group.id, lock).then(function(lockingSuccessed) {82 return lockingSuccessed ? updateGroupDates(group, incr, false) : false83 })84 .finally(function() {85 return dbapi.adminUnlockGroup(lock)86 })87 }88 function doBecomeActiveGroup(group, incr) {89 const lock = {}90 return dbapi.adminLockGroup(group.id, lock).then(function(lockingSuccessed) {91 return lockingSuccessed ? updateGroupDates(group, incr, true) : false92 })93 .finally(function() {94 return dbapi.adminUnlockGroup(lock)95 })96 }97 dbapi.unlockBookingObjects().then(function() {98 setInterval(function() {99 const now = Date.now()100 dbapi.getReadyGroupsOrderByIndex('startTime').then(function(groups) {101 Promise.each(groups, (function(group) {102 if (apiutil.isOriginGroup(group.class)) {103 if (now >= group.dates[0].stop.getTime()) {104 return updateOriginGroupLifetime(group)105 }106 }107 else if ((group.isActive || group.state === apiutil.WAITING) &&108 now >= group.dates[0].stop.getTime()) {109 if (group.dates.length === 1) {110 return deleteUserGroup(group)111 }112 else {113 return doBecomeUnactiveGroup(group)114 }115 }116 else if (!group.isActive) {117 for(const i in group.dates) {118 if (now >= group.dates[i].stop.getTime()) {...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var devicefarmer = require('devicefarmer-stf');2var client = devicefarmer.createClient({3});4client.updateOriginGroupLifetime('test', 100, function(err, res) {5 if (err) {6 return console.error(err);7 }8 console.log('updateOrigin

Full Screen

Using AI Code Generation

copy

Full Screen

1var DeviceFarmer = require('devicefarmer-stf-client');2deviceFarmer.updateOriginGroupLifetime(1, 1, 0, function(err, response){3 if (err) {4 console.error(err);5 } else {6 console.log(response);7 }8});9var DeviceFarmer = require('devicefarmer-stf-client');10deviceFarmer.updateOriginGroup(1, 1, "test", function(err, response){11 if (err) {12 console.error(err);13 } else {14 console.log(response);15 }16});17var DeviceFarmer = require('devicefarmer-stf-client');18deviceFarmer.getOriginGroup(1, 1, function(err, response){19 if (err) {20 console.error(err);21 } else {22 console.log(response);23 }24});25var DeviceFarmer = require('devicefarmer-stf-client');26deviceFarmer.getOriginGroups(1, function(err, response){27 if (err) {28 console.error(err);29 } else {30 console.log(response);31 }32});33var DeviceFarmer = require('devicefarmer-stf-client');34deviceFarmer.deleteOriginGroup(1, 1, function(err, response){35 if (err) {36 console.error(err);37 } else {38 console.log(response);39 }40});41var DeviceFarmer = require('devicefarmer-stf-client');

Full Screen

Using AI Code Generation

copy

Full Screen

1var DeviceFarmer = require('devicefarmer-stf-client');2stf.updateOriginGroupLifetime(1, 2, 1000, function (err, data) {3 console.log(data);4});5var DeviceFarmer = require('devicefarmer-stf-client');6var originGroup = {7};8stf.updateOriginGroup(1, originGroup, function (err, data) {9 console.log(data);10});11var DeviceFarmer = require('devicefarmer-stf-client');12stf.deleteOriginGroup(1, function (err, data) {13 console.log(data);14});15var DeviceFarmer = require('devicefarmer-stf-client');16stf.updateOriginGroupDevices(1, [1], function (err, data) {17 console.log(data);18});19var DeviceFarmer = require('devicefarmer-stf-client');20stf.getOriginGroup(1, function (err, data) {21 console.log(data);22});23var DeviceFarmer = require('devicefarmer-stf-client');24stf.getOriginGroups(function (err, data) {25 console.log(data);26});27var DeviceFarmer = require('devicefarmer-stf-client

Full Screen

Using AI Code Generation

copy

Full Screen

1var devicefarmerStfClient = require('devicefarmer-stf-client');2var api = new devicefarmerStfClient.DeviceFarmerApi();3var originGroupLifetime = new devicefarmerStfClient.OriginGroupLifetime();4originGroupLifetime.id = "id of the origin group";5api.updateOriginGroupLifetime(originGroupLifetime, function(error) {6 if (error) console.error(error);7});8var devicefarmerStfClient = require('devicefarmer-stf-client');9var api = new devicefarmerStfClient.DeviceFarmerApi();10api.getOriginGroup("id of the origin group", function(error, originGroup) {11 if (error) console.error(error);12 else console.log('API called successfully. Returned origin group: ' + originGroup);13});14var devicefarmerStfClient = require('devicefarmer-stf-client');15var api = new devicefarmerStfClient.DeviceFarmerApi();16api.deleteOriginGroup("id of the origin group", function(error) {17 if (error) console.error(error);18});19var devicefarmerStfClient = require('devicefarmer-stf-client');20var api = new devicefarmerStfClient.DeviceFarmerApi();21api.getOriginGroupDevices("id of the origin group", function(error, devices) {22 if (error) console.error(error);23 else console.log('API called successfully. Returned devices: ' + devices);24});25var devicefarmerStfClient = require('devicefarmer-stf-client');26var api = new devicefarmerStfClient.DeviceFarmerApi();27api.getOriginGroupDevicesCount("id of the origin group", function(error, devicesCount

Full Screen

Using AI Code Generation

copy

Full Screen

1const DeviceFarmer = require('devicefarmer-stf-client');2client.updateOriginGroupLifetime('groupname', 1000000000).then(() => {3 console.log('lifetime updated');4});5The {groupname} parameter should be replaced with the name of the origin group. The lifetime of the origin group is specified in the request body as shown in the following example:6{ "lifetime": 1000000000 }7The following example shows how to use the deleteOriginGroup() method of the DeviceFarmer.Client class to delete an origin group:8const DeviceFarmer = require('devicefarmer-stf-client');9client.deleteOriginGroup('groupname').then(() => {10 console.log('origin group deleted');11});12Use the getDevicesFromOriginGroup() method of the

Full Screen

Using AI Code Generation

copy

Full Screen

1const client = require('devicefarmer-stf-client');2const request = require('request');3}, function(err, res, body) {4 if (err) {5 console.error(err);6 } else {7 const device = body.devices[0];8 const deviceID = device.id;9 const originGroupID = device.origin_group_id;10 deviceFarmerClient.updateOriginGroupLifetime(originGroupID, 10, function(err) {11 if (err) {12 console.error(err);13 } else {14 console.log('Lifetime updated');15 }16 });17 deviceFarmerClient.updateOriginGroupLifetime(originGroupID, 20, function(err) {18 if (err) {19 console.error(err);20 } else {21 console.log('Lifetime updated');22 }23 });24 deviceFarmerClient.updateOriginGroupLifetime(originGroupID, 30, function(err) {25 if (err) {26 console.error(err);27 } else {28 console.log('Lifetime updated');29 }30 });31 }32});

Full Screen

Using AI Code Generation

copy

Full Screen

1var devicefarmer = require('devicefarmer-stf');2var api = new devicefarmer.DeviceFarmerApi();3var groupid = "3f2c0b1f-2f8f-4b2f-8e6f-9aa0f8d7e0b1";4var lifetime = 60;5api.updateOriginGroupLifetime(groupid, lifetime, function(error, data, response) {6 console.log('API called successfully. Returned data: ' + data);7});8var devicefarmer = require('devicefarmer-stf');9var api = new devicefarmer.DeviceFarmerApi();10var groupid = "3f2c0b1f-2f8f-4b2f-8e6f-9aa0f8d7e0b1";11var lifetime = 60;12api.updateOriginGroupLifetime(groupid, lifetime, function(error, data, response) {13 console.log('API called successfully. Returned data: ' + data);14});15var devicefarmer = require('devicefarmer-stf');16var api = new devicefarmer.DeviceFarmerApi();17var groupid = "3f2c0b1f-2f8f-4b2f-8e6f-9aa0f8d7e0b1";18var lifetime = 60;19api.updateOriginGroupLifetime(groupid, lifetime, function(error, data, response) {20 console.log('API called successfully. Returned data: ' + data);21});22var devicefarmer = require('devicefarmer-stf');23var api = new devicefarmer.DeviceFarmerApi();24var groupid = "3f2c0b1f-2f8f-4b2f-8e6f-9aa0f8d7e0b1";25var lifetime = 60;26api.updateOriginGroupLifetime(groupid, lifetime, function(error, data, response) {27 console.log('API called successfully. Returned data: ' + data);28});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run devicefarmer-stf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful