Repos api
This commit is contained in:
+4
-4
@@ -1,13 +1,13 @@
|
||||
package db
|
||||
|
||||
type Contrib struct {
|
||||
Week int64 `json:"week"`
|
||||
Week uint64 `json:"week"`
|
||||
Author string `json:"author"`
|
||||
Owner string `json:"owner"`
|
||||
Repo string `json:"repo"`
|
||||
Commits int64 `json:"commits"`
|
||||
Additions int64 `json:"additions"`
|
||||
Deletions int64 `json:"deletions"`
|
||||
Commits uint64 `json:"commits"`
|
||||
Additions uint64 `json:"additions"`
|
||||
Deletions uint64 `json:"deletions"`
|
||||
}
|
||||
|
||||
const saveContribQuery = `
|
||||
|
||||
@@ -3,7 +3,7 @@ package db
|
||||
type Org struct {
|
||||
Login string `json:"login"`
|
||||
Descr string `json:"descr"`
|
||||
ID int64 `json:"id"`
|
||||
ID uint64 `json:"id"`
|
||||
AvatarURL string `json:"avatar_url"`
|
||||
}
|
||||
|
||||
|
||||
+23
-3
@@ -1,12 +1,32 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Repo struct {
|
||||
Owner string `json:"owner"`
|
||||
Name string `json:"name"`
|
||||
ID uint64 `json:"id"`
|
||||
Owner string `json:"owner"`
|
||||
Name string `json:"name"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
IsPrivate bool `json:"is_private"`
|
||||
IsForm bool `json:"is_fork"`
|
||||
}
|
||||
|
||||
const saveRepoQuery = `replace into repos (owner, name, updated_at) values (?, ?, now())`
|
||||
const orgReposQuery = `select * from repos where owner = ?`
|
||||
const saveRepoQuery = `
|
||||
insert into repos (owner, name, updated_at)
|
||||
values (?, ?, now())
|
||||
on duplicate key update
|
||||
updated_at=now()`
|
||||
|
||||
func (r *Repo) Save() {
|
||||
conn.MustExec(saveRepoQuery, r.Owner, r.Name)
|
||||
}
|
||||
|
||||
func OrgRepos(login string) (repos []*Repo) {
|
||||
if err := conn.Select(&repos, orgReposQuery, login); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package db
|
||||
|
||||
type Team struct {
|
||||
ID int64 `json:"id"`
|
||||
ID uint64 `json:"id"`
|
||||
Owner string `json:"owner"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
+3
-3
@@ -5,11 +5,11 @@ import (
|
||||
)
|
||||
|
||||
type Token struct {
|
||||
ID int64 `json:"id"`
|
||||
ID uint64 `json:"id"`
|
||||
User string `json:"user"`
|
||||
Token string `json:"token"`
|
||||
Quota int64 `json:"quota"`
|
||||
Remaining int64 `json:"remaining"`
|
||||
Quota uint64 `json:"quota"`
|
||||
Remaining uint64 `json:"remaining"`
|
||||
ResetAt time.Time `json:"reset_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package db
|
||||
type User struct {
|
||||
Login string `json:"login"`
|
||||
Name string `json:"name"`
|
||||
ID int64 `json:"id"`
|
||||
ID uint64 `json:"id"`
|
||||
AvatarURL string `json:"avatar_url"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user