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

function: LOC function implementation #798

Merged
merged 3 commits into from
Apr 23, 2019
Merged

function: LOC function implementation #798

merged 3 commits into from
Apr 23, 2019

Conversation

mcuadros
Copy link
Contributor

@mcuadros mcuadros commented Apr 17, 2019

This PR introduces the https://github.com/hhatto/gocloc through a new LOC function returning a JSON struct.

SELECT    
    LANGUAGE(file_path, blob_content) as lang,     
    SUM(JSON_EXTRACT(LOC(file_path, blob_content), '$.Code')) as code,  
    SUM(JSON_EXTRACT(LOC(file_path, blob_content), '$.Comments')) as comments,     
    SUM(JSON_EXTRACT(LOC(file_path, blob_content), '$.Blanks')) as blanks,    
    COUNT(1) as files 
FROM commit_files 
NATURAL JOIN refs 
NATURAL JOIN blobs 
WHERE ref_name='HEAD' 
GROUP BY lang;
+------+------+----------+--------+-------+
| lang | code | comments | blanks | files |
+------+------+----------+--------+-------+
| Markdown | 63763 |        0 |  24316 |   693 |
| YAML | 6033 |       91 |    788 |   229 |
| Text |    0 |        0 |      0 |   437 |
| Go   | 7444446 |   857226 | 638471 | 18639 |
|      |    0 |        0 |      0 |  1272 |
| Ignore List |    0 |        0 |      0 |   177 |
| TOML | 3616 |       37 |    512 |    32 |
| Dockerfile |    0 |        0 |      0 |    35 |
| C    | 1564 |      277 |    431 |    27 |
| Makefile | 5084 |     5544 |   1255 |   319 |
| Groovy |   61 |        0 |      0 |     1 |
| SQL  | 1198 |        0 |      6 |    46 |
| Protocol Buffer |    0 |        0 |      0 |   810 |
| JSON | 23245 |        0 |      0 |   223 |
| HTML | 14597 |      814 |   2390 |   116 |

Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
Copy link
Contributor

@ajnavarro ajnavarro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some examples into the documentation please?

Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
@ajnavarro ajnavarro merged commit 90b377c into src-d:master Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants