// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.25.0
// source: changelog.sql

package db

import (
	"context"

	"github.com/google/uuid"
)

const CreateCampaignChangelog = `-- name: CreateCampaignChangelog :one
INSERT INTO campaign_changelog (domain_id, campaign_id, message, ipv6_status)
VALUES ($1, $2, $3, $4)
RETURNING id, ts, domain_id, campaign_id, message, ipv6_status
`

type CreateCampaignChangelogParams struct {
	DomainID   int64
	CampaignID uuid.UUID
	Message    string
	Ipv6Status string
}

func (q *Queries) CreateCampaignChangelog(ctx context.Context, arg CreateCampaignChangelogParams) (CampaignChangelog, error) {
	row := q.db.QueryRow(ctx, CreateCampaignChangelog,
		arg.DomainID,
		arg.CampaignID,
		arg.Message,
		arg.Ipv6Status,
	)
	var i CampaignChangelog
	err := row.Scan(
		&i.ID,
		&i.Ts,
		&i.DomainID,
		&i.CampaignID,
		&i.Message,
		&i.Ipv6Status,
	)
	return i, err
}

const CreateChangelog = `-- name: CreateChangelog :one
INSERT INTO changelog (domain_id, message, ipv6_status)
VALUES ($1, $2, $3)
RETURNING id, ts, domain_id, message, ipv6_status
`

type CreateChangelogParams struct {
	DomainID   int64
	Message    string
	Ipv6Status string
}

func (q *Queries) CreateChangelog(ctx context.Context, arg CreateChangelogParams) (Changelog, error) {
	row := q.db.QueryRow(ctx, CreateChangelog, arg.DomainID, arg.Message, arg.Ipv6Status)
	var i Changelog
	err := row.Scan(
		&i.ID,
		&i.Ts,
		&i.DomainID,
		&i.Message,
		&i.Ipv6Status,
	)
	return i, err
}

const GetChangelogByCampaign = `-- name: GetChangelogByCampaign :many
SELECT id, ts, domain_id, campaign_id, message, ipv6_status, site
FROM changelog_campaign_view
WHERE campaign_id = $1
LIMIT $2 OFFSET $3
`

type GetChangelogByCampaignParams struct {
	CampaignID uuid.UUID
	Limit      int64
	Offset     int64
}

func (q *Queries) GetChangelogByCampaign(ctx context.Context, arg GetChangelogByCampaignParams) ([]ChangelogCampaignView, error) {
	rows, err := q.db.Query(ctx, GetChangelogByCampaign, arg.CampaignID, arg.Limit, arg.Offset)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ChangelogCampaignView{}
	for rows.Next() {
		var i ChangelogCampaignView
		if err := rows.Scan(
			&i.ID,
			&i.Ts,
			&i.DomainID,
			&i.CampaignID,
			&i.Message,
			&i.Ipv6Status,
			&i.Site,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const GetChangelogByCampaignDomain = `-- name: GetChangelogByCampaignDomain :many
SELECT id, ts, domain_id, campaign_id, message, ipv6_status, site
FROM changelog_campaign_view
WHERE campaign_id = $1
  AND site = $2
LIMIT $3 OFFSET $4
`

type GetChangelogByCampaignDomainParams struct {
	CampaignID uuid.UUID
	Site       string
	Limit      int64
	Offset     int64
}

func (q *Queries) GetChangelogByCampaignDomain(ctx context.Context, arg GetChangelogByCampaignDomainParams) ([]ChangelogCampaignView, error) {
	rows, err := q.db.Query(ctx, GetChangelogByCampaignDomain,
		arg.CampaignID,
		arg.Site,
		arg.Limit,
		arg.Offset,
	)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ChangelogCampaignView{}
	for rows.Next() {
		var i ChangelogCampaignView
		if err := rows.Scan(
			&i.ID,
			&i.Ts,
			&i.DomainID,
			&i.CampaignID,
			&i.Message,
			&i.Ipv6Status,
			&i.Site,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const GetChangelogByDomain = `-- name: GetChangelogByDomain :many
SELECT id, ts, domain_id, message, ipv6_status, site
FROM changelog_view
WHERE site = $1
LIMIT $2 OFFSET $3
`

type GetChangelogByDomainParams struct {
	Site   string
	Limit  int64
	Offset int64
}

func (q *Queries) GetChangelogByDomain(ctx context.Context, arg GetChangelogByDomainParams) ([]ChangelogView, error) {
	rows, err := q.db.Query(ctx, GetChangelogByDomain, arg.Site, arg.Limit, arg.Offset)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ChangelogView{}
	for rows.Next() {
		var i ChangelogView
		if err := rows.Scan(
			&i.ID,
			&i.Ts,
			&i.DomainID,
			&i.Message,
			&i.Ipv6Status,
			&i.Site,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const ListCampaignChangelog = `-- name: ListCampaignChangelog :many
SELECT id, ts, domain_id, campaign_id, message, ipv6_status, site
FROM changelog_campaign_view
LIMIT $1 OFFSET $2
`

type ListCampaignChangelogParams struct {
	Limit  int64
	Offset int64
}

func (q *Queries) ListCampaignChangelog(ctx context.Context, arg ListCampaignChangelogParams) ([]ChangelogCampaignView, error) {
	rows, err := q.db.Query(ctx, ListCampaignChangelog, arg.Limit, arg.Offset)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ChangelogCampaignView{}
	for rows.Next() {
		var i ChangelogCampaignView
		if err := rows.Scan(
			&i.ID,
			&i.Ts,
			&i.DomainID,
			&i.CampaignID,
			&i.Message,
			&i.Ipv6Status,
			&i.Site,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}

const ListChangelog = `-- name: ListChangelog :many
SELECT id, ts, domain_id, message, ipv6_status, site
FROM changelog_view
LIMIT $1 OFFSET $2
`

type ListChangelogParams struct {
	Limit  int64
	Offset int64
}

func (q *Queries) ListChangelog(ctx context.Context, arg ListChangelogParams) ([]ChangelogView, error) {
	rows, err := q.db.Query(ctx, ListChangelog, arg.Limit, arg.Offset)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	items := []ChangelogView{}
	for rows.Next() {
		var i ChangelogView
		if err := rows.Scan(
			&i.ID,
			&i.Ts,
			&i.DomainID,
			&i.Message,
			&i.Ipv6Status,
			&i.Site,
		); err != nil {
			return nil, err
		}
		items = append(items, i)
	}
	if err := rows.Err(); err != nil {
		return nil, err
	}
	return items, nil
}
