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

mozilla / blurts-server / #12818

pending completion
#12818

push

circleci

web-flow
Merge pull request #2911 from mozilla/MNTOR-1395

MNTOR-1395: Some benchmark tests for prod migration

282 of 1467 branches covered (19.22%)

Branch coverage included in aggregate %.

76 of 76 new or added lines in 3 files covered. (100.0%)

959 of 3992 relevant lines covered (24.02%)

2.0 hits per line

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

0.0
/src/scripts/prod-experiments/pullExperiment100.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 100
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 = 100 // with millions of records, we have to load a few at a time
×
16
let offset = 0 // looping through all records with offset
×
17
let subscribersArr = []
×
18

19
const startTime = Date.now()
×
20
console.log(`Start time is: ${startTime}`)
×
21

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

26
// find all subscribers who resolved any breaches in the past, convert those
27
// records into the new v2 format
28
do {
×
29
  console.log(`Converting breaches_resolved to breach_resolution - start: ${offset} limit: ${LIMIT}`)
×
30
  subscribersArr = await knex
×
31
    .select('id', 'primary_email', 'breaches_resolved', 'breach_resolution')
32
    .from('subscribers')
33
    .whereNotNull('breaches_resolved')
34
    .limit(LIMIT)
35
    .offset(offset)
36

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

39
  offset += LIMIT
×
40
} while (subscribersArr.length === LIMIT)
41

42
// breaking out of do..while loop
43
console.log('Reaching the end of the table, offset ended at', offset)
×
44
const endTime = Date.now()
×
45
console.log(`End time is: ${endTime}`)
×
46
console.log('Diff is: ', endTime - startTime)
×
47
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