@@ -12,7 +12,22 @@ WHERE commits.commit_author_name = 'Javi Fontan' AND refs.ref_name='HEAD';
12
12
## Get all the HEAD references from all the repositories
13
13
14
14
``` sql
15
- SELECT * FROM refs WHERE ref_name = ' HEAD'
15
+ SELECT * FROM refs WHERE ref_name = ' HEAD' ;
16
+ ```
17
+
18
+ ## First commit on HEAD history for all repositories
19
+
20
+ ``` sql
21
+ SELECT
22
+ file_path,
23
+ ref_commits .repository_id
24
+ FROM
25
+ commit_files
26
+ NATURAL JOIN
27
+ ref_commits
28
+ WHERE
29
+ ref_commits .ref_name = ' HEAD'
30
+ AND ref_commits .index = 0 ;
16
31
```
17
32
18
33
## Commits that appear in more than one reference
@@ -24,7 +39,7 @@ SELECT * FROM (
24
39
INNER JOIN commits c
25
40
ON r .commit_hash = c .commit_hash
26
41
GROUP BY c .commit_hash
27
- ) t WHERE num > 1
42
+ ) t WHERE num > 1 ;
28
43
```
29
44
30
45
## Get the number of blobs per HEAD commit
@@ -36,7 +51,7 @@ INNER JOIN commits c
36
51
ON r .ref_name = ' HEAD' AND r .commit_hash = c .commit_hash
37
52
INNER JOIN commit_blobs cb
38
53
ON cb .commit_hash = c .commit_hash
39
- GROUP BY c .commit_hash
54
+ GROUP BY c .commit_hash ;
40
55
```
41
56
42
57
## Get commits per committer, per month in 2015
@@ -53,29 +68,61 @@ FROM (
53
68
ON YEAR(c .committer_when ) = 2015 AND r .commit_hash = c .commit_hash
54
69
WHERE r .ref_name = ' HEAD'
55
70
) as t
56
- GROUP BY committer_email, month, repo_id
71
+ GROUP BY committer_email, month, repo_id;
72
+ ```
73
+
74
+ ## Files from first 6 commits from HEAD references that contains some key and are not in vendor directory
75
+
76
+ ``` sql
77
+ select
78
+ files .file_path ,
79
+ ref_commits .repository_id ,
80
+ files .blob_content
81
+ FROM
82
+ files
83
+ NATURAL JOIN
84
+ commit_files
85
+ NATURAL JOIN
86
+ ref_commits
87
+ WHERE
88
+ ref_commits .ref_name = ' HEAD'
89
+ AND ref_commits .index BETWEEN 0 AND 5
90
+ AND is_binary(blob_content) = false
91
+ AND files .file_path NOT REGEXP ' ^vendor.*'
92
+ AND (
93
+ blob_content REGEXP ' (?i)facebook.*[\'\\ "][0-9a-f]{32}[\'\\ "]'
94
+ OR blob_content REGEXP ' (?i)twitter.*[\'\\ "][0-9a-zA-Z]{35,44}[\'\\ "]'
95
+ OR blob_content REGEXP ' (?i)github.*[\'\\ "][0-9a-zA-Z]{35,40}[\'\\ "]'
96
+ OR blob_content REGEXP ' AKIA[0-9A-Z]{16}'
97
+ OR blob_content REGEXP ' (?i)reddit.*[\'\\ "][0-9a-zA-Z]{14}[\'\\ "]'
98
+ OR blob_content REGEXP ' (?i)heroku.*[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}'
99
+ OR blob_content REGEXP ' .*-----BEGIN PRIVATE KEY-----.*'
100
+ OR blob_content REGEXP ' .*-----BEGIN RSA PRIVATE KEY-----.*'
101
+ OR blob_content REGEXP ' .*-----BEGIN DSA PRIVATE KEY-----.*'
102
+ OR blob_content REGEXP ' .*-----BEGIN OPENSSH PRIVATE KEY-----.*'
103
+ );
57
104
```
58
105
59
106
## Create an index for columns on a table
60
107
61
108
You can create an index either on a specific column or on several columns:
62
109
63
110
``` sql
64
- CREATE INDEX commits_hash_idx ON commits USING pilosa (commit_hash)
111
+ CREATE INDEX commits_hash_idx ON commits USING pilosa (commit_hash);
65
112
66
- CREATE INDEX files_commit_path_blob_idx ON commit_files USING pilosa (commit_hash, file_path, blob_hash)
113
+ CREATE INDEX files_commit_path_blob_idx ON commit_files USING pilosa (commit_hash, file_path, blob_hash);
67
114
```
68
115
69
116
## Create an index for an expression on a table
70
117
71
118
Note that just one expression at a time is allowed to be indexed.
72
119
73
120
``` sql
74
- CREATE INDEX files_lang_idx ON files USING pilosa (language(file_path, blob_content))
121
+ CREATE INDEX files_lang_idx ON files USING pilosa (language(file_path, blob_content));
75
122
```
76
123
77
124
## Drop a table's index
78
125
79
126
``` sql
80
- DROP INDEX files_lang_idx ON files
127
+ DROP INDEX files_lang_idx ON files;
81
128
```
0 commit comments