How to use queueJob method in Playwright Internal

Best JavaScript code snippet using playwright-internal

QueueJobService.js

Source:QueueJobService.js Github

copy

Full Screen

1var o = require("./HelperService");2var moment = require('moment');3var $q = require('q');4module.exports = {5 CreateQueueJob: function(queueJob, transaction) {6 console.log("||||||||||||||||||||||||||||||||||| CreateQueueJob")7 var error = new Error('CreateQueueJob.Error');8 function Validate() {9 var q = $q.defer();10 try {11 var fields = {12 Receiver: true,13 CC: true,14 ReceiverType: true,15 ReceiverUID: true,16 Queue: true,17 Read: true,18 EventName: true,19 MsgContent: true,20 Subject: true,21 MsgKind: true,22 MsgContentType: true,23 FirstDelay: true,24 ReleaseDelay: true,25 MaxRelease: true,26 SendFromServer: true,27 SenderType: true,28 SenderUID: true,29 Enable: true,30 MsgState: true,31 }32 var requiredFields = {33 Receiver: true,34 ReceiverType: true,35 // ReceiverUID:true,36 Queue: true,37 MsgContent: true,38 EventName: true,39 SendFromServer: true,40 // SenderType:true,41 // SenderUID:true,42 }43 queueJob = o.rationalizeObject(queueJob, fields);44 if (queueJob.MsgContentType == 'JSON') {45 queueJob.MsgContent = JSON.stringify(queueJob.MsgContent);46 }47 var listMissingFields = o.validateRequireFields(queueJob, requiredFields);48 if (listMissingFields.length > 0) {49 error.pushError({ 'requiredFields': listMissingFields });50 throw error;51 }52 if (queueJob.Queue == o.const.queue.SMS) {53 if (!o.isValidPhoneNumber(queueJob.Receiver)) {54 error.pushError("Receiver.PhoneNumber.Invalid");55 throw error;56 }57 }58 if (queueJob.Queue == o.const.queue.EMAIL) {59 if (!o.isValidEmail(queueJob.Receiver)) {60 error.pushError("Receiver.Email.Invalid");61 throw error;62 }63 }64 q.resolve({ status: 'success' });65 } catch (err) {66 q.reject(err);67 }68 return q.promise;69 }70 return Validate()71 .then(function(data) {72 if (queueJob.FirstDelay && queueJob.FirstDelay > 0)73 queueJob.Status = o.const.jobStatus.DELAY;74 else75 queueJob.Status = o.const.jobStatus.READY;76 console.log(queueJob);77 return QueueJob.create(queueJob, { transaction: transaction })78 .then(function(data) {79 return data;80 }, function(err) {81 o.exlog(err);82 error.pushError('QueueJob.createError');83 throw error;84 })85 }, function(err) {86 throw err;87 })88 },89 GetQueueJob: function(ID, transaction) {90 console.log("||||||||||||||||||||||||||||||||||| GetQueueJob")91 var error = new Error("GetQueueJob.Error");92 return QueueJob.findOne({93 where: {94 ID: ID95 },96 transaction: transaction97 })98 .then(function(data) {99 return data;100 }, function(err) {101 o.exlog(err);102 error.pushError("query.error");103 throw error;104 })105 },106 //Dua job quay tro lai queue107 //Cac field can update:108 //Status: READY hay DELAY109 //ReleaseCount: day la la release thu bao nhieu110 //LastedSentAt: thoi diem cuoi cung send message111 Requeue: function(queueJob, transaction) {112 console.log("||||||||||||||||||||||||||||||||||| Requeue")113 var error = new Error("Requeue.Error");114 var Status = null;115 ReleaseCount = null;116 Status = (queueJob.ReleaseDelay && queueJob.ReleaseDelay) ? 'DELAY' : 'READY';117 ReleaseCount = (queueJob.ReleaseCount) ? queueJob.ReleaseCount : 0;118 ReleaseCount = ReleaseCount + 1;119 return queueJob.updateAttributes({120 Status: Status,121 ReleaseCount: ReleaseCount,122 LastedSentAt: new Date(),123 }, { transaction: transaction })124 .then(function(qj) {125 QueueJobLogService.AddLog(queueJob.ID, 'Release');126 return qj;127 }, function(err) {128 console.log(err);129 error.pushError("update.error");130 this.BuryQueueJob(queueJob, error);131 throw error;132 })133 },134 FinishQueueJob: function(queueJob) {135 console.log("||||||||||||||||||||||||||||||||||| FinishQueueJob")136 var error = new Error("FinishQueueJob.Error");137 /*return queueJob.updateAttributes({138 Status:'HANDLED',139 LastedSentAt:new Date(),140 })141 .then(function(qj){142 QueueJobLogService.AddLog(queueJob.ID,'Handled');143 return qj;144 },function(err){145 console.log(err);146 error.pushError('update.error');147 this.BuryQueueJob(queueJob,error);148 throw error;149 })*/150 function updateStatus(qj) {151 return qj.updateAttributes({152 Status: 'HANDLED',153 LastedSentAt: new Date(),154 })155 .then(function(qj) {156 QueueJobLogService.AddLog(qj.ID, 'Handled');157 return qj;158 }, function(err) {159 console.log(err);160 error.pushError("update.error");161 QueueJobLogService.AddLog(qj.ID, error);162 throw error;163 })164 }165 if (_.isObject(queueJob)) {166 return updateStatus(queueJob);167 } else {168 var queueJobID = queueJob;169 return this.GetQueueJob(queueJobID)170 .then(function(qj) {171 return updateStatus(qj);172 }, function(err) {173 console.log(err);174 error.pushError("query.error");175 QueueJobLogService.AddLog(queueJobID, error);176 throw error;177 })178 }179 },180 BuryQueueJob: function(queueJob, log) {181 console.log("||||||||||||||||||||||||||||||||||| BuryQueueJob")182 var error = new Error('BuryQueueJob.Error');183 function updateStatus(qj) {184 return qj.updateAttributes({185 Status: 'BURIED',186 })187 .then(function(qj) {188 QueueJobLogService.AddLog(qj.ID, log);189 return qj;190 }, function(err) {191 console.log(err);192 error.pushError("update.error");193 QueueJobLogService.AddLog(qj.ID, error);194 throw error;195 })196 }197 if (_.isObject(queueJob)) {198 return updateStatus(queueJob);199 } else {200 var queueJobID = queueJob;201 return this.GetQueueJob(queueJobID)202 .then(function(qj) {203 return updateStatus(qj);204 }, function(err) {205 console.log(err);206 error.pushError("query.error");207 QueueJobLogService.AddLog(queueJobID, error);208 throw error;209 })210 }211 },212 GetListQueueByRole: function(userUID, queue) {213 var q = $q.defer();214 QueueJob.findAll({215 where: {216 Queue: queue,217 ReceiverUID: userUID,218 },219 include: {220 model: UserAccount,221 attributes: ['UID', 'UserName'],222 as: 'SenderAccount'223 },224 order: 'CreatedDate DESC'225 }).then(function(data) {226 QueueJob.count({227 where: {228 Queue: queue,229 Read: 'N',230 ReceiverUID: userUID,231 }232 }).then(function(count) {233 q.resolve({234 status: 'success',235 data: data,236 count: count,237 });238 }, function(err) {239 console.log("GetListQueueByRoleCount", err);240 });241 }, function(err) {242 console.log("GetListQueueByRole", err);243 q.reject(err);244 });245 return q.promise;246 },247 whereClause: function(data) {248 var whereClause = {};249 if (data.Search.userUID) {250 whereClause.ReceiverUID = data.Search.userUID251 };252 if (data.Search.queue) {253 whereClause.Queue = data.Search.queue254 };255 if (data.Search.kind) {256 whereClause.MsgKind = data.Search.kind257 };258 if (data.Search.kind === 'Review' && data.Search.type) {259 whereClause.Subject = data.Search.type260 };261 if (data.Search.SenderUID) {262 whereClause.SenderUID = data.Search.SenderUID;263 } else {264 whereClause.Enable = 'Y';265 whereClause.Status = o.const.jobStatus.HANDLED;266 };267 if (data.Search.MsgContent) {268 whereClause.MsgContent = {269 like: '%"Action":"%' + data.Search.MsgContent + '%"}%'270 }271 };272 if (data.Search.Subject) {273 whereClause.Subject = {274 like: '%' + data.Search.Subject + '%'275 }276 };277 if (data.Search.Object) {278 whereClause.MsgContent = {279 like: '%"Object":{"name":"%' + data.Search.Object + '%","%'280 }281 };282 if (data.Search.FromCreatedDate && !data.Search.ToCreatedDate) {283 whereClause.CreatedDate = {284 $gte: data.Search.FromCreatedDate,285 $lt: moment(data.Search.FromCreatedDate).add(1, 'days').format('YYYY-MM-DD HH:mm:ss Z')286 }287 };288 if (!data.Search.FromCreatedDate && data.Search.ToCreatedDate) {289 whereClause.CreatedDate = {290 $gte: data.Search.ToCreatedDate,291 $lt: moment(data.Search.ToCreatedDate).add(1, 'days').format('YYYY-MM-DD HH:mm:ss Z')292 }293 };294 if (data.Search.FromCreatedDate && data.Search.ToCreatedDate) {295 whereClause.CreatedDate = {296 $gte: data.Search.FromCreatedDate,297 $lt: moment(data.Search.ToCreatedDate).add(1, 'days').format('YYYY-MM-DD HH:mm:ss Z')298 }299 };300 return whereClause;301 },302 GetListQueueByRoleSearch: function(info) {303 var q = $q.defer();304 var whereClause = QueueJobService.whereClause(info);305 var whereClauseAccount = {306 Sender: {},307 Receiver: {},308 };309 if (info.Search.SenderAccount) {310 whereClauseAccount.Sender.UserName = {311 like: '%' + info.Search.SenderAccount + '%'312 }313 };314 if (info.Search.ReceiverAccount) {315 whereClauseAccount.Receiver.UserName = {316 like: '%' + info.Search.ReceiverAccount + '%'317 }318 };319 var limit = info.limit;320 var offset = info.offset;321 QueueJob.findAndCountAll({322 offset: offset,323 limit: limit,324 where: whereClause,325 include: [{326 model: UserAccount,327 attributes: ['UserName'],328 as: 'SenderAccount',329 where: whereClauseAccount.Sender330 }, {331 model: UserAccount,332 attributes: ['UserName'],333 as: 'ReceiverAccount',334 where: whereClauseAccount.Receiver335 },{336 model: UserAccount,337 attributes: ['UserName'],338 as: 'ModifiedAccount'339 }],340 order: info.order341 }).then(function(data) {342 whereClause.Read = 'N';343 QueueJob.count({344 where: whereClause,345 include: [{346 model: UserAccount,347 attributes: ['UserName'],348 as: 'SenderAccount',349 where: whereClauseAccount.Sender350 }, {351 model: UserAccount,352 attributes: ['UserName'],353 as: 'ReceiverAccount',354 where: whereClauseAccount.Receiver355 }],356 }).then(function(count) {357 q.resolve({358 status: 'success',359 data: data.rows,360 count: count,361 countAll: data.count362 });363 }, function(err) {364 console.log("GetListQueueByRoleCount", err);365 });366 }, function(err) {367 console.log("GetListQueueByRole", err);368 q.reject(err);369 });370 return q.promise;371 },372 UpdateReadQueueJob: function(info) {373 var q = $q.defer();374 var userUID = info.userUID;375 var queue = info.queue;376 var whereClause = {377 ReceiverUID: userUID,378 Queue: queue,379 Read: 'N',380 };381 if (info.ID) {382 whereClause.ID = info.ID;383 };384 QueueJob.update({385 Read: 'Y'386 }, {387 where: whereClause388 }).then(function(data) {389 q.resolve({390 status: 'success',391 data: data392 });393 }, function(err) {394 q.reject(err);395 });396 return q.promise;397 },398 ChangeEnableQueueJob: function(info) {399 var q = $q.defer();400 UserAccount.findOne({401 where: {402 UID: info.UserUID403 },404 attributes: ['ID'],405 }).then(function(data0) {406 QueueJob.update({407 Enable: info.Enable,408 ModifiedBy: data0.ID409 }, {410 where: { ID: info.ID }411 }).then(function(data) {412 q.resolve({413 status: 'success'414 });415 }, function(err) {416 q.reject(err);417 });418 }, function(err) {419 q.reject(err);420 });421 return q.promise;422 },423 UpdateStateQueueJob: function(info) {424 var q = $q.defer();425 UserAccount.findOne({426 where: {427 UID: info.UserUID428 },429 attributes: ['ID'],430 }).then(function(data0) {431 QueueJob.update({432 MsgState: info.MsgState,433 ModifiedBy: data0.ID434 }, {435 where: { ID: info.ID }436 }).then(function(data) {437 q.resolve({438 status: 'success'439 });440 }, function(err) {441 q.reject(err);442 });443 }, function(err) {444 q.reject(err);445 });446 return q.promise;447 },...

Full Screen

Full Screen

HandlerUtils.js

Source:HandlerUtils.js Github

copy

Full Screen

1module.exports={2 jobLifeCycle:function(jobdata,FuncNonLoop,FuncLoop)3 {4 console.log("jobLifeCycle |||||||||||||||||||||||||||||||||||");5 var error=new Error("jobLifeCycle.Error");6 return QueueJobService.GetQueueJob(jobdata.ID)7 .then(function(queueJob){8 if(queueJob)9 {10 if(['READY','DELAY'].indexOf(queueJob.Status)>=0)11 { 12 if (queueJob.Enable === 'N') {13 error.pushError("sender.turnoffmessage");14 return QueueJobService.BuryQueueJob(queueJob,ErrorWrap(error))15 .then(function(success){16 return {status:'bury'};17 });18 };19 if(queueJob.MaxRelease==0)20 {21 //TRUONG HOP CHI GUI MESSAGE 1 LAN22 return FuncNonLoop(queueJob)23 .then(function(status){24 return {status:"success"};25 },function(err){26 return QueueJobService.BuryQueueJob(queueJob,ErrorWrap(err))27 .then(function(success){28 return {status:'bury'};29 })30 })31 }32 else33 {34 var ReleaseCount=queueJob.ReleaseCount?queueJob.ReleaseCount:0;35 if(queueJob.MaxRelease>=ReleaseCount)36 {37 //TRUONG HOP GUI MESSAGE REPEAT38 return FuncLoop(queueJob)39 .then(function(status){40 return {status:"release",ReleaseDelay:queueJob.ReleaseDelay};41 },function(err){42 return QueueJobService.BuryQueueJob(queueJob,ErrorWrap(err))43 .then(function(success){44 return {status:'bury'};45 })46 })47 }48 else49 {50 error.pushError('queueJob.MaxRelease');51 return QueueJobService.BuryQueueJob(queueJob,ErrorWrap(error))52 .then(function(success){53 return {status:'bury'};54 })55 }56 }57 }58 else if(queueJob.Status=="HANDLED")59 {60 return QueueJobService.FinishQueueJob(queueJob)61 .then(function(success){62 return {status:'success'};63 })64 }65 else66 {67 error.pushError("queueJob.buried");68 return QueueJobService.BuryQueueJob(queueJob,ErrorWrap(error))69 .then(function(success){70 return {status:'bury'};71 })72 }73 }74 else75 {76 error.pushError("queueJob.notFound");77 return QueueJobService.BuryQueueJob(jobdata.ID,ErrorWrap(error))78 .then(function(success){79 return {status:'bury'};80 })81 }82 },function(err){83 return QueueJobService.BuryQueueJob(jobdata.ID,ErrorWrap(err))84 .then(function(success){85 return {status:'bury'};86 })87 })88 },89 jobgLifeCycle:function(jobgdata,FuncNonLoop,FuncLoop)90 {91 console.log("jobgLifeCycle |||||||||||||||||||||||");92 var error=new Error("jobgLifeCycle.Error");93 return QueueJobgService.GetQueueJobg(jobgdata.ID)94 .then(function(queueJobg){95 if(queueJobg)96 {97 if(['READY','DELAY'].indexOf(queueJobg.Status)>=0)98 {99 if (queueJobg.Enable === 'N') {100 error.pushError("sender.turnoffmessage");101 return QueueJobgService.BuryQueueJobg(queueJobg,ErrorWrap(error))102 .then(function(success){103 return {status:'bury'};104 });105 };106 if(queueJobg.MaxRelease==0)107 {108 //TRUONG HOP CHI GUI MESSAGE 1 LAN109 return FuncNonLoop(queueJobg)110 .then(function(status){111 return {status:"success"};112 },function(err){113 return QueueJobgService.BuryQueueJobg(queueJobg,ErrorWrap(err))114 .then(function(success){115 return {status:'bury'};116 })117 })118 }119 else120 {121 var ReleaseCount=queueJobg.ReleaseCount?queueJobg.ReleaseCount:0;122 if(queueJobg.MaxRelease>=ReleaseCount)123 {124 //TRUONG HOP GUI MESSAGE REPEAT125 return FuncLoop(queueJobg)126 .then(function(status){127 return {status:"release",ReleaseDelay:queueJobg.ReleaseDelay};128 },function(err){129 return QueueJobgService.BuryQueueJobg(queueJobg,ErrorWrap(err))130 .then(function(success){131 return {status:'bury'};132 })133 })134 }135 else136 {137 error.pushError('queueJobg.MaxRelease');138 return QueueJobgService.BuryQueueJobg(queueJobg,ErrorWrap(error))139 .then(function(success){140 return {status:'bury'};141 })142 }143 }144 }145 else if(queueJobg.Status=="HANDLED")146 {147 return QueueJobgService.FinishQueueJobg(queueJobg)148 .then(function(success){149 return {status:'success'};150 })151 }152 else153 {154 error.pushError("queueJobg.buried");155 return QueueJobgService.BuryQueueJobg(queueJobg,ErrorWrap(error))156 .then(function(success){157 return {status:'bury'};158 })159 }160 }161 else162 {163 error.pushError("queueJobg.notFound");164 return QueueJobgService.BuryQueueJobg(jobgdata.ID,ErrorWrap(error))165 .then(function(success){166 return {status:'bury'};167 })168 }169 },function(err){170 return QueueJobgService.BuryQueueJobg(jobgdata.ID,ErrorWrap(err))171 .then(function(success){172 return {status:'bury'};173 })174 })175 }...

Full Screen

Full Screen

storeItemsPage.js

Source:storeItemsPage.js Github

copy

Full Screen

1var async = require('async'),2 debug = require('app/lib/debug')('app:itemController:storeItemsPage'),3 getResource = require('app/controllers/item/getResource'),4 Item = require('app/models/item'),5 itemDataObjectsFromPage = require('app/controllers/item/itemDataObjectsFromPage'),6 itemsGetUrl = require('app/controllers/item/itemsGetUrl'),7 itemsPageNextPagination = require('app/controllers/item/itemsPageNextPagination'),8 totalItemsAvailableFromPage = require('app/controllers/item/totalItemsAvailableFromPage'),9 itemsPageError = require('app/controllers/item/itemsPageError'),10 kue = require('kue'),11 logger = require('app/lib/logger'),12 persistItemDataObject = require('app/controllers/item/persistItemDataObject'),13 storeItemData = require('app/controllers/item/storeItemData'),14 UserSourceAuth = require('app/models/userSourceAuth'),15 validateParams = require('app/lib/validateParams');16var queue = kue.createQueue();17queue.process('storeItemData', (queueJob, done) => {18 // eslint-disable-next-line global-require19 var Job = require('app/models/job');20 21 debug('process queueJob %s with itemId %s and jobId', queueJob.id, queueJob.data.itemId, queueJob.data.jobId);22 var getItem = (done) => {23 Item.findById(queueJob.data.itemId, (error, item) => {24 if (error) {25 done(error);26 } else if (!item) {27 done(new Error('Item with queueJob.data.itemId not found'));28 } else {29 done(undefined, item);30 }31 });32 };33 var getJob = (item, done) => {34 if (!queueJob.data.jobId) { return done(undefined, item, undefined); }35 Job.findById(queueJob.data.jobId, (error, job) => {36 if (error) {37 done(error);38 } else if (!job) {39 done(new Error('Job with queueJob.data.jobId not found'));40 } else {41 done(undefined, item, job);42 }43 });44 };45 var runStoreItemData = (item, job, done) => {46 debug.start('queueJob storeItemData', item.id, job ? job.id : null);47 storeItemData(item, queueJob.data.data, job, done);48 };49 async.waterfall([getItem, getJob, runStoreItemData], (error) => {50 if (error) {51 debug.error('failed to process queueJob %s: %s', queueJob.id, error.message);52 } else {53 debug.success('processed queueJob %s', queueJob.id);54 }55 done(error);56 });57});58queue.on('error', (error) => {59 debug.error('queueJob failed:', error.message);60});61/**62 * Store all items of contentType found from source for user.63 * Persist new Items in database for any not previously stored.64 * Emit event on app for each Item once stored.65 * @param {User} user - User for which to retrieve items from source and store them in storage.66 * @param {Source} source - Source from which to retrieve items.67 * @param {Storage} storage - Storage within which to store items.68 * @param {ContentType} contentType - ContentType of which to retrieve items.69 * @param {Object} pagination – Object containing pagination information.70 * @param {Job} [job] - Job for which to store items.71 * @param {callback} done72 */73module.exports = function(user, source, storage, contentType, pagination, job, done) {74 var ids, page, userSourceAuth, log = logger.scopedLog();75 var validate = (done) => {76 validateParams([{77 name: 'user', variable: user, required: true, requiredProperties: ['id']78 }, {79 name: 'source', variable: source, required: true, requiredProperties: ['id']80 }, {81 name: 'storage', variable: storage, required: true, requiredProperties: ['id']82 }, {83 name: 'contentType', variable: contentType, required: true, requiredProperties: ['id']84 }, {85 name: 'pagination', variable: pagination, required: true86 }], done);87 };88 var setupLog = (done) => {89 debug.start('## storeItemsPage (contentType: %s, pagination: %o)', contentType.id, pagination);90 ids = {91 user: user.id,92 storage: storage.id,93 source: source.id,94 contentType: contentType.id95 };96 log = logger.scopedLog(Object.assign({}, pagination, ids));97 done();98 };99 var findUserSourceAuth = (done) => {100 UserSourceAuth.findOne({101 user: user.id,102 source: source.id103 }, (error, foundUserSourceAuth) => {104 if (!foundUserSourceAuth && !error) {105 error = new Error('Failed to find userSourceAuth');106 }107 userSourceAuth = foundUserSourceAuth;108 done(error);109 });110 };111 var getItemsPageResource = (done) => {112 getResource(itemsGetUrl(source, contentType, userSourceAuth, pagination), done);113 };114 var getItemDataObjects = (resource, done) => {115 page = resource;116 var error = itemsPageError(page);117 if (error) {118 return done(new Error('Failed to retrieve valid item objects page. ' + error.message));119 }120 var itemDataObjects = itemDataObjectsFromPage(page, source, contentType);121 var totalItemsAvailable = totalItemsAvailableFromPage(page, source, contentType);122 if (job && totalItemsAvailable && pagination.offset === 0) {123 job.updateTotalItemsAvailable(totalItemsAvailable);124 }125 if (!itemDataObjects || !itemDataObjects.length) {126 debug.warning('storeItemsPage retrieved page with no data (contentType: %s, pagination: %o)', contentType.id, pagination);127 }128 done(undefined, itemDataObjects);129 };130 var persistItemDataObjects = (itemDataObjects, done) => {131 var count = 0;132 async.mapSeries(itemDataObjects, (itemDataObject, done) => {133 count++;134 debug('persisting itemDataObject #%s', count);135 136 persistItemDataObject(itemDataObject, {137 user: user,138 storage: storage,139 source: source,140 contentType: contentType141 }, (error, item) => {142 debug('persisted itemDataObject #%s with item ID %s', count, item.id);143 done(error, {144 item: item,145 data: itemDataObject146 });147 });148 }, done);149 };150 var storeItemsData = (itemPairs, done) => {151 async.each(itemPairs, (itemPair, done) => {152 var jobAttributes = {153 itemId: itemPair.item.id,154 data: itemPair.data155 };156 if (job) {157 jobAttributes.jobId = job.id;158 }159 var queueJob = queue.create('storeItemData', jobAttributes).save((error) => {160 if (error) {161 debug.error('queueJob %s failed to queue: %s', queueJob.id, error.message);162 } else {163 debug.success('queueJob %s queued for item %s', queueJob.id, itemPair.item.id);164 }165 });166 done();167 }, done);168 };169 var determineNextPagination = (done) => {170 done(undefined, itemsPageNextPagination(page, pagination, contentType));171 };172 async.waterfall([173 validate,174 setupLog,175 findUserSourceAuth,176 getItemsPageResource,177 getItemDataObjects,178 persistItemDataObjects,179 storeItemsData,180 determineNextPagination181 ], (error, nextPagination) => {182 if (error) {183 log('error', 'Item controller failed to store page of items', { error: error.message });184 } else {185 debug.success('storeItemsPage (contentType: %s, pagination: %o, nextPagination: %o)', contentType.id, pagination, nextPagination);186 }187 done(error, nextPagination);188 });...

Full Screen

Full Screen

Associations.js

Source:Associations.js Github

copy

Full Screen

1module.exports = {2 associations: function() {3 //association QueueJob - UserAccount(Receiver)4 UserAccount.hasMany(QueueJob, {5 foreignKey: 'ReceiverUID',6 targetKey: 'UID'7 });8 QueueJob.belongsTo(UserAccount, {9 foreignKey: 'ReceiverUID',10 targetKey: 'UID',11 as: 'ReceiverAccount'12 });13 //association QueueJob - UserAccount(Sender)14 UserAccount.hasMany(QueueJob, {15 foreignKey: 'SenderUID',16 targetKey: 'UID'17 });18 QueueJob.belongsTo(UserAccount, {19 foreignKey: 'SenderUID',20 targetKey: 'UID',21 as: 'SenderAccount'22 });23 //association QueueJob - UserAccount(ModifiedBy)24 UserAccount.hasMany(QueueJob, {25 foreignKey: 'ModifiedBy',26 targetKey: 'ID'27 });28 QueueJob.belongsTo(UserAccount, {29 foreignKey: 'ModifiedBy',30 targetKey: 'ID',31 as: 'ModifiedAccount'32 });33 //association QueueJobg - UserAccount(Receiver)34 UserAccount.hasMany(QueueJobg, {35 foreignKey: 'ReceiverUID',36 targetKey: 'UID'37 });38 QueueJobg.belongsTo(UserAccount, {39 foreignKey: 'ReceiverUID',40 targetKey: 'UID',41 as: 'ReceiverAccount'42 });43 //association QueueJobg - UserAccount(Sender)44 UserAccount.hasMany(QueueJobg, {45 foreignKey: 'SenderUID',46 targetKey: 'UID'47 });48 QueueJobg.belongsTo(UserAccount, {49 foreignKey: 'SenderUID',50 targetKey: 'UID',51 as: 'SenderAccount'52 });53 // UserAccount - RelUserRole - Role54 UserAccount.hasMany(RelUserRole, {55 foreignKey: 'UserAccountId'56 });57 RelUserRole.belongsTo(UserAccount, {58 foreignKey: 'UserAccountId'59 });60 Role.hasMany(RelUserRole, {61 foreignKey: 'RoleId'62 });63 RelUserRole.belongsTo(Role, {64 foreignKey: 'RoleId'65 });66 Role.belongsToMany(UserAccount, {67 through: 'RelUserRole',68 foreignKey: 'RoleId'69 });70 UserAccount.belongsToMany(Role, {71 through: 'RelUserRole',72 foreignKey: 'UserAccountId'73 });74 }...

Full Screen

Full Screen

EmailHandlers.js

Source:EmailHandlers.js Github

copy

Full Screen

1var HandlerUtils=require("./HandlerUtils");2var sendMailNonLoop=function(queueJob)3{4 var mailOptions={5 subject:queueJob.Subject,6 to:queueJob.Receiver,7 html:queueJob.MsgContent8 }9 return EmailService.SendMail('test',mailOptions)10 .then(function(sentInfo){11 console.log(sentInfo);12 return QueueJobService.FinishQueueJob(queueJob)13 .then(function(qj){14 return {status:"success"};15 },function(err){16 throw err;17 })18 })19}20var sendMailLoop=function(queueJob)21{22 var mailOptions={23 subject:queueJob.Subject,24 to:queueJob.Receiver,25 html:queueJob.MsgContent26 }27 return EmailService.SendMail('test',mailOptions)28 .then(function(sentInfo){29 console.log(sentInfo);30 return QueueJobService.Requeue(queueJob)31 .then(function(qj){32 return {status:"release"};33 },function(err){34 throw err;35 })36 },function(err){37 throw err;38 })39}40module.exports={41 sendmail:function()42 {43 function TestEmail()44 {45 this.type = 'sendmail';46 this.work=function(jobdata, callback)47 {48 HandlerUtils.jobLifeCycle(jobdata,sendMailNonLoop,sendMailLoop)49 .then(function(result){50 if(result.status=='success')51 {52 callback("success");53 }54 else if(result.status=='release')55 {56 callback("release",result.ReleaseDelay);57 }58 else59 {60 callback("bury");61 }62 })63 }64 }65 var handler = new TestEmail();66 return handler;67 }...

Full Screen

Full Screen

NotifyHandlers.js

Source:NotifyHandlers.js Github

copy

Full Screen

1var HandlerUtils=require("./HandlerUtils");2var sendNotifyNonLoop=function(queueJob)3{4 return NotifyService.SendNotify(queueJob.Receiver,queueJob.EventName,queueJob.MsgContent)5 .then(function(responseData){6 return QueueJobService.FinishQueueJob(queueJob)7 .then(function(qj){8 return {status:'success'};9 },function(err){10 throw err;11 })12 },function(err){13 console.log(err);14 throw err;15 })16};17var sendNotifyLoop=function(queueJob)18{19 return NotifyService.SendNotify(queueJob.Receiver,queueJob.EventName,queueJob.MsgContent)20 .then(function(responseData){21 return QueueJobService.Requeue(queueJob)22 .then(function(qj){23 return {status:'release'}24 },function(err){25 throw err;26 })27 },function(err){28 console.log(err);29 throw err;30 })31}32module.exports={33 sendnotify:function(){34 function SendNotify()35 {36 this.type='sendnotify';37 this.work=function(jobdata,callback)38 {39 console.log("|||||||||||||||||||||||||| sendnotify");40 HandlerUtils.jobLifeCycle(jobdata,sendNotifyNonLoop,sendNotifyLoop)41 .then(function(result){42 if(result.status=='success')43 {44 callback("success");45 }46 else if(result.status=='release')47 {48 callback("release",result.ReleaseDelay);49 }50 else51 {52 callback("bury");53 }54 })55 }56 }57 var handler = new SendNotify();58 return handler;59 }...

Full Screen

Full Screen

SMSHandlers.js

Source:SMSHandlers.js Github

copy

Full Screen

1var HandlerUtils=require("./HandlerUtils");2var sendSMSNonLoop=function(queueJob)3{4 return SMSService.SendSMS(queueJob.Receiver,queueJob.MsgContent)5 .then(function(responseData){6 console.log(responseData);7 return QueueJobService.FinishQueueJob(queueJob)8 .then(function(qj){9 return {status:'success'};10 },function(err){11 throw err;12 })13 },function(err){14 console.log(err);15 throw err;16 })17}18var sendSMSLoop=function(queueJob)19{20 return SMSService.SendSMS(queueJob.Receiver,queueJob.MsgContent)21 .then(function(responseData){22 console.log(responseData);23 return QueueJobService.Requeue(queueJob)24 .then(function(qj){25 return {status:'release'}26 },function(err){27 throw err;28 })29 },function(err){30 console.log(err);31 throw err;32 })33}34module.exports={35 sendsms:function()36 {37 function SendSMS()38 {39 this.type='sendsms';40 this.work=function(jobdata,callback)41 {42 HandlerUtils.jobLifeCycle(jobdata,sendSMSNonLoop,sendSMSLoop)43 .then(function(result){44 if(result.status=='success')45 {46 callback("success");47 }48 else if(result.status=='release')49 {50 callback("release",result.ReleaseDelay);51 }52 else53 {54 callback("bury");55 }56 })57 }58 }59 var handler = new SendSMS();60 return handler;61 }...

Full Screen

Full Screen

8-job.js

Source:8-job.js Github

copy

Full Screen

1export default function createPushNotificationsJobs(jobs, queue) {2 if (!Array.isArray(jobs)) throw 'Jobs is not an array'3 jobs.forEach(job => {4 const queueJob = queue.create('push_notification_code_3', job).save(error => {5 if (!error) console.log(`Notification job created: ${queueJob.id}`);6 });7 queueJob.on('complete', () => console.log(`Notification job ${queueJob.id} completed`));8 queueJob.on('failed', (error) => console.log(`Notification job ${queueJob.id} failed: ${error}`));9 queueJob.on('progress', (progress) => console.log(`Notification job ${queueJob.id} ${progress}% complete`));10 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.screenshot({ path: 'example.png' });6 await browser.close();7})();8import { PlaywrightTestConfig } from '@playwright/test';9const config: PlaywrightTestConfig = {10 use: {11 viewport: { width: 1280, height: 720 },12 },13 {14 use: {15 },16 },17};18export default config;

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.screenshot({ path: 'example.png' });6 await browser.close();7})();8const { chromium } = require('playwright');9(async () => {10 const browser = await chromium.launch();11 const page = await browser.newPage();12 await page.screenshot({ path: 'example.png' });13 await browser.close();14})();15const { chromium } = require('playwright');16(async () => {17 const browser = await chromium.launch();18 const page = await browser.newPage();19 await page.screenshot({ path: 'example.png' });20 await browser.close();21})();22const { chromium } = require('playwright');23(async () => {24 const browser = await chromium.launch();25 const page = await browser.newPage();26 await page.screenshot({ path: 'example.png' });27 await browser.close();28})();29const { chromium } = require('playwright');30(async () => {31 const browser = await chromium.launch();32 const page = await browser.newPage();33 await page.screenshot({ path: 'example.png' });34 await browser.close();35})();36const { chromium } = require('playwright');37(async () => {38 const browser = await chromium.launch();39 const page = await browser.newPage();40 await page.screenshot({ path: 'example.png' });41 await browser.close();42})();43const { chromium } = require('playwright');44(async () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.launch();4 const page = await browser.newPage();5 await page.waitForSelector('.navbar__inner');6 await page.evaluate(() => {7 window.__playwright__queueJob(() => {8 console.log('hello from the browser');9 });10 });11 await browser.close();12})();13const playwright = require('playwright');14(async () => {15 const browser = await playwright.chromium.launch();16 const page = await browser.newPage();17 await page.waitForSelector('.navbar__inner');18 await page.evaluate(() => {19 window.__playwright__queueMicrotask(() => {20 console.log('hello from the browser');21 });22 });23 await browser.close();24})();25const playwright = require('playwright');26(async () => {27 const browser = await playwright.chromium.launch();28 const page = await browser.newPage();29 await page.waitForSelector('.navbar__inner');30 await page.evaluate(() => {31 window.__playwright__runBeforeUnload();32 });33 await browser.close();34})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { queueJob } = require('playwright/lib/internal/worker');2queueJob(() => {3 console.log("hello world");4});5const { queueMicrotask } = require('playwright/lib/internal/worker');6queueMicrotask(() => {7 console.log("hello world");8});9const { queueTask } = require('playwright/lib/internal/worker');10queueTask(() => {11 console.log("hello world");12});13const { queueMicrotask } = require('playwright/lib/internal/worker');14queueMicrotask(() => {15 console.log("hello world");16});17const { queuePostTask } = require('playwright/lib/internal/worker');18queuePostTask(() => {19 console.log("hello world");20});21const { queuePostMicrotask } = require('playwright/lib/internal/worker');22queuePostMicrotask(() => {23 console.log("hello world");24});25const { queuePostTask } = require('playwright/lib/internal/worker');26queuePostTask(() => {27 console.log("hello world");28});29const { queuePostMicrotask } = require('playwright/lib/internal/worker');30queuePostMicrotask(() => {31 console.log("hello world");32});33const { queuePostTask } = require('playwright/lib/internal/worker');34queuePostTask(() => {35 console.log("hello world");36});37const { queuePostMicrotask } = require('playwright/lib/internal/worker');38queuePostMicrotask(() => {39 console.log("hello world");40});41const { queuePostTask } = require('playwright/lib/internal/worker');42queuePostTask(() => {43 console.log("hello world");44});45const { queuePostMicrotask } =

Full Screen

Using AI Code Generation

copy

Full Screen

1const { queueJob } = require('playwright/lib/internal/worker');2queueJob(() => {console.log('Hello World!')});3const { queueMicrotask } = require('playwright/lib/internal/worker');4queueMicrotask(() => {console.log('Hello World!')});5const { runWithDebugger } = require('playwright/lib/internal/worker');6runWithDebugger(() => {console.log('Hello World!')});7const { runWithTracing } = require('playwright/lib/internal/worker');8runWithTracing(() => {console.log('Hello World!')});9const { setLogHandler } = require('playwright/lib/internal/worker');10setLogHandler(() => {console.log('Hello World!')});11const { setLogVerbosity } = require('playwright/lib/internal/worker');12setLogVerbosity(() => {console.log('Hello World!')});13const { setMaxListeners } = require('playwright/lib/internal/worker');14setMaxListeners(() => {console.log('Hello World!')});15const { setUncaughtExceptionCaptureHandler } = require('playwright/lib/internal/worker');16setUncaughtExceptionCaptureHandler(() => {console.log('Hello World!')});17const { setUncaughtExceptionHandler } = require('playwright/lib/internal/worker');18setUncaughtExceptionHandler(() => {console.log('Hello World!')});19const { setUnhandledRejectionHandler } = require('playwright/lib/internal/worker');20setUnhandledRejectionHandler(() => {console.log('Hello World!')});21const { startCPUProfiler } = require('playwright/lib/internal/worker');22startCPUProfiler(() => {console.log('Hello World!')});

Full Screen

Using AI Code Generation

copy

Full Screen

1const {Page} = require('playwright');2const {queueJob} = require('playwright/lib/internal/queue');3const {waitWithTimeout} = require('playwright/lib/internal/utils');4const {helper} = require('playwright/lib/helper');5const page = new Page(null, null);6const job = queueJob(page, 'myJob', async (page, a, b) => {7 await waitWithTimeout(1000);8 console.log('job done');9 return a + b;10}, 1, 2);11job.promise.catch(e => console.log('job failed', e));12job.promise.then(result => console.log('job result', result));13helper.waitForEvent(page, 'close').then(() => {14 console.log('page closed');15 job.cancel();16});17const {Page} = require('playwright');18const {queueJob} = require('playwright/lib/internal/queue');19const {waitWithTimeout} = require('playwright/lib/internal/utils');20const {helper} = require('playwright/lib/helper');21const page = new Page(null, null);22const job = queueJob(page, 'myJob', async (page, a, b) => {23 await waitWithTimeout(1000);24 console.log('job done');25 return a + b;26}, 1, 2);27job.promise.catch(e => console.log('job failed', e));28job.promise.then(result => console.log('job result', result));29helper.waitForEvent(page, 'close').then(() => {30 console.log('page closed');31 job.cancel();32});33 at Object.pageClosedError (/Users/xxxxx/playwright/lib/helper.js:185:15)34 at Page._onClose (/Users/xxxxx/playwright/lib/page.js:100:26)35 at Page.emit (events.js:315:20)36 at CDPSession.Page._onClose (/Users/xxxxx/playwright/lib/page.js:89:36)37 at CDPSession.emit (events.js:315:20)38 at CDPSession._onMessage (/Users/xxxxx/playwright/lib/cjs/pw/protocol/protocol.js:113:14)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { queueJob } = require('@playwright/test/lib/workerRunner');2queueJob(() => {3 console.log('Running in worker');4});5console.log('Running in main process');6test('My test', async ({ test }) => {7 console.log('Running in main process');8 const { queueJob } = require('@playwright/test/lib/workerRunner');9 await queueJob(() => {10 console.log('Running in worker');11 });12 console.log('Running in main process');13});

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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