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

bandantonio / obsidian-apple-books-highlights-plugin / 21190337405

20 Jan 2026 10:55PM UTC coverage: 71.753%. Remained the same
21190337405

push

github

bandantonio
refactor: add debug timers

78 of 85 branches covered (91.76%)

Branch coverage included in aggregate %.

88 of 184 new or added lines in 8 files covered. (47.83%)

17 existing lines in 3 files now uncovered.

364 of 531 relevant lines covered (68.55%)

8.04 hits per line

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

80.49
/src/services/dataService.ts
1
import { annotationsRequest, dbRequest } from '../db';
1✔
2
import {
3
  BOOKS_DB_PATH,
4
  BOOKS_LIBRARY_COLUMNS,
5
  BOOKS_LIBRARY_NAME,
6
  HIGHLIGHTS_DB_PATH,
7
  HIGHLIGHTS_LIBRARY_COLUMNS,
8
  HIGHLIGHTS_LIBRARY_NAME,
9
} from '../db/constants';
10
import type { IBook, IBookAnnotation, IDataService } from '../types';
11
import type { DiagnosticsCollector } from '../utils/diagnostics';
12
import { Timer } from '../utils/timing';
13

14
export class DataService implements IDataService {
1✔
15
  private diagnosticsCollector?: DiagnosticsCollector;
16

17
  constructor(diagnosticsCollector?: DiagnosticsCollector) {
1✔
18
    this.diagnosticsCollector = diagnosticsCollector;
27✔
19
  }
27✔
20

21
  async getBooks(): Promise<IBook[]> {
1✔
22
    const timer = new Timer('DataService.getBooks', this.diagnosticsCollector);
4✔
23
    timer.start();
4✔
24
    try {
4✔
25
      const bookDetails = (await dbRequest(
4✔
26
        BOOKS_DB_PATH,
4✔
27
        `SELECT ${BOOKS_LIBRARY_COLUMNS.join(', ')} FROM ${BOOKS_LIBRARY_NAME} WHERE ZPURCHASEDATE IS NOT NULL`,
4✔
28
      )) as IBook[];
4✔
29
      timer.end();
4✔
30
      return bookDetails;
4✔
31
    } catch (error) {
4!
NEW
32
      timer.end();
×
UNCOV
33
      throw new Error(`Failed to fetch books: ${error}`);
×
UNCOV
34
    }
×
35
  }
4✔
36

37
  async getAnnotations(): Promise<IBookAnnotation[]> {
1✔
38
    const timer = new Timer('DataService.getAnnotations', this.diagnosticsCollector);
4✔
39
    timer.start();
4✔
40
    try {
4✔
41
      const annotationDetails = (await annotationsRequest(
4✔
42
        HIGHLIGHTS_DB_PATH,
4✔
43
        `SELECT ${HIGHLIGHTS_LIBRARY_COLUMNS.join(', ')} FROM ${HIGHLIGHTS_LIBRARY_NAME} WHERE ZANNOTATIONDELETED IS 0 AND ZANNOTATIONSELECTEDTEXT IS NOT NULL`,
4✔
44
      )) as IBookAnnotation[];
4✔
45
      timer.end();
4✔
46
      return annotationDetails;
4✔
47
    } catch (error) {
4!
NEW
48
      timer.end();
×
49
      throw new Error(`Failed to fetch annotations: ${error}`);
×
50
    }
×
51
  }
4✔
52
}
1✔
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