Skip to content

Commit 9c7b02f

Browse files
author
kuba--
committed
Add regression queries.
Signed-off-by: kuba-- <[email protected]>
1 parent ba04fe0 commit 9c7b02f

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed

_testdata/regression.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
-
2+
ID: '0.16.0-0'
3+
Name: 'All commits'
4+
Statements:
5+
- SELECT * FROM commits
6+
-
7+
ID: '0.16.0-1'
8+
Name: 'Last commit messages in HEAD for every repository'
9+
Statements:
10+
- SELECT c.commit_message FROM refs rJOIN commits c ON r.commit_hash = c.commit_hashWHEREr.ref_name = 'HEAD'
11+
-
12+
ID: '0.16.0-2'
13+
Name: 'All commit messages in HEAD history for every repository'
14+
Statements:
15+
- SELECT c.commit_message FROM commits cNATURAL JOIN ref_commits rWHERE r.ref_name = 'HEAD'
16+
-
17+
ID: '0.16.0-3'
18+
Name: 'Top 10 repositories by commit count in HEAD'
19+
Statements:
20+
- SELECT repository_id,commit_count FROM (SELECT r.repository_id,count(*) AS commit_count FROM ref_commits r WHERE r.ref_name = 'HEAD' GROUP BY r.repository_id) AS q ORDER BY commit_count DESC LIMIT 10
21+
-
22+
ID: '0.16.0-4'
23+
Name: 'Top 10 repositories by contributor count (all branches)'
24+
Statements:
25+
- SELECT repository_id,contributor_count FROM (SELECT repository_id, COUNT(DISTINCT commit_author_email) AS contributor_count FROM commits GROUP BY repository_id) AS q ORDER BY contributor_count DESC LIMIT 10
26+
-
27+
ID: '0.16.0-5'
28+
Name: 'Create pilosa index on language UDF'
29+
Statements:
30+
- CREATE INDEX language_idx ON files USING pilosa (language(file_path, blob_content)) WITH (async = false)
31+
-
32+
ID: '0.16.0-6'
33+
Name: 'Create pilosalib index on language UDF'
34+
Statements:
35+
- CREATE INDEX language_idx ON files USING pilosalib (language(file_path, blob_content)) WITH (async = false)
36+
-
37+
ID: '0.16.0-7'
38+
Name: 'Query by language using the pilosa index'
39+
Statements:
40+
- CREATE INDEX language_idx ON files USING pilosa (language(file_path, blob_content)) WITH (async = false)
41+
- SELECT file_path FROM files WHERE language(file_path, blob_content) = 'Go'
42+
- DROP INDEX language_idx ON files
43+
-
44+
ID: '0.16.0-8'
45+
Name: 'Query by language using the pilosalib index'
46+
Statements:
47+
- CREATE INDEX language_idx ON files USING pilosalib (language(file_path, blob_content)) WITH (async = false)
48+
- SELECT file_path FROM files WHERE language(file_path, blob_content) = 'Go'
49+
- DROP INDEX language_idx ON files
50+
-
51+
ID: '0.16.0-9'
52+
Name: 'Query all files from HEAD'
53+
Statements:
54+
- SELECT cf.file_path, f.blob_content FROM ref_commits r NATURAL JOIN commit_files cf NATURAL JOIN files f WHERE r.ref_name = 'HEAD' AND r.index = 0
55+
-
56+
ID: '0.16.0-10'
57+
Name: 'Get all LICENSE blobs using pilosa index'
58+
Statements:
59+
- CREATE INDEX file_path_idx ON files USING pilosa (file_path) WITH (async = false)
60+
- SELECT blob_content FROM files WHERE file_path = 'LICENSE'
61+
-
62+
ID: '0.16.0-11'
63+
Name: 'Get all LICENSE blobs using pilosalib index'
64+
Statements:
65+
- CREATE INDEX file_path_idx ON files USING pilosalib (file_path) WITH (async = false)
66+
- SELECT blob_content FROM files WHERE file_path = 'LICENSE'
67+
-
68+
ID: '0.16.0-12'
69+
Name: '10 top repos by file count in HEAD'
70+
Statements:
71+
- SELECT repository_id, num_files FROM (SELECT COUNT(f.*) num_files, f.repository_id FROM ref_commits r INNER JOIN commit_files cf ON r.commit_hash = cf.commit_hash AND r.repository_id = cf.repository_id INNER JOIN files fON cf.repository_id = f.repository_id AND cf.blob_hash = f.blob_hash AND cf.tree_hash = f.tree_hash AND cf.file_path = f.file_path WHERE r.ref_name = 'HEAD' GROUP BY f.repository_id) t ORDER BY num_files DESC LIMIT 10
72+
-
73+
ID: '0.16.0-13'
74+
Name: 'Top committers per repository'
75+
Statements:
76+
- SELECT * FROM (SELECT commit_author_email as author,repository_id as id,count(*) as num_commits FROM commits GROUP BY commit_author_email, repository_id) t ORDER BY num_commits DESC"
77+
-
78+
ID: '0.16.0-14'
79+
Name: 'Top committers in all repositories'
80+
Statements:
81+
- SELECT * FROM (SELECT commit_author_email as author,count(*) as num_commits FROM commits GROUP BY commit_author_email) t ORDER BY num_commits DESC
82+
-
83+
ID: '0.16.0-15'
84+
Name: 'Union operation with pilosa index'
85+
Statements:
86+
- CREATE INDEX file_path_idx ON files USING pilosa (file_path) WITH (async = false)
87+
- SELECT blob_content FROM files WHERE file_path = 'LICENSE' OR file_path = 'README.md'
88+
- DROP INDEX file_path_idx ON files
89+
-
90+
ID: '0.16.0-16'
91+
Name: 'Union operation with pilosalib index'
92+
Statements:
93+
- CREATE INDEX file_path_idx ON files USING pilosalib (file_path) WITH (async = false)
94+
- SELECT blob_content FROM files WHERE file_path = 'LICENSE' OR file_path = 'README.md'
95+
- DROP INDEX file_path_idx ON files
96+
-
97+
ID: '0.16.0-17'
98+
Name: 'Count all commits with NOT operation'
99+
Statements:
100+
- SELECT COUNT(*) FROM commits WHERE NOT(commit_author_email = 'non existing email address');
101+
-
102+
ID: '0.16.0-18'
103+
Name: 'Count all commits with NOT operation and pilosalib index'
104+
Statements:
105+
- CREATE INDEX email_idx ON commits USING pilosalib (commit_author_email) WITH (async = false)
106+
- SELECT COUNT(*) FROM commits WHERE NOT(commit_author_email = 'non existing email address')
107+
- DROP INDEX email_idx ON commits

cmd/gitbase/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"fmt"
45
"os"
56

67
"github.com/src-d/gitbase/cmd/gitbase/command"
@@ -17,6 +18,16 @@ var (
1718

1819
func main() {
1920
parser := flags.NewNamedParser(name, flags.Default)
21+
parser.UnknownOptionHandler = func(option string, arg flags.SplitArgument, args []string) ([]string, error) {
22+
if "g" != option {
23+
return nil, fmt.Errorf("unknown flag `%s'", option)
24+
}
25+
if len(args) == 0 {
26+
return nil, fmt.Errorf("unknown flag `%s'", option)
27+
}
28+
29+
return append(append(args, "-d"), args[0]), nil
30+
}
2031

2132
_, err := parser.AddCommand("server", command.ServerDescription, command.ServerHelp,
2233
&command.Server{

0 commit comments

Comments
 (0)