db

package
v1.12.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const TimeframeMonths = 7

Variables

This section is empty.

Functions

func AddArtifact

func AddArtifact(e Execer, artifact models.Artifact) error

func AddCollaborator

func AddCollaborator(e Execer, c models.Collaborator) error

func AddEmail

func AddEmail(e Execer, email models.Email) error

func AddFollow

func AddFollow(e Execer, follow *models.Follow) error

func AddInflightSignup

func AddInflightSignup(e Execer, signup models.InflightSignup) error

func AddIssueComment

func AddIssueComment(tx *sql.Tx, c models.IssueComment) (int64, error)

func AddKnot

func AddKnot(e Execer, domain, did string) error

func AddLabelDefinition

func AddLabelDefinition(e Execer, l *models.LabelDefinition) (int64, error)

no updating type for now

func AddLabelOp

func AddLabelOp(e Execer, l *models.LabelOp) (int64, error)

func AddPipeline

func AddPipeline(e Execer, pipeline models.Pipeline) error

func AddPipelineStatus

func AddPipelineStatus(e Execer, status models.PipelineStatus) error

func AddPublicKey

func AddPublicKey(e Execer, did, name, key, rkey string) error

func AddPunch

func AddPunch(e Execer, punch models.Punch) error

this adds to the existing count

func AddReaction

func AddReaction(e Execer, reactedByDid string, threadAt syntax.ATURI, kind models.ReactionKind, rkey string) error

func AddRepo

func AddRepo(tx *sql.Tx, repo *models.Repo) error

func AddSpindle

func AddSpindle(e Execer, spindle models.Spindle) error

if there is an existing spindle with the same instance, this returns an error

func AddSpindleMember

func AddSpindleMember(e Execer, member models.SpindleMember) error

func AddStar

func AddStar(e Execer, star *models.Star) error

func AddString

func AddString(e Execer, s models.String) error

func AddTrigger

func AddTrigger(e Execer, trigger models.Trigger) (int64, error)

func AddWebhook

func AddWebhook(e Execer, webhook *models.Webhook) error

AddWebhook creates a new webhook

func AddWebhookDelivery

func AddWebhookDelivery(e Execer, delivery *models.WebhookDelivery) error

AddWebhookDelivery records a webhook delivery attempt

func CheckEmailExists

func CheckEmailExists(e Execer, did string, email string) (bool, error)

func CheckEmailExistsAtAll

func CheckEmailExistsAtAll(e Execer, email string) (bool, error)

func CheckValidVerificationCode

func CheckValidVerificationCode(e Execer, did string, email string, code string) (bool, error)

func CloseIssues

func CloseIssues(e Execer, filters ...orm.Filter) error

func ClosePull

func ClosePull(e Execer, repoAt syntax.ATURI, pullId int) error

func CollaboratingIn

func CollaboratingIn(e Execer, collaborator string) ([]models.Repo, error)

func CountNotifications

func CountNotifications(e Execer, filters ...orm.Filter) (int64, error)

func CountRepos

func CountRepos(e Execer, filters ...orm.Filter) (int64, error)

func CountStars

func CountStars(e Execer, filters ...orm.Filter) (int64, error)

func CountStrings

func CountStrings(e Execer, filters ...orm.Filter) (int64, error)

func CreateNotification

func CreateNotification(e Execer, notification *models.Notification) error

func DeleteArtifact

func DeleteArtifact(e Execer, filters ...orm.Filter) error

func DeleteCollaborator

func DeleteCollaborator(e Execer, filters ...orm.Filter) error

func DeleteEmail

func DeleteEmail(e Execer, did string, email string) error

func DeleteFollow

func DeleteFollow(e Execer, userDid, subjectDid string) error

Remove a follow

func DeleteFollowByRkey

func DeleteFollowByRkey(e Execer, userDid, rkey string) error

Remove a follow

func DeleteInflightSignup

func DeleteInflightSignup(e Execer, email string) error

func DeleteIssueComments

func DeleteIssueComments(e Execer, filters ...orm.Filter) error

func DeleteIssues

func DeleteIssues(tx *sql.Tx, did, rkey string) error

func DeleteKnot

func DeleteKnot(e Execer, filters ...orm.Filter) error

func DeleteLabelDefinition

func DeleteLabelDefinition(e Execer, filters ...orm.Filter) error

func DeleteNotification

func DeleteNotification(e Execer, notificationID int64, userDID string) error

func DeletePublicKey

func DeletePublicKey(e Execer, did, name, key string) error

func DeletePublicKeyByRkey

func DeletePublicKeyByRkey(e Execer, did, rkey string) error

func DeletePull

func DeletePull(e Execer, repoAt syntax.ATURI, pullId int) error

func DeleteReaction

func DeleteReaction(e Execer, reactedByDid string, threadAt syntax.ATURI, kind models.ReactionKind) error

Remove a reaction

func DeleteReactionByRkey

func DeleteReactionByRkey(e Execer, reactedByDid string, rkey string) error

Remove a reaction

func DeleteRepoLanguages

func DeleteRepoLanguages(e Execer, filters ...orm.Filter) error

func DeleteSpindle

func DeleteSpindle(e Execer, filters ...orm.Filter) error

func DeleteStar

func DeleteStar(e Execer, did string, subjectAt syntax.ATURI) error

Remove a star

func DeleteStarByRkey

func DeleteStarByRkey(e Execer, did string, rkey string) error

Remove a star

func DeleteString

func DeleteString(e Execer, filters ...orm.Filter) error

func DeleteWebhook

func DeleteWebhook(e Execer, id int64) error

DeleteWebhook deletes a webhook

func GetAbandonedPulls

func GetAbandonedPulls(e Execer, stackId string) ([]*models.Pull, error)

func GetActiveWebhooksForRepo

func GetActiveWebhooksForRepo(e Execer, repoAt syntax.ATURI) ([]models.Webhook, error)

GetActiveWebhooksForRepo returns only active webhooks for a repository

func GetAllEmails

func GetAllEmails(e Execer, did string) ([]models.Email, error)

func GetAllPublicKeys

func GetAllPublicKeys(e Execer) ([]models.PublicKey, error)

func GetArtifact

func GetArtifact(e Execer, filters ...orm.Filter) ([]models.Artifact, error)
func GetBacklinks(e Execer, target syntax.ATURI) ([]models.RichReferenceLink, error)

func GetBlueskyPosts

func GetBlueskyPosts(e Execer, limit int) ([]models.BskyPost, error)

func GetCollaborators

func GetCollaborators(e Execer, filters ...orm.Filter) ([]models.Collaborator, error)

func GetDidForEmail

func GetDidForEmail(e Execer, em string) (string, error)

func GetEmail

func GetEmail(e Execer, did string, em string) (models.Email, error)

func GetEmailForCode

func GetEmailForCode(e Execer, inviteCode string) (string, error)

func GetEmailToDid

func GetEmailToDid(e Execer, emails []string, isVerifiedFilter bool) (map[string]string, error)

func GetFollow

func GetFollow(e Execer, userDid, subjectDid string) (*models.Follow, error)

Get a follow record

func GetFollowStatus

func GetFollowStatus(e Execer, userDid, subjectDid string) models.FollowStatus

func GetFollowStatuses

func GetFollowStatuses(e Execer, userDid string, subjectDids []string) (map[string]models.FollowStatus, error)

func GetFollowerFollowingCount

func GetFollowerFollowingCount(e Execer, did string) (models.FollowStats, error)

func GetFollowerFollowingCounts

func GetFollowerFollowingCounts(e Execer, dids []string) (map[string]models.FollowStats, error)

func GetFollowers

func GetFollowers(e Execer, did string) ([]models.Follow, error)

func GetFollowing

func GetFollowing(e Execer, did string) ([]models.Follow, error)

func GetFollows

func GetFollows(e Execer, limit int, filters ...orm.Filter) ([]models.Follow, error)

func GetForkByDid

func GetForkByDid(e Execer, did string, name string) (*models.Repo, error)

func GetForksByDid

func GetForksByDid(e Execer, did string) ([]models.Repo, error)

func GetIssue

func GetIssue(e Execer, repoAt syntax.ATURI, issueId int) (*models.Issue, error)

func GetIssueComments

func GetIssueComments(e Execer, filters ...orm.Filter) ([]models.IssueComment, error)

func GetIssueCount

func GetIssueCount(e Execer, repoAt syntax.ATURI) (models.IssueCount, error)

func GetIssues

func GetIssues(e Execer, filters ...orm.Filter) ([]models.Issue, error)

func GetIssuesPaginated

func GetIssuesPaginated(e Execer, page pagination.Page, filters ...orm.Filter) ([]models.Issue, error)

func GetLabelDefinition

func GetLabelDefinition(e Execer, filters ...orm.Filter) (*models.LabelDefinition, error)

helper to get exactly one label def

func GetLabelDefinitions

func GetLabelDefinitions(e Execer, filters ...orm.Filter) ([]models.LabelDefinition, error)

func GetLabelOps

func GetLabelOps(e Execer, filters ...orm.Filter) ([]models.LabelOp, error)

func GetLabels

func GetLabels(e Execer, filters ...orm.Filter) (map[syntax.ATURI]models.LabelState, error)

get labels for a given list of subject URIs

func GetNotificationPreference

func GetNotificationPreference(e Execer, userDid string) (*models.NotificationPreferences, error)

func GetNotificationPreferences

func GetNotificationPreferences(e Execer, filters ...orm.Filter) (map[syntax.DID]*models.NotificationPreferences, error)

func GetNotifications

func GetNotifications(e Execer, filters ...orm.Filter) ([]*models.Notification, error)

GetNotifications retrieves notifications with filters

func GetNotificationsPaginated

func GetNotificationsPaginated(e Execer, page pagination.Page, filters ...orm.Filter) ([]*models.Notification, error)

GetNotificationsPaginated retrieves notifications with filters and pagination

func GetNotificationsWithEntities

func GetNotificationsWithEntities(e Execer, page pagination.Page, filters ...orm.Filter) ([]*models.NotificationWithEntity, error)

GetNotificationsWithEntities retrieves notifications with their related entities

func GetPipelineStatuses

func GetPipelineStatuses(e Execer, limit int, filters ...orm.Filter) ([]models.Pipeline, error)

this is a mega query, but the most useful one: get N pipelines, for each one get the latest status of its N workflows

the pipelines table is aliased to `p` the triggers table is aliased to `t`

func GetPipelines

func GetPipelines(e Execer, filters ...orm.Filter) ([]models.Pipeline, error)

func GetPrimaryEmail

func GetPrimaryEmail(e Execer, did string) (models.Email, error)

func GetProfile

func GetProfile(e Execer, did string) (*models.Profile, error)

func GetProfiles

func GetProfiles(e Execer, filters ...orm.Filter) (map[string]*models.Profile, error)

func GetPublicKeysForDid

func GetPublicKeysForDid(e Execer, did string) ([]models.PublicKey, error)

func GetPull

func GetPull(e Execer, repoAt syntax.ATURI, pullId int) (*models.Pull, error)

func GetPullAt

func GetPullAt(e Execer, repoAt syntax.ATURI, pullId int) (syntax.ATURI, error)

func GetPullComments

func GetPullComments(e Execer, filters ...orm.Filter) ([]models.PullComment, error)

func GetPullCount

func GetPullCount(e Execer, repoAt syntax.ATURI) (models.PullCount, error)

func GetPullSubmissions

func GetPullSubmissions(e Execer, filters ...orm.Filter) (map[syntax.ATURI][]*models.PullSubmission, error)

mapping from pull -> pull submissions

func GetPulls

func GetPulls(e Execer, filters ...orm.Filter) ([]*models.Pull, error)

func GetPullsByOwnerDid

func GetPullsByOwnerDid(e Execer, did, timeframe string) ([]models.Pull, error)

timeframe here is directly passed into the sql query filter, and any timeframe in the past should be negative; e.g.: "-3 months"

func GetPullsPaginated

func GetPullsPaginated(e Execer, page pagination.Page, filters ...orm.Filter) ([]*models.Pull, error)

func GetPunchcardPreference

func GetPunchcardPreference(e Execer, did string) (models.PunchcardPreference, error)

func GetReaction

func GetReaction(e Execer, reactedByDid string, threadAt syntax.ATURI, kind models.ReactionKind) (*models.Reaction, error)

Get a reaction record

func GetReactionCount

func GetReactionCount(e Execer, threadAt syntax.ATURI, kind models.ReactionKind) (int, error)

func GetReactionMap

func GetReactionMap(e Execer, userLimit int, threadAt syntax.ATURI) (map[models.ReactionKind]models.ReactionDisplayData, error)

func GetReactionStatus

func GetReactionStatus(e Execer, userDid string, threadAt syntax.ATURI, kind models.ReactionKind) bool

func GetReactionStatusMap

func GetReactionStatusMap(e Execer, userDid string, threadAt syntax.ATURI) map[models.ReactionKind]bool

func GetReferencesAll

func GetReferencesAll(e Execer, filters ...orm.Filter) (map[syntax.ATURI][]syntax.ATURI, error)

func GetRegistrations

func GetRegistrations(e Execer, filters ...orm.Filter) ([]models.Registration, error)

func GetRepo

func GetRepo(e Execer, filters ...orm.Filter) (*models.Repo, error)

helper to get exactly one repo

func GetRepoByAtUri

func GetRepoByAtUri(e Execer, atUri string) (*models.Repo, error)

func GetRepoLabels

func GetRepoLabels(e Execer, filters ...orm.Filter) ([]models.RepoLabel, error)

func GetRepoLanguages

func GetRepoLanguages(e Execer, filters ...orm.Filter) ([]models.RepoLanguage, error)

func GetRepoSource

func GetRepoSource(e Execer, repoAt syntax.ATURI) (string, error)

func GetRepoSourceRepo

func GetRepoSourceRepo(e Execer, repoAt syntax.ATURI) (*models.Repo, error)

func GetRepoStars

func GetRepoStars(e Execer, limit int, filters ...orm.Filter) ([]models.RepoStar, error)

GetRepoStars return a list of stars each holding target repository. If there isn't known repo with starred at-uri, those stars will be ignored.

func GetRepos

func GetRepos(e Execer, limit int, filters ...orm.Filter) ([]models.Repo, error)

func GetSpindleMembers

func GetSpindleMembers(e Execer, filters ...orm.Filter) ([]models.SpindleMember, error)

func GetSpindles

func GetSpindles(e Execer, filters ...orm.Filter) ([]models.Spindle, error)

func GetStack

func GetStack(e Execer, stackId string) (models.Stack, error)
change-id     parent-change-id

4 w ,-------- z (TOP) 3 z <----',------- y 2 y <-----',------ x 1 x <------' nil (BOT)

`w` is parent of none, so it is the top of the stack

func GetStar

func GetStar(e Execer, did string, subjectAt syntax.ATURI) (*models.Star, error)

Get a star record

func GetStarCount

func GetStarCount(e Execer, subjectAt syntax.ATURI) (int, error)

func GetStarStatus

func GetStarStatus(e Execer, userDid string, subjectAt syntax.ATURI) bool

func GetStarStatuses

func GetStarStatuses(e Execer, userDid string, subjectAts []syntax.ATURI) (map[string]bool, error)

GetStarStatuses returns a map of repo URIs to star status for a given user

func GetStrings

func GetStrings(e Execer, limit int, filters ...orm.Filter) ([]models.String, error)

func GetTopStarredReposLastWeek

func GetTopStarredReposLastWeek(e Execer) ([]models.Repo, error)

GetTopStarredReposLastWeek returns the top 8 most starred repositories from the last week

func GetTotalPipelineStatuses

func GetTotalPipelineStatuses(e Execer, filters ...orm.Filter) (int64, error)

the pipelines table is aliased to `p` the triggers table is aliased to `t`

func GetVanityStat

func GetVanityStat(e Execer, did string, stat models.VanityStatKind) (uint64, error)

func GetVerificationCodeForEmail

func GetVerificationCodeForEmail(e Execer, did string, email string) (string, error)

func GetWebhook

func GetWebhook(e Execer, id int64) (*models.Webhook, error)

GetWebhook returns a single webhook by ID

func GetWebhookDeliveries

func GetWebhookDeliveries(e Execer, webhookId int64, limit int) ([]models.WebhookDelivery, error)

GetWebhookDeliveries returns recent deliveries for a webhook

func GetWebhooks

func GetWebhooks(e Execer, filters ...orm.Filter) ([]models.Webhook, error)

GetWebhooks returns all webhooks for a repository

func GetWebhooksForRepo

func GetWebhooksForRepo(e Execer, repoAt syntax.ATURI) ([]models.Webhook, error)

GetWebhooksForRepo is a convenience function to get all webhooks for a repository

func InsertBlueskyPosts

func InsertBlueskyPosts(e Execer, posts []models.BskyPost) error

func InsertRepoLanguages

func InsertRepoLanguages(e Execer, langs []models.RepoLanguage) error

func MakeEmailPrimary

func MakeEmailPrimary(e Execer, did string, email string) error

func MakeProfileTimeline

func MakeProfileTimeline(e Execer, forDid string) (*models.ProfileTimeline, error)

func MakePunchcard

func MakePunchcard(e Execer, filters ...orm.Filter) (*models.Punchcard, error)

func MakeTimeline

func MakeTimeline(e Execer, limit int, loggedInUserDid string, limitToUsersIsFollowing bool) ([]models.TimelineEvent, error)

TODO: this gathers heterogenous events from different sources and aggregates them in code; if we did this entirely in sql, we could order and limit and paginate easily

func MarkAllNotificationsRead

func MarkAllNotificationsRead(e Execer, userDID string) error

func MarkEmailVerified

func MarkEmailVerified(e Execer, did string, email string) error

func MarkNotificationRead

func MarkNotificationRead(e Execer, notificationID int64, userDID string) error

func MarkRegistered

func MarkRegistered(e Execer, filters ...orm.Filter) error

func MergePull

func MergePull(e Execer, repoAt syntax.ATURI, pullId int) error

func NewLabelApplicationCtx

func NewLabelApplicationCtx(e Execer, filters ...orm.Filter) (*models.LabelApplicationCtx, error)

func NewPull

func NewPull(tx *sql.Tx, pull *models.Pull) error

func NewPullComment

func NewPullComment(tx *sql.Tx, comment *models.PullComment) (int64, error)

func NextPullId

func NextPullId(e Execer, repoAt syntax.ATURI) (int, error)

func PutIssue

func PutIssue(tx *sql.Tx, issue *models.Issue) error

func PutRepo

func PutRepo(tx *sql.Tx, repo models.Repo) error

func RemoveRepo

func RemoveRepo(e Execer, did, name string) error

func RemoveSpindleMember

func RemoveSpindleMember(e Execer, filters ...orm.Filter) error

func ReopenIssues

func ReopenIssues(e Execer, filters ...orm.Filter) error

func ReopenPull

func ReopenPull(e Execer, repoAt syntax.ATURI, pullId int) error

func ResubmitPull

func ResubmitPull(e Execer, pullAt syntax.ATURI, newRoundNumber int, newPatch string, combinedPatch string, newSourceRev string) error

func SetPullParentChangeId

func SetPullParentChangeId(e Execer, parentChangeId string, filters ...orm.Filter) error

func SetPullState

func SetPullState(e Execer, repoAt syntax.ATURI, pullId int, pullState models.PullState) error

func SubscribeLabel

func SubscribeLabel(e Execer, rl *models.RepoLabel) error

func UnsubscribeLabel

func UnsubscribeLabel(e Execer, filters ...orm.Filter) error

func UpdateDescription

func UpdateDescription(e Execer, repoAt, newDescription string) error

func UpdatePull

func UpdatePull(e Execer, newPatch, sourceRev string, filters ...orm.Filter) error

Only used when stacking to update contents in the event of a rebase (the interdiff should be empty). otherwise submissions are immutable

func UpdateRepoLanguages

func UpdateRepoLanguages(tx *sql.Tx, repoAt syntax.ATURI, ref string, langs []models.RepoLanguage) error

func UpdateSpindle

func UpdateSpindle(e Execer, repoAt string, spindle *string) error

func UpdateVerificationCode

func UpdateVerificationCode(e Execer, did string, email string, code string) error

func UpdateWebhook

func UpdateWebhook(e Execer, webhook *models.Webhook) error

UpdateWebhook updates an existing webhook

func UpsertProfile

func UpsertProfile(tx *sql.Tx, profile *models.Profile) error

func UpsertPunchcardPreference

func UpsertPunchcardPreference(e Execer, did string, hideMine, hideOthers bool) error

func ValidateProfile

func ValidateProfile(e Execer, profile *models.Profile) error
func ValidateReferenceLinks(e Execer, refLinks []models.ReferenceLink) ([]syntax.ATURI, error)

ValidateReferenceLinks resolves refLinks to Issue/PR/IssueComment/PullComment ATURIs. It will ignore missing refLinks.

func VerifySpindle

func VerifySpindle(e Execer, filters ...orm.Filter) (int64, error)

Types

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}

func Make

func Make(ctx context.Context, dbPath string) (*DB, error)

func (*DB) ClearOldNotifications

func (d *DB) ClearOldNotifications(ctx context.Context, olderThan time.Duration) error

func (*DB) Close

func (d *DB) Close() error

func (*DB) UpdateNotificationPreferences

func (d *DB) UpdateNotificationPreferences(ctx context.Context, prefs *models.NotificationPreferences) error

type DbWrapper

type DbWrapper struct {
	Execer
}

func (DbWrapper) GetLastTimeUs

func (db DbWrapper) GetLastTimeUs() (int64, error)

func (DbWrapper) SaveLastTimeUs

func (db DbWrapper) SaveLastTimeUs(lastTimeUs int64) error

type Execer

type Execer interface {
	Query(query string, args ...any) (*sql.Rows, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	QueryRow(query string, args ...any) *sql.Row
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
	Exec(query string, args ...any) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	Prepare(query string) (*sql.Stmt, error)
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
}

Source Files

  • artifact.go
  • bsky.go
  • collaborators.go
  • db.go
  • email.go
  • follow.go
  • issues.go
  • jetstream.go
  • label.go
  • language.go
  • notifications.go
  • pipeline.go
  • preferences.go
  • profile.go
  • pubkeys.go
  • pulls.go
  • punchcard.go
  • reaction.go
  • reference.go
  • registration.go
  • repos.go
  • signup.go
  • spindle.go
  • star.go
  • strings.go
  • timeline.go
  • webhooks.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL