add stuff that may not compile.
continuous-integration/drone/push Build is failing

This commit is contained in:
2021-03-25 14:13:43 +01:00
parent 9aa7304982
commit 410e07a6a2
16 changed files with 674 additions and 3 deletions
+19
View File
@@ -8,6 +8,12 @@ import (
"time"
)
type CommonTag struct {
Tag string `json:"tag"`
TargetKind string `json:"target_kind"`
TargetID string `json:"target_id"`
}
type CoreCounter struct {
ID string `json:"id"`
Value sql.NullInt32 `json:"value"`
@@ -41,3 +47,16 @@ type DataCharacter struct {
Description string `json:"description"`
TsVector interface{} `json:"ts_vector"`
}
type Story struct {
ID string `json:"id"`
Author string `json:"author"`
Name string `json:"name"`
Category string `json:"category"`
Open bool `json:"open"`
Listed bool `json:"listed"`
SortByFictionalDate bool `json:"sort_by_fictional_date"`
CreatedDate time.Time `json:"created_date"`
FictionalDate time.Time `json:"fictional_date"`
UpdatedDate time.Time `json:"updated_date"`
}
+113
View File
@@ -0,0 +1,113 @@
// Code generated by sqlc. DO NOT EDIT.
// source: stories.sql
package psqlcore
import (
"context"
"time"
"github.com/lib/pq"
)
const selectStories = `-- name: SelectStories :many
SELECT id, author, name, category, open, listed, sort_by_fictional_date, created_date, fictional_date, updated_date FROM story
WHERE ($1::bool = false OR id = ANY($2::text[]))
AND ($3::bool = false OR name = $4::text)
AND ($5::bool = false OR fictional_date >= $6::timestamp)
AND ($7::bool = false OR fictional_date <= $8::timestamp)
AND ($9::bool = false OR category = $10::text)
AND ($11::bool = false OR open = $12::bool)
AND ($13::bool = false OR unlisted = $14::bool)
LIMIT $15::int
`
type SelectStoriesParams struct {
FilterID bool `json:"filter_id"`
Ids []string `json:"ids"`
FilterAuthor bool `json:"filter_author"`
Author string `json:"author"`
FilterEarlistFictionalDate bool `json:"filter_earlist_fictional_date"`
EarliestFictionalDate time.Time `json:"earliest_fictional_date"`
FilterLastestFictionalDate bool `json:"filter_lastest_fictional_date"`
LatestFictionalDate time.Time `json:"latest_fictional_date"`
FilterCategory bool `json:"filter_category"`
Category string `json:"category"`
FilterOpen bool `json:"filter_open"`
Open bool `json:"open"`
FilterUnlisted bool `json:"filter_unlisted"`
Unlisted bool `json:"unlisted"`
LimitSize int32 `json:"limit_size"`
}
func (q *Queries) SelectStories(ctx context.Context, arg SelectStoriesParams) ([]Story, error) {
rows, err := q.db.QueryContext(ctx, selectStories,
arg.FilterID,
pq.Array(arg.Ids),
arg.FilterAuthor,
arg.Author,
arg.FilterEarlistFictionalDate,
arg.EarliestFictionalDate,
arg.FilterLastestFictionalDate,
arg.LatestFictionalDate,
arg.FilterCategory,
arg.Category,
arg.FilterOpen,
arg.Open,
arg.FilterUnlisted,
arg.Unlisted,
arg.LimitSize,
)
if err != nil {
return nil, err
}
defer rows.Close()
items := []Story{}
for rows.Next() {
var i Story
if err := rows.Scan(
&i.ID,
&i.Author,
&i.Name,
&i.Category,
&i.Open,
&i.Listed,
&i.SortByFictionalDate,
&i.CreatedDate,
&i.FictionalDate,
&i.UpdatedDate,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const selectStory = `-- name: SelectStory :one
SELECT id, author, name, category, open, listed, sort_by_fictional_date, created_date, fictional_date, updated_date FROM story WHERE id = $1 LIMIT 1
`
func (q *Queries) SelectStory(ctx context.Context, id string) (Story, error) {
row := q.db.QueryRowContext(ctx, selectStory, id)
var i Story
err := row.Scan(
&i.ID,
&i.Author,
&i.Name,
&i.Category,
&i.Open,
&i.Listed,
&i.SortByFictionalDate,
&i.CreatedDate,
&i.FictionalDate,
&i.UpdatedDate,
)
return i, err
}
+235
View File
@@ -0,0 +1,235 @@
// Code generated by sqlc. DO NOT EDIT.
// source: tags.sql
package psqlcore
import (
"context"
"github.com/lib/pq"
)
const clearTag = `-- name: ClearTag :exec
DELETE FROM common_tag
WHERE tag=$1::TEXT
AND target_kind=$2::TEXT
AND target_id=$3::TEXT
`
type ClearTagParams struct {
Tag string `json:"tag"`
TargetKind string `json:"target_kind"`
TargetID string `json:"target_id"`
}
func (q *Queries) ClearTag(ctx context.Context, arg ClearTagParams) error {
_, err := q.db.ExecContext(ctx, clearTag, arg.Tag, arg.TargetKind, arg.TargetID)
return err
}
const clearTagsByTarget = `-- name: ClearTagsByTarget :exec
DELETE FROM common_tag
WHERE target_kind=$1::TEXT
AND target_id=$2::TEXT
`
type ClearTagsByTargetParams struct {
TargetKind string `json:"target_kind"`
TargetID string `json:"target_id"`
}
func (q *Queries) ClearTagsByTarget(ctx context.Context, arg ClearTagsByTargetParams) error {
_, err := q.db.ExecContext(ctx, clearTagsByTarget, arg.TargetKind, arg.TargetID)
return err
}
const selectDistinctTags = `-- name: SelectDistinctTags :many
SELECT DISTINCT tag FROM common_tag
`
func (q *Queries) SelectDistinctTags(ctx context.Context) ([]string, error) {
rows, err := q.db.QueryContext(ctx, selectDistinctTags)
if err != nil {
return nil, err
}
defer rows.Close()
items := []string{}
for rows.Next() {
var tag string
if err := rows.Scan(&tag); err != nil {
return nil, err
}
items = append(items, tag)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const selectDistinctTagsByKind = `-- name: SelectDistinctTagsByKind :many
SELECT DISTINCT tag FROM common_tag WHERE tag LIKE '$1::text%'
`
func (q *Queries) SelectDistinctTagsByKind(ctx context.Context) ([]string, error) {
rows, err := q.db.QueryContext(ctx, selectDistinctTagsByKind)
if err != nil {
return nil, err
}
defer rows.Close()
items := []string{}
for rows.Next() {
var tag string
if err := rows.Scan(&tag); err != nil {
return nil, err
}
items = append(items, tag)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const selectTagsByTag = `-- name: SelectTagsByTag :many
SELECT tag, target_kind, target_id FROM common_tag WHERE tag = $1::text
`
func (q *Queries) SelectTagsByTag(ctx context.Context, tagName string) ([]CommonTag, error) {
rows, err := q.db.QueryContext(ctx, selectTagsByTag, tagName)
if err != nil {
return nil, err
}
defer rows.Close()
items := []CommonTag{}
for rows.Next() {
var i CommonTag
if err := rows.Scan(&i.Tag, &i.TargetKind, &i.TargetID); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const selectTagsByTags = `-- name: SelectTagsByTags :many
SELECT tag, target_kind, target_id FROM common_tag WHERE tag = ANY($1::text[])
`
func (q *Queries) SelectTagsByTags(ctx context.Context, tagNames []string) ([]CommonTag, error) {
rows, err := q.db.QueryContext(ctx, selectTagsByTags, pq.Array(tagNames))
if err != nil {
return nil, err
}
defer rows.Close()
items := []CommonTag{}
for rows.Next() {
var i CommonTag
if err := rows.Scan(&i.Tag, &i.TargetKind, &i.TargetID); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const selectTagsByTarget = `-- name: SelectTagsByTarget :many
SELECT tag, target_kind, target_id FROM common_tag WHERE target_kind = $1 AND target_id = $2::text
`
type SelectTagsByTargetParams struct {
TargetKind string `json:"target_kind"`
Column2 string `json:"column_2"`
}
func (q *Queries) SelectTagsByTarget(ctx context.Context, arg SelectTagsByTargetParams) ([]CommonTag, error) {
rows, err := q.db.QueryContext(ctx, selectTagsByTarget, arg.TargetKind, arg.Column2)
if err != nil {
return nil, err
}
defer rows.Close()
items := []CommonTag{}
for rows.Next() {
var i CommonTag
if err := rows.Scan(&i.Tag, &i.TargetKind, &i.TargetID); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const selectTagsByTargets = `-- name: SelectTagsByTargets :many
SELECT tag, target_kind, target_id FROM common_tag WHERE target_kind = $1 AND target_id = ANY($2::text[])
`
type SelectTagsByTargetsParams struct {
TargetKind string `json:"target_kind"`
Column2 []string `json:"column_2"`
}
func (q *Queries) SelectTagsByTargets(ctx context.Context, arg SelectTagsByTargetsParams) ([]CommonTag, error) {
rows, err := q.db.QueryContext(ctx, selectTagsByTargets, arg.TargetKind, pq.Array(arg.Column2))
if err != nil {
return nil, err
}
defer rows.Close()
items := []CommonTag{}
for rows.Next() {
var i CommonTag
if err := rows.Scan(&i.Tag, &i.TargetKind, &i.TargetID); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const setTag = `-- name: SetTag :exec
INSERT INTO common_tag (tag, target_kind, target_id)
VALUES (
$1::TEXT, $2::TEXT, $3::TEXT
)
ON CONFLICT DO NOTHING
`
type SetTagParams struct {
Tag string `json:"tag"`
TargetKind string `json:"target_kind"`
TargetID string `json:"target_id"`
}
func (q *Queries) SetTag(ctx context.Context, arg SetTagParams) error {
_, err := q.db.ExecContext(ctx, setTag, arg.Tag, arg.TargetKind, arg.TargetID)
return err
}