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

TotalTechGeek / pg-swag / 11942733536

20 Nov 2024 10:20PM UTC coverage: 94.749% (-2.2%) from 96.95%
11942733536

push

github

TotalTechGeek
Include the version bump

215 of 243 branches covered (88.48%)

Branch coverage included in aggregate %.

1048 of 1090 relevant lines covered (96.15%)

91594.37 hits per line

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

73.08
/sql/sqlite.js
1
import { deleteSingle, deleteQueue, flush, insert } from './postgres.js'
3✔
2
export { deleteSingle, deleteQueue, flush, insert }
3✔
3

3✔
4
export const fetchAndLock = `
3✔
5
update $1:name
3✔
6
set locked_until = datetime('now', $5), locked_by = $2, attempts = attempts + 1
3✔
7
where id in (
3✔
8
  select id
3✔
9
  from $1:name
3✔
10
  where queue = $3
3✔
11
  and locked_until <= datetime('now')
3✔
12
  limit $4
3✔
13
)
3✔
14
and queue = $3 and locked_until <= datetime('now')
3✔
15
returning *
3✔
16
`
3✔
17

3✔
18
export const heartbeat = 'update $1:name set locked_until = datetime(\'now\', $2) where id in ($3:csv) and queue = $4'
3✔
19

3✔
20
export const init = `
3✔
21
begin;
3✔
22
$2:line create schema if not exists $2:name;
3✔
23
create table if not exists $1:name (queue text, id text, run_at timestamptz, data jsonb, expression text, locked_until timestamptz, locked_by text, attempts int default 0);
3✔
24
drop index if exists idx_jobs_queue_run_at;
3✔
25
create index if not exists idx_jobs_queue_locked_until on $1:name (queue, locked_until);
3✔
26
create unique index if not exists idx_jobs_queue_id on $1:name (queue, id);
3✔
27
commit;
3✔
28
`
3✔
29

3✔
30
export const vacuumTest = ''
3✔
31

3✔
32
/**
3✔
33
 * @param {any} config
3✔
34
 * @param {any} schema
3✔
35
 * @returns
3✔
36
 */
3✔
37
export function connect (config, schema = null) {
3✔
38
  async function connect () {
×
39
    const sqlite = await import('better-sqlite3')
×
40
    const db = sqlite.default(config.file)
×
41
    return {
×
42
      query: s => db.prepare(s).all(),
×
43
      none: s => db.exec(s)
×
44
    }
×
45
  }
×
46
  const db = connect()
×
47
  return {
×
48
    query: async str => (await db).query(str),
×
49
    none: async str => (await db).none(str)
×
50
  }
×
51
}
×
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

© 2026 Coveralls, Inc