• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / blurts-server / 6114f23b-7380-4043-a832-7483bb4ee902

pending completion
6114f23b-7380-4043-a832-7483bb4ee902

push

circleci

Joey Zhou
Merge branch 'main' into MNTOR-1356

282 of 1601 branches covered (17.61%)

Branch coverage included in aggregate %.

433 of 433 new or added lines in 31 files covered. (100.0%)

959 of 4327 relevant lines covered (22.16%)

3.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/scripts/prod-experiments/pullExperiment1000.js
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4

5
/**
6
 * Executes once
7
 * The purpose of the script is to benchmark pure read with limit set as 1000
8
 */
9

10
import Knex from 'knex'
11
import knexConfig from '../../db/knexfile.js'
12
import { getAllBreachesFromDb } from '../../utils/hibp.js'
13
const knex = Knex(knexConfig)
×
14

15
const LIMIT = 1000 // with millions of records, we have to load a few at a time
×
16
let CAP = 1500000
×
17
if (process.argv.length > 2) {
×
18
  CAP = process.argv[2]
×
19
  console.log('using cap passed in: ', CAP)
×
20
}
21
let offset = 0 // looping through all records with offset
×
22
let subscribersArr = []
×
23

24
// load all breaches for ref
25
const allBreaches = await getAllBreachesFromDb()
×
26
if (allBreaches && allBreaches.length > 0) console.log('breaches loaded successfully! ', allBreaches.length)
×
27

28
const startTime = Date.now()
×
29
console.log(`Start time is: ${startTime}`)
×
30
do {
×
31
  console.log(`Converting breaches_resolved to breach_resolution - start: ${offset} limit: ${LIMIT}`)
×
32
  subscribersArr = await knex
×
33
    .select('id', 'primary_email', 'breaches_resolved', 'breach_resolution')
34
    .from('subscribers')
35
    .whereNotNull('breaches_resolved')
36
    .limit(LIMIT)
37
    .offset(offset)
38
    .orderBy('updated_at', 'desc')
39

40
  console.log(`Loaded # of subscribers: ${subscribersArr.length}`)
×
41

42
  offset += LIMIT
×
43
} while (subscribersArr.length === LIMIT && offset <= CAP)
×
44

45
// breaking out of do..while loop
46
console.log('Reaching the end of the table, offset ended at', offset)
×
47
const endTime = Date.now()
×
48
console.log(`End time is: ${endTime}`)
×
49
console.log('Diff is: ', endTime - startTime)
×
50
process.exit()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc