Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get data from Job ? #31

Closed
phucnguyen1605 opened this issue Jun 25, 2020 · 2 comments
Closed

Can't get data from Job ? #31

phucnguyen1605 opened this issue Jun 25, 2020 · 2 comments

Comments

@phucnguyen1605
Copy link

Hello
First of all, thanks for coding this provider.

In app/controllers/http, i have the following controller:

 'use strict'

const Bull = use('Rocketseat/Bull')
const RegisterDashboardJob = use('App/Jobs/RegisterDashboard')

class RegisterController {

  async store({ request, response }) {

    const data = {
      "companyName": "test",
      "firstName": "test",
      "lastName": "1",
      "telephone": "0349208926",
      "email": "test@gmail.com",
      "password": "123456",
      "productSelect": [],
      "posCategory": 1,
      "gender": 1,
      "username": "test@gmail.com",
      "name": "test account",
      "companyDomain": "test-46"
    }

    Bull.add(RegisterDashboardJob.key, data)

    return response.status(201).json({
      message: `Register job added to queue`
    })

  }

}

module.exports = RegisterController

In app/Jobs/RegisterDashboard i have the following:

'use strict'

const {
  createSyncDashboardDatabase,
} = use('App/Services/SyncDatabase')

const _ = use('lodash');
const Job = use('App/Models/v2/Job')
const {simpleStringify} = use('App/Helpers/Utils')

class RegisterDashboard {
  static get key () {
    return 'register-dashboard-job'
  }

  async handle (job) {
    const { data } = job

    let dataInsert = {
      'queue': RegisterDashboard.key,
      'payload': simpleStringify(data),
      'response': '',
      'email': data.email,
      'status': ''
    }

    await createSyncDashboardDatabase(data).then((dashboard) => {
      Job.create(dataInsert)
    }).catch(e => {
      dataInsert.response = simpleStringify(e)
      dataInsert.status = 500
      Job.create(dataInsert)
    })
  }
}

module.exports = RegisterDashboard

When debug Job data transmitted is no data that controller transmits.
Could you please help me? Maybe I'm missing something here...

Data from Job be like

{
  "name":"__default__",
  "_progress":0,
  "delay":0,
  "timestamp":1593077938333,
  "attemptsMade":0,
  "id":"27",
  "processedOn":1593077940335
}

Thanks

@HigoRibeiro
Copy link
Contributor

Hi @phucnguyen1605 !!
It seems ok.

I made the structure like as yours and it worked fine!

Did you open the bull board? Did you see anything stranger?

Captura de Tela 2020-07-17 às 14 49 55

@HigoRibeiro
Copy link
Contributor

Hey, I will close this issue for lack of current interactions. Feel free to open it again if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants