Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor repository #149

Merged
merged 59 commits into from
Aug 2, 2020
Merged
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
3c82f2f
fix: nits
h13i32maru Jul 31, 2020
238bfc2
refactor(StreamRepo):
h13i32maru Jul 31, 2020
138cd93
refactor(StreamRepo):
h13i32maru Jul 31, 2020
7dfa9c6
refactor(StreamRepo):
h13i32maru Aug 1, 2020
adcbd23
refactor(StreamRepo):
h13i32maru Aug 1, 2020
2bad1d3
refactor(StreamRepo):
h13i32maru Aug 1, 2020
50c1584
refactor(StreamRepo):
h13i32maru Aug 1, 2020
dc07165
refactor(StreamRepo):
h13i32maru Aug 1, 2020
1ca4bf6
refactor(StreamRepo):
h13i32maru Aug 1, 2020
c88fea0
refactor(StreamRepo):
h13i32maru Aug 1, 2020
f5081be
refactor(StreamRepo):
h13i32maru Aug 1, 2020
e57bb00
refactor(StreamRepo):
h13i32maru Aug 1, 2020
eb726e5
refactor(StreamRepo):
h13i32maru Aug 1, 2020
ae12f7d
refactor(StreamRepo):
h13i32maru Aug 1, 2020
ca4b6bb
refactor(StreamRepo):
h13i32maru Aug 1, 2020
c6c26fd
refactor(FilterHistoryRepo):
h13i32maru Aug 1, 2020
9c37bed
refactor(FilterHistoryRepo):
h13i32maru Aug 1, 2020
0df5a99
refactor(StreamRepo):
h13i32maru Aug 1, 2020
de9adf3
refactor(StreamIssueRepo):
h13i32maru Aug 1, 2020
498447d
refactor:
h13i32maru Aug 1, 2020
67f7e7c
refactor(StreamIssueRepo):
h13i32maru Aug 1, 2020
5d17553
refactor(StreamIssueRepo):
h13i32maru Aug 1, 2020
a9e1f5e
refactor(SubscriptionIssueRepo):
h13i32maru Aug 1, 2020
c9496ac
refactor(SystemStreamRepo):
h13i32maru Aug 1, 2020
1ff6872
refactor(SystemStreamRepo):
h13i32maru Aug 1, 2020
933087b
refactor(SystemStreamRepo):
h13i32maru Aug 1, 2020
c3eee22
fix(Stream): query index calc
h13i32maru Aug 1, 2020
2e76678
refactor(SystemStreamRepo):
h13i32maru Aug 1, 2020
8a9af6d
refactor(SystemStreamRepo):
h13i32maru Aug 1, 2020
5b4678d
refactor(SystemStreamRepo):
h13i32maru Aug 1, 2020
be72387
refactor(SystemStreamRepo):
h13i32maru Aug 1, 2020
54b1f49
refactor(StreamPolling):
h13i32maru Aug 1, 2020
8bb448b
refactor(SystemStreamRepo):
h13i32maru Aug 1, 2020
9d10f56
refactor(SystemStreamRepo):
h13i32maru Aug 1, 2020
e135662
refactor(IssueRepo):
h13i32maru Aug 1, 2020
efceb1f
refactor(IssueRepo):
h13i32maru Aug 1, 2020
4e4059d
refactor(IssueRepo):
h13i32maru Aug 1, 2020
2b7e4ce
refactor(IssueRepo):
h13i32maru Aug 1, 2020
30f82e5
refactor(IssueRepo):
h13i32maru Aug 1, 2020
8d245b9
refactor(IssueRepo):
h13i32maru Aug 1, 2020
f0d0d98
refactor(IssueRepo):
h13i32maru Aug 1, 2020
0730d1e
refactor(IssueRepo):
h13i32maru Aug 1, 2020
457a361
refactor(IssueRepo):
h13i32maru Aug 1, 2020
59168df
refactor(VersionRepo):
h13i32maru Aug 1, 2020
8e2c123
refactor(IssueRepo):
h13i32maru Aug 1, 2020
3d9d5d6
refactor(IssueRepo):
h13i32maru Aug 1, 2020
19e50f8
refactor(IssueRepo):
h13i32maru Aug 1, 2020
bff9d34
refactor(IssueRepo):
h13i32maru Aug 1, 2020
b44e56c
refactor: nits
h13i32maru Aug 2, 2020
cab2570
refactor(IssueRepo):
h13i32maru Aug 2, 2020
8bcf72c
refactor(IssueRepo):
h13i32maru Aug 2, 2020
5166b9f
refactor(IssueRepo):
h13i32maru Aug 2, 2020
c0852ca
refactor(IssueRepo):
h13i32maru Aug 2, 2020
d71e3e7
refactor(IssueRepo):
h13i32maru Aug 2, 2020
eedb2d0
refactor(IssueRepo):
h13i32maru Aug 2, 2020
e45dc8d
refactor(StreamIssueRepo):
h13i32maru Aug 2, 2020
992dac7
refactor(DBIPC): show slow query
h13i32maru Aug 2, 2020
13aa0f8
refactor(Repo):
h13i32maru Aug 2, 2020
f9e5f9a
refactor(IssueRepo):
h13i32maru Aug 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(DBIPC): show slow query
  • Loading branch information
h13i32maru committed Aug 2, 2020
commit 992dac72d37b59d4c9d7eaa1d24a76ecbc0eea0e
32 changes: 24 additions & 8 deletions src/IPC/DBIPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ type SQLRowReturn<T> = {
};

class _DBIPC {
private log: boolean = false;

// exec
async exec(sql: SQLParams['sql'], params?: SQLParams['params']): Promise<SQLRunReturn> {
if (this.log) console.log(sql, params);
const p: SQLParams = {sql, params};
return ipcRenderer.invoke(ChannelNames.exec, p);
const t = Date.now();
const res = await ipcRenderer.invoke(ChannelNames.exec, p);
this.showLog(t, sql, params);
return res;
}

onExec(handler: (_ev, params: SQLParams) => Promise<SQLRunReturn>) {
Expand All @@ -43,9 +43,11 @@ class _DBIPC {

// select
async select<T = any>(sql: SQLParams['sql'], params?: SQLParams['params']): Promise<SQLRowsReturn<T>> {
if (this.log) console.log(sql, params);
const p: SQLParams = {sql, params};
return ipcRenderer.invoke(ChannelNames.select, p);
const t = Date.now();
const res = await ipcRenderer.invoke(ChannelNames.select, p);
this.showLog(t, sql, params);
return res;
}

onSelect(handler: (_ev, params: SQLParams) => Promise<SQLRowsReturn<any>>) {
Expand All @@ -54,9 +56,11 @@ class _DBIPC {

// selectSingle
async selectSingle<T = any>(sql: SQLParams['sql'], params?: SQLParams['params']): Promise<SQLRowReturn<T>> {
if (this.log) console.log(sql, params);
const p: SQLParams = {sql, params};
return ipcRenderer.invoke(ChannelNames.selectSingle, p);
const t = Date.now();
const res = await ipcRenderer.invoke(ChannelNames.selectSingle, p);
this.showLog(t, sql, params);
return res;
}

onSelectSingle(handler: (_ev, params: SQLParams) => Promise<SQLRowReturn<any>>) {
Expand All @@ -71,6 +75,18 @@ class _DBIPC {
onInit(handler: (_ev, configIndex: number) => Promise<void>) {
ipcMain.handle(ChannelNames.init, handler);
}

private showLog(startTime: number, sql: SQLParams['sql'], params: SQLParams['params']) {
const isDev = process.env.JASPER === 'DEV';
if (!isDev) return;

const time = Date.now() - startTime;
if (time > 33) {
console.debug(`<span style="color: red">slow query ${time}</span>`, sql, params);
} else {
console.debug(time, sql, params);
}
}
}

export const DBIPC = new _DBIPC();