Skip to content

Commit 339e8a9

Browse files
author
Juanjo Alvarez
committed
Blame: added examples
Signed-off-by: Juanjo Alvarez <[email protected]>
1 parent 9732c68 commit 339e8a9

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

docs/using-gitbase/examples.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,41 @@ The output will be similar to this:
200200
+-----------------+--------------------------------------+---------------+------------------+--------------------+
201201
```
202202

203+
## Get miscelaneous information about lines with a "// TODO" comment in HEAD
204+
205+
```sql
206+
SELECT repository_id,
207+
JSON_UNQUOTE(JSON_EXTRACT(bl, "$.commit")),
208+
JSON_UNQUOTE(JSON_EXTRACT(bl, "$.file")),
209+
JSON_UNQUOTE(JSON_EXTRACT(bl, "$.linenum")),
210+
JSON_UNQUOTE(JSON_EXTRACT(bl, "$.author")),
211+
JSON_UNQUOTE(JSON_EXTRACT(bl, "$.text"))
212+
FROM (SELECT repository_id,
213+
EXPLODE(BLAME(repository_id, commit_hash)) AS bl
214+
FROM ref_commits
215+
NATURAL JOIN blobs
216+
WHERE ref_name = 'HEAD'
217+
AND NOT IS_BINARY(blob_content)
218+
) as p
219+
WHERE JSON_EXTRACT(bl, "$.text") LIKE '%// TODO%';
220+
```
221+
222+
## Report of authors with more lines authored in HEAD
223+
224+
```sql
225+
SELECT
226+
JSON_UNQUOTE(JSON_EXTRACT(bl, "$.author")),
227+
COUNT(JSON_UNQUOTE(JSON_EXTRACT(bl, "$.author")))
228+
229+
FROM (SELECT EXPLODE(BLAME(repository_id, commit_hash)) AS bl
230+
FROM ref_commits
231+
NATURAL JOIN blobs
232+
WHERE ref_name = 'HEAD'
233+
AND NOT IS_BINARY(blob_content)
234+
) AS p
235+
GROUP BY JSON_UNQUOTE(JSON_EXTRACT(bl, "$.author"));
236+
```
237+
203238
# UAST UDFs Examples
204239

205240
First of all, you should check out the [bblfsh documentation](https://docs.sourced.tech/babelfish) to get yourself familiar with UAST concepts.

0 commit comments

Comments
 (0)