cncf / devstats

📈CNCF-created tool for analyzing and graphing developer contributions
https://devstats.cncf.io
Apache License 2.0
61 stars 22 forks source link

[bug] API returning error #38

Closed cjyabraham closed 9 months ago

cjyabraham commented 9 months ago

We are calling the API to populate metrics on the CNCF homepage. Here is the code we use to call the API.

This is the main call:

$data = wp_remote_post(
                'https://devstats.cncf.io/api/v1',
                array(
                    'headers'     => array( 'Content-Type' => 'application/json; charset=utf-8' ),
                    'body'        => '{"api":"SiteStats","payload":{"project":"all"}}',
                    'method'      => 'POST',
                    'data_format' => 'body',
                )
            );

The error we're seeing is API 'SiteStats': pq: missing FROM-clause entry for table \"c\"

lukaszgryglicki commented 9 months ago

On it.

lukaszgryglicki commented 9 months ago

Fixed by: https://github.com/cncf/devstatscode/commit/997fbb199cb0fc76ee13aaaaec1fdfffe845306a - sorry for that issue.

Before the fix:

bash-3.2$ curl -H 'Content-Type: application/json; charset=utf-8' https://devstats.cncf.io/api/v1 -d'{"api":"SiteStats","payload":{"project":"all"}}'
{"error":"API 'SiteStats': pq: missing FROM-clause entry for table \"c\""}

After the fix:

bash-3.2$ curl -H 'Content-Type: application/json; charset=utf-8' https://devstats.cncf.io/api/v1 -d'{"api":"SiteStats","payload":{"project":"all"}}'
{"project":"all","db_name":"allprj","contributors":215976,"contributions":14631534,"boc":7702159995,"committers":49890,"commits":2425663,"events":22187509,"forkers":269981,"repositories":6316,"stargazers":0,"countries":190,"companies":16135}

cc @cjyabraham

cjyabraham commented 9 months ago

Great. Thanks!