new css, ability to query any repo for watch items
This commit is contained in:
parent
c68076859a
commit
7a3cf08dcf
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -56,5 +56,6 @@ type WatchItem struct {
|
||||
OwnerID int64 `json:"owner_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
Name string `json:"name"`
|
||||
Repo string `json:"repo"`
|
||||
Descr sql.NullString `json:"descr"`
|
||||
}
|
||||
|
@ -146,24 +146,31 @@ func (q *Queries) AddPullRequestIgnore(ctx context.Context, arg AddPullRequestIg
|
||||
}
|
||||
|
||||
const addWatchItem = `-- name: AddWatchItem :one
|
||||
insert into watch_items (owner_id, name, descr)
|
||||
values (?, ?, ?) returning id, owner_id, created_at, name, descr
|
||||
insert into watch_items (owner_id, name, repo, descr)
|
||||
values (?, ?, ?, ?) returning id, owner_id, created_at, name, repo, descr
|
||||
`
|
||||
|
||||
type AddWatchItemParams struct {
|
||||
OwnerID int64 `json:"owner_id"`
|
||||
Name string `json:"name"`
|
||||
Repo string `json:"repo"`
|
||||
Descr sql.NullString `json:"descr"`
|
||||
}
|
||||
|
||||
func (q *Queries) AddWatchItem(ctx context.Context, arg AddWatchItemParams) (WatchItem, error) {
|
||||
row := q.db.QueryRowContext(ctx, addWatchItem, arg.OwnerID, arg.Name, arg.Descr)
|
||||
row := q.db.QueryRowContext(ctx, addWatchItem,
|
||||
arg.OwnerID,
|
||||
arg.Name,
|
||||
arg.Repo,
|
||||
arg.Descr,
|
||||
)
|
||||
var i WatchItem
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.OwnerID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Repo,
|
||||
&i.Descr,
|
||||
)
|
||||
return i, err
|
||||
@ -364,7 +371,7 @@ func (q *Queries) GetAllPullRequests(ctx context.Context, arg GetAllPullRequests
|
||||
}
|
||||
|
||||
const getAllWatchItems = `-- name: GetAllWatchItems :many
|
||||
select id, owner_id, created_at, name, descr
|
||||
select id, owner_id, created_at, name, repo, descr
|
||||
from watch_items
|
||||
`
|
||||
|
||||
@ -382,6 +389,7 @@ func (q *Queries) GetAllWatchItems(ctx context.Context) ([]WatchItem, error) {
|
||||
&i.OwnerID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Repo,
|
||||
&i.Descr,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
@ -398,7 +406,7 @@ func (q *Queries) GetAllWatchItems(ctx context.Context) ([]WatchItem, error) {
|
||||
}
|
||||
|
||||
const getAllWatchItemsByOwner = `-- name: GetAllWatchItemsByOwner :many
|
||||
select id, owner_id, created_at, name, descr
|
||||
select id, owner_id, created_at, name, repo, descr
|
||||
from watch_items
|
||||
where owner_id = ?
|
||||
`
|
||||
@ -417,6 +425,7 @@ func (q *Queries) GetAllWatchItemsByOwner(ctx context.Context, ownerID int64) ([
|
||||
&i.OwnerID,
|
||||
&i.CreatedAt,
|
||||
&i.Name,
|
||||
&i.Repo,
|
||||
&i.Descr,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
|
6
page.go
6
page.go
@ -18,7 +18,7 @@ const gqEndPoint = "https://api.github.com/graphql"
|
||||
const graphQuery = `
|
||||
{
|
||||
search(
|
||||
query: "is:open is:public archived:false repo:nixos/nixpkgs in:title %s",
|
||||
query: "is:open is:public archived:false repo:%s in:title %s",
|
||||
type: ISSUE,
|
||||
first: 20
|
||||
) {
|
||||
@ -144,7 +144,7 @@ func (w *WatchResults) Update(ghToken string) error {
|
||||
}
|
||||
|
||||
for _, watch := range watches {
|
||||
qd := GQLQuery{Query: fmt.Sprintf(graphQuery, watch.Name)}
|
||||
qd := GQLQuery{Query: fmt.Sprintf(graphQuery, watch.Repo, watch.Name)}
|
||||
wr, err := getData(qd, ghToken)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -153,6 +153,7 @@ func (w *WatchResults) Update(ghToken string) error {
|
||||
// TODO: cross ref the list of ignores and prune the wr accordingly
|
||||
wr.OwnerID = watch.OwnerID
|
||||
wr.Name = watch.Name
|
||||
wr.Repo = watch.Repo
|
||||
*w = append(*w, *wr)
|
||||
}
|
||||
|
||||
@ -163,6 +164,7 @@ type WatchResult struct {
|
||||
Data Data `json:"data,omitempty"`
|
||||
OwnerID int64
|
||||
Name string
|
||||
Repo string
|
||||
}
|
||||
type Repository struct {
|
||||
NameWithOwner string `json:"nameWithOwner,omitempty"`
|
||||
|
@ -17,8 +17,8 @@ from watch_items
|
||||
where owner_id = ?;
|
||||
|
||||
-- name: AddWatchItem :one
|
||||
insert into watch_items (owner_id, name, descr)
|
||||
values (?, ?, ?) returning *;
|
||||
insert into watch_items (owner_id, name, repo, descr)
|
||||
values (?, ?, ?, ?) returning *;
|
||||
|
||||
-- name: DeleteWatchItem :exec
|
||||
delete from watch_items where id = ? and owner_id = ?;
|
||||
|
@ -9,8 +9,10 @@ create table watch_items
|
||||
id integer primary key autoincrement,
|
||||
owner_id INTEGER REFERENCES owners (id) not null,
|
||||
created_at datetime default current_timestamp not null,
|
||||
name text not null unique,
|
||||
descr text
|
||||
name text not null,
|
||||
repo text not null,
|
||||
descr text,
|
||||
unique (name, repo)
|
||||
);
|
||||
create table pull_request_ignores
|
||||
(
|
||||
|
@ -14,42 +14,59 @@
|
||||
list-style-type: none;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.icons li img {
|
||||
width: 50px;
|
||||
hight: 50px;
|
||||
}
|
||||
dialog {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<title>{{.Title}}::{{.Node.ComputedName}}</title>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>{{.Title}} for {{.Node.ComputedName}}</h1>
|
||||
<input type="search" id="search" name="search" placeholder="Search">
|
||||
<ul class="icons">
|
||||
{{range .Links}}
|
||||
<li>{{.Name}}</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</header>
|
||||
<main>
|
||||
<h3>Pull Requests</h3>
|
||||
<ul>
|
||||
{{range .PullRequests}}
|
||||
<li>{{.Repo}} {{.Number}} ( {{.ID}} )</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
|
||||
<h3>Watch Items</h3>
|
||||
<ul class="">
|
||||
{{range .Watches}}
|
||||
<li>{{.Name}}
|
||||
<li><b>{{.Repo}} :: {{.Name}}</b>
|
||||
<ul>
|
||||
{{range .Data.Search.Edges}}
|
||||
<li>{{.Node.Title}} ({{.Node.CreatedAt}})</li>
|
||||
<li>{{.Node.Title}}</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
|
||||
<h3>Links</h3>
|
||||
<ul class="icons">
|
||||
{{range .Links}}
|
||||
<li>{{.Name}}</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
|
||||
<foot>Remaining queries: {{.CurrentLimits.Remaining}}</foot>
|
||||
<dialog open>
|
||||
<article>
|
||||
<h3>Add Watch Item</h3>
|
||||
<p>
|
||||
<input type="text" />
|
||||
</p>
|
||||
<footer>
|
||||
<a href="#cancel" role="button" class="secondary">Cancel</a>
|
||||
<a href="#confirm" role="button">Add</a>
|
||||
</footer>
|
||||
</article>
|
||||
</dialog>
|
||||
</main>
|
||||
<footer>Remaining queries: {{.CurrentLimits.Remaining}}</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
28
tmp.go
28
tmp.go
@ -15,12 +15,13 @@ func tmpDBPopulate(db *sql.DB) {
|
||||
|
||||
ownerID := int64(57395170551826799)
|
||||
|
||||
a, err := app.queries.AddOwner(app.ctx, data.AddOwnerParams{
|
||||
_, err := app.queries.AddOwner(app.ctx, data.AddOwnerParams{
|
||||
ID: 57395170551826799,
|
||||
Name: "europa.humpback-trout.ts.net.",
|
||||
})
|
||||
log.Println(a, err)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
b, err := app.queries.AddLink(app.ctx, data.AddLinkParams{
|
||||
OwnerID: ownerID,
|
||||
Url: "https://tapenet.org",
|
||||
@ -28,23 +29,30 @@ func tmpDBPopulate(db *sql.DB) {
|
||||
})
|
||||
log.Println(b, err)
|
||||
|
||||
c, err := app.queries.AddPullRequest(app.ctx, data.AddPullRequestParams{
|
||||
_, err = app.queries.AddPullRequest(app.ctx, data.AddPullRequestParams{
|
||||
OwnerID: ownerID,
|
||||
Number: 1234,
|
||||
Repo: "NixOS/nixpkgs",
|
||||
Description: sql.NullString{String: "who knows"},
|
||||
})
|
||||
log.Println(c, err)
|
||||
|
||||
d, err := app.queries.AddWatchItem(app.ctx, data.AddWatchItemParams{
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
_, err = app.queries.AddWatchItem(app.ctx, data.AddWatchItemParams{
|
||||
Name: "tailscale",
|
||||
Repo: "NixOS/nixpkgs",
|
||||
OwnerID: ownerID,
|
||||
})
|
||||
log.Println(d, err)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
e, err := app.queries.AddWatchItem(app.ctx, data.AddWatchItemParams{
|
||||
_, err = app.queries.AddWatchItem(app.ctx, data.AddWatchItemParams{
|
||||
Name: "openssh",
|
||||
OwnerID: ownerID,
|
||||
Repo: "NixOS/nixpkgs",
|
||||
})
|
||||
log.Println(e, err)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user