Skip to content

Commit 000b15d

Browse files
committed
add cube gitbase docker-compose running
0 parents  commit 000b15d

20 files changed

+617
-0
lines changed

.env

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
REDIS_URL=redis://redis_db:6379/0
2+
CUBEJS_DB_HOST=gitbase
3+
CUBEJS_DB_NAME=gitbase
4+
CUBEJS_DB_USER=root
5+
CUBEJS_DB_TYPE=mysql
6+
CUBEJS_API_SECRET=f175c412a9136d6bf6cb84bc59c027f39cc93ae35887774ac3fe091bb0717a8d53409a967a1d2014988ef344e75214d48e0cd65c8b6c9403f8d0850a5545afdd

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
npm-debug.log

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# cube gitbase(mysql) docker-compose running
2+
3+
> with redis for cache

cube/.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
npm-debug.log
3+
.env
4+
schema

cube/Dockerfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM node:10-alpine
2+
LABEL AUTHOR="dalong"
3+
LABEL EMAIL="[email protected]"
4+
WORKDIR /usr/src/app
5+
COPY package*.json ./
6+
7+
RUN npm install
8+
9+
COPY . .
10+
11+
EXPOSE 4000

cube/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const CubejsServer = require('@cubejs-backend/server');
2+
3+
const server = new CubejsServer();
4+
5+
server.listen().then(({ port }) => {
6+
console.log(`🚀 Cube.js server is listening on ${port}`);
7+
});

cube/package.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "gitbase-demo",
3+
"version": "0.0.1",
4+
"private": true,
5+
"scripts": {
6+
"dev": "./node_modules/.bin/cubejs-dev-server"
7+
},
8+
"dependencies": {
9+
"@cubejs-backend/mysql-driver": "^0.9.2",
10+
"@cubejs-backend/server": "^0.9.2"
11+
}
12+
}

cube/schema/Blobs.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
cube(`Blobs`, {
2+
sql: `SELECT * FROM gitbase.blobs`,
3+
4+
joins: {
5+
Repositories: {
6+
sql: `${CUBE}.repository_id = ${Repositories}.repository_id`,
7+
relationship: `belongsTo`
8+
}
9+
},
10+
11+
measures: {
12+
count: {
13+
type: `count`,
14+
drillMembers: [repositoryId]
15+
}
16+
},
17+
18+
dimensions: {
19+
repositoryId: {
20+
sql: `repository_id`,
21+
type: `string`,
22+
primaryKey: true
23+
},
24+
repositoryId2: {
25+
sql: `repository_id`,
26+
type: `string`,
27+
},
28+
blobHash: {
29+
sql: `blob_hash`,
30+
type: `string`
31+
},
32+
33+
blobContent: {
34+
sql: `blob_content`,
35+
type: `string`
36+
}
37+
}
38+
});

cube/schema/CommitBlobs.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
cube(`CommitBlobs`, {
2+
sql: `SELECT * FROM gitbase.commit_blobs`,
3+
4+
joins: {
5+
Repositories: {
6+
sql: `${CUBE}.repository_id = ${Repositories}.repository_id`,
7+
relationship: `belongsTo`
8+
}
9+
},
10+
11+
measures: {
12+
count: {
13+
type: `count`,
14+
drillMembers: [repositoryId]
15+
}
16+
},
17+
18+
dimensions: {
19+
repositoryId: {
20+
sql: `repository_id`,
21+
type: `string`,
22+
primaryKey: true
23+
},
24+
repositoryId2: {
25+
sql: `repository_id`,
26+
type: `string`,
27+
},
28+
commitHash: {
29+
sql: `commit_hash`,
30+
type: `string`
31+
},
32+
33+
blobHash: {
34+
sql: `blob_hash`,
35+
type: `string`
36+
}
37+
}
38+
});

cube/schema/CommitFiles.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
cube(`CommitFiles`, {
2+
sql: `SELECT * FROM gitbase.commit_files`,
3+
4+
joins: {
5+
Repositories: {
6+
sql: `${CUBE}.repository_id = ${Repositories}.repository_id`,
7+
relationship: `belongsTo`
8+
}
9+
},
10+
11+
measures: {
12+
count: {
13+
type: `count`,
14+
drillMembers: [repositoryId]
15+
}
16+
},
17+
18+
dimensions: {
19+
repositoryId: {
20+
sql: `repository_id`,
21+
type: `string`,
22+
primaryKey: true
23+
},
24+
repositoryId2: {
25+
sql: `repository_id`,
26+
type: `string`,
27+
},
28+
commitHash: {
29+
sql: `commit_hash`,
30+
type: `string`
31+
},
32+
33+
filePath: {
34+
sql: `file_path`,
35+
type: `string`
36+
},
37+
38+
blobHash: {
39+
sql: `blob_hash`,
40+
type: `string`
41+
},
42+
43+
treeHash: {
44+
sql: `tree_hash`,
45+
type: `string`
46+
}
47+
}
48+
});

cube/schema/CommitTrees.js

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
cube(`CommitTrees`, {
2+
sql: `SELECT * FROM gitbase.commit_trees`,
3+
4+
joins: {
5+
Repositories: {
6+
sql: `${CUBE}.repository_id = ${Repositories}.repository_id`,
7+
relationship: `belongsTo`
8+
}
9+
},
10+
11+
measures: {
12+
count: {
13+
type: `count`,
14+
drillMembers: [repositoryId]
15+
}
16+
},
17+
18+
dimensions: {
19+
repositoryId: {
20+
sql: `repository_id`,
21+
type: `string`,
22+
primaryKey: true
23+
},
24+
repositoryId2: {
25+
sql: `repository_id`,
26+
type: `string`,
27+
},
28+
commitHash: {
29+
sql: `commit_hash`,
30+
type: `string`
31+
},
32+
33+
treeHash: {
34+
sql: `tree_hash`,
35+
type: `string`
36+
}
37+
}
38+
});

cube/schema/Commits.js

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
cube(`Commits`, {
2+
sql: `SELECT * FROM gitbase.commits`,
3+
4+
joins: {
5+
Repositories: {
6+
sql: `${CUBE}.repository_id = ${Repositories}.repository_id`,
7+
relationship: `belongsTo`
8+
}
9+
},
10+
11+
measures: {
12+
count: {
13+
type: `count`,
14+
drillMembers: [committerName, repositoryId, commitAuthorName]
15+
}
16+
},
17+
18+
dimensions: {
19+
committerName: {
20+
sql: `committer_name`,
21+
type: `string`
22+
},
23+
24+
repositoryId: {
25+
sql: `repository_id`,
26+
type: `string`,
27+
primaryKey: true
28+
},
29+
repositoryId2: {
30+
sql: `repository_id`,
31+
type: `string`,
32+
},
33+
commitAuthorName: {
34+
sql: `commit_author_name`,
35+
type: `string`
36+
},
37+
38+
commitAuthorEmail: {
39+
sql: `commit_author_email`,
40+
type: `string`
41+
},
42+
43+
commitHash: {
44+
sql: `commit_hash`,
45+
type: `string`
46+
},
47+
48+
committerEmail: {
49+
sql: `committer_email`,
50+
type: `string`
51+
},
52+
53+
commitMessage: {
54+
sql: `commit_message`,
55+
type: `string`
56+
},
57+
58+
treeHash: {
59+
sql: `tree_hash`,
60+
type: `string`
61+
},
62+
63+
commitParents: {
64+
sql: `commit_parents`,
65+
type: `string`
66+
},
67+
68+
commitAuthorWhen: {
69+
sql: `commit_author_when`,
70+
type: `time`
71+
},
72+
73+
committerWhen: {
74+
sql: `committer_when`,
75+
type: `time`
76+
}
77+
}
78+
});

cube/schema/Committer-Repos.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
cube(`CommitterRepos`, {
2+
sql: `SELECT
3+
SUM(JSON_EXTRACT(LOC(file_path, blob_content), '$.code')) as code,
4+
SUM(JSON_EXTRACT(LOC(file_path, blob_content), '$.comment')) as comments,
5+
SUM(JSON_EXTRACT(LOC(file_path, blob_content), '$.blank')) as blanks,
6+
COUNT(1) as files,
7+
commit_author_email,
8+
repository_id
9+
FROM commit_files
10+
NATURAL JOIN refs
11+
NATURAL JOIN blobs
12+
NATURAL JOIN commits
13+
WHERE ref_name='HEAD'
14+
GROUP BY repository_id,commit_author_email`,
15+
dimensions: {
16+
repositoryId: {
17+
sql: `repository_id`,
18+
type: `string`,
19+
primaryKey: true
20+
},
21+
repositoryId2: {
22+
sql: `repository_id`,
23+
type: `string`
24+
},
25+
commit_author_email: {
26+
sql: `commit_author_email`,
27+
type: `string`,
28+
},
29+
files: {
30+
sql: `files`,
31+
type: `string`
32+
},
33+
34+
blanks: {
35+
sql: `blanks`,
36+
type: `string`
37+
},
38+
comments: {
39+
sql: `comments`,
40+
type: `string`
41+
},
42+
code: {
43+
sql: `code`,
44+
type: `string`
45+
}
46+
}
47+
});
48+

0 commit comments

Comments
 (0)