1- import timeDatabase from '../database/timer-database'
1+ import timerDatabase , { QueryParam } from '../database/timer-database'
22import whitelistDatabase from '../database/whitelist-database'
33
44/**
@@ -8,20 +8,37 @@ import whitelistDatabase from '../database/whitelist-database'
88class TimeService {
99
1010 public addTotal ( url : string , start : number ) {
11- this . notInWhitelistThen ( url , ( ) => timeDatabase . addTotal ( url , start ) )
11+ this . notInWhitelistThen ( url , ( ) => timerDatabase . addTotal ( url , start ) )
1212 }
1313
1414 public addFocusAndTotal ( url : string , focusStart : number , runStart : number ) {
15- this . notInWhitelistThen ( url , ( ) => timeDatabase . addFocusAndTotal ( url , focusStart , runStart ) )
15+ this . notInWhitelistThen ( url , ( ) => timerDatabase . addFocusAndTotal ( url , focusStart , runStart ) )
1616 }
1717
1818 public addOneTime ( url : string ) {
19- this . notInWhitelistThen ( url , ( ) => timeDatabase . addOneTime ( url ) )
19+ this . notInWhitelistThen ( url , ( ) => timerDatabase . addOneTime ( url ) )
2020 }
2121
2222 private notInWhitelistThen ( url : string , hook : ( ) => void ) {
2323 ! ! url && whitelistDatabase . includes ( url , include => ! include && hook ( ) )
2424 }
25+
26+ /**
27+ * Query domain names
28+ *
29+ * @param fuzzyQuery the part of domain name
30+ * @param callback callback
31+ * @since 0.0.8
32+ */
33+ public listDomains ( fuzzyQuery : string , callback : ( domains : Set < string > ) => void ) {
34+ const param : QueryParam = new QueryParam ( )
35+ param . host = fuzzyQuery
36+ timerDatabase . select ( rows => {
37+ const result : Set < string > = new Set ( )
38+ rows . forEach ( row => result . add ( row . host ) )
39+ callback ( result )
40+ } , param )
41+ }
2542}
2643
2744export default new TimeService ( )
0 commit comments