Permalink
Browse files

fix(scripts): fix lint errors in marketing scripts

#78
r=vbudhram
  • Loading branch information...
philbooth committed Dec 21, 2018
1 parent 0182b37 commit 29ec30a532e749abebe25946b171c84ea07da02d
Showing with 515 additions and 580 deletions.
  1. +3 −0 .eslintrc
  2. +7 −3 bin/marketing-localfs.js
  3. +10 −6 bin/marketing-sqs.js
  4. +7 −7 marketing.js
  5. +486 −562 package-lock.json
  6. +2 −2 package.json
@@ -1,3 +1,6 @@
parserOptions:
ecmaVersion: 2018

plugins:
- fxa

@@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

'use strict'

const fs = require('fs')
@@ -9,10 +13,10 @@ if (process.argv.length !== 3) {
process.exit(1)
}

const main = async () => {
main()

async function main () {
const local_file_stream = fs.createReadStream(process.argv[2])

await marketing.processStream(local_file_stream)
}

main()
@@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

'use strict'

const AWS = require('aws-sdk')
@@ -8,24 +12,26 @@ const marketing = require('../marketing')

const queue_url = process.env.SQS_QUEUE_URL

const main = async () => {
main()

async function main () {
console.log(`Fetching message from ${queue_url}`)
const messages = await SQS.receiveMessage({
MaxNumberOfMessages: 1,
QueueUrl: queue_url,
WaitTimeSeconds: 20
}).promise()

if (!messages.Messages) {
if (! messages.Messages) {
return console.log('No messages in queue')
}

for (const message of messages.Messages) {
const receipt_handle = message.ReceiptHandle
const s3_notification = JSON.parse(message.Body)

if (!s3_notification.Records) {
break;
if (! s3_notification.Records) {
break
}

for (const s3_object of s3_notification.Records) {
@@ -49,5 +55,3 @@ const main = async () => {
}
}
}

main()
@@ -1,13 +1,13 @@
'use strict'

const async = require('async')
const AutoDetectDecoderStream = require('autodetect-decoder-stream')
const crypto = require('crypto')
const csv = require('csv-parser')
const { lookup } = require('lookup-dns-cache')
const moment = require('moment-timezone')
const Promise = require('bluebird')
const request = require('request-promise')
const moment = require('moment-timezone')
const { lookup } = require('lookup-dns-cache')
const async = require('async');

const EVENT = /^mktg-([a-z]+-[a-z]+)$/

@@ -22,15 +22,15 @@ if (! HMAC_KEY || ! API_KEY) {
}

module.exports.processStream = function processStream (stream) {
let eventCount = 0, batch = [], error
let eventCount = 0

let cargo = async.cargo(async (tasks, callback) => {
const cargo = async.cargo(async (tasks, callback) => {
await send(tasks)
callback()
}, MAX_EVENTS_PER_BATCH)
cargo.concurrency = WORKERS

return new Promise((resolve, reject) => {
return new Promise(resolve => {
cargo.drain = () => {
resolve(eventCount)
}
@@ -51,7 +51,7 @@ module.exports.processStream = function processStream (stream) {
async function send (localBatch) {
const body = await sendBatch(localBatch)

if (body == "success") {
if (body === 'success') {
eventCount += localBatch.length
} else {
console.log(body)
Oops, something went wrong.

0 comments on commit 29ec30a

Please sign in to comment.