mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-21 21:49:51 +01:00
34 lines
707 B
Go
34 lines
707 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
)
|
||
|
|
||
|
func tokenFromTeamId(teamId int) (string, error) {
|
||
|
pgConn := getPGConn()
|
||
|
defer pgConn.Close(context.Background())
|
||
|
|
||
|
var token string
|
||
|
err := pgConn.QueryRow(context.Background(), "select api_token from posthog_team where id = $1;", teamId).Scan(&token)
|
||
|
|
||
|
if err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
|
||
|
return token, nil
|
||
|
}
|
||
|
|
||
|
func personFromDistinctId(distinctId string) (int, error) {
|
||
|
pgConn := getPGConn()
|
||
|
defer pgConn.Close(context.Background())
|
||
|
|
||
|
var personId int
|
||
|
err := pgConn.QueryRow(context.Background(), "select person_id from posthog_persondistinctid where distinct_id = $1;", distinctId).Scan(&personId)
|
||
|
|
||
|
if err != nil {
|
||
|
return 0, err
|
||
|
}
|
||
|
|
||
|
return personId, nil
|
||
|
}
|