Documentation
¶
Index ¶
- func BackfillTrunkRevisions(ctx context.Context, db *sql.DB, slugRevisions map[string]int64) (int64, error)
- func BatchUpsertPackages(ctx context.Context, db *sql.DB, pkgs []*Package) error
- func BatchUpsertShellPackages(ctx context.Context, db *sql.DB, entries []ShellEntry) error
- func DeactivatePackage(ctx context.Context, db *sql.DB, id int64) error
- func FinishStatusCheck(ctx context.Context, db *sql.DB, id int64, started time.Time, ...) error
- func FinishSyncRun(ctx context.Context, db *sql.DB, rowID int64, status string, ...) error
- func GetMeta(ctx context.Context, db *sql.DB, key string) (string, error)
- func MarkPackagesChanged(ctx context.Context, db *sql.DB, pkgType string, ...) (int64, error)
- func MarkPermanentlyClosed(ctx context.Context, db *sql.DB, id int64) error
- func ReactivatePackage(ctx context.Context, db *sql.DB, id int64) error
- func RecordStatusCheckChange(ctx context.Context, db *sql.DB, statusCheckID int64, ...)
- func RefreshSiteStats(ctx context.Context, db *sql.DB) error
- func SetMeta(ctx context.Context, db *sql.DB, key, value string) error
- func StartStatusCheck(ctx context.Context, db *sql.DB, started time.Time) (int64, error)
- func UpsertPackage(ctx context.Context, db *sql.DB, pkg *Package) error
- func UpsertShellPackage(ctx context.Context, db *sql.DB, pkgType, name string, ...) error
- type Package
- func GetAllPackages(ctx context.Context, db *sql.DB, pkgType string) ([]*Package, error)
- func GetDeactivatedDeployedPackages(ctx context.Context, db *sql.DB) ([]*Package, error)
- func GetDirtyPackages(ctx context.Context, db *sql.DB) ([]*Package, error)
- func GetPackagesNeedingUpdate(ctx context.Context, db *sql.DB, opts UpdateQueryOpts) ([]*Package, error)
- func PackageFromAPIData(data map[string]any, pkgType string) *Package
- type Seeds
- type ShellEntry
- type StatusCheck
- type StatusCheckChange
- type SyncRun
- type UpdateQueryOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackfillTrunkRevisions ¶
func BackfillTrunkRevisions(ctx context.Context, db *sql.DB, slugRevisions map[string]int64) (int64, error)
BackfillTrunkRevisions sets trunk_revision for active plugins that don't have one yet. Only updates rows where trunk_revision IS NULL to avoid overwriting newer data.
func BatchUpsertPackages ¶
BatchUpsertPackages inserts or updates full package records in a single transaction.
func BatchUpsertShellPackages ¶
BatchUpsertShellPackages inserts or updates shell package records in a single transaction.
func DeactivatePackage ¶
DeactivatePackage sets is_active = 0 for a package.
func FinishStatusCheck ¶
func FinishStatusCheck(ctx context.Context, db *sql.DB, id int64, started time.Time, checked, deactivated, reactivated, failed int64, runErr error) error
FinishStatusCheck updates a status_checks row with the final results.
func FinishSyncRun ¶
func FinishSyncRun(ctx context.Context, db *sql.DB, rowID int64, status string, stats map[string]any) error
FinishSyncRun marks a sync run as completed with stats.
func MarkPackagesChanged ¶
func MarkPackagesChanged(ctx context.Context, db *sql.DB, pkgType string, slugRevisions map[string]int64) (int64, error)
MarkPackagesChanged sets last_committed = now and trunk_revision for the given slugs of a specific type, so they'll be picked up by GetPackagesNeedingUpdate. slugRevisions maps each slug to its highest SVN revision from the changelog.
func MarkPermanentlyClosed ¶
MarkPermanentlyClosed tombstones a package so it's excluded from discovery and polling entirely. The row is kept (with is_active = 0 and permanently_closed = 1) so SVN discovery dedup still works and audit history via status_check_changes is preserved.
func ReactivatePackage ¶
ReactivatePackage sets is_active = 1 for a package.
func RecordStatusCheckChange ¶
func RecordStatusCheckChange(ctx context.Context, db *sql.DB, statusCheckID int64, pkgType, pkgName, action string)
RecordStatusCheckChange inserts a per-package deactivation or reactivation event.
func RefreshSiteStats ¶
RefreshSiteStats recomputes the package_stats row from the packages table.
func StartStatusCheck ¶
StartStatusCheck inserts a new status_checks row and returns its ID.
func UpsertPackage ¶
UpsertPackage inserts or updates a package record by (type, name).
Types ¶
type Package ¶
type Package struct {
ID int64
Type string
Name string
DisplayName *string
Description *string
Author *string
Homepage *string
SlugURL *string
VersionsJSON string
Downloads int64
ActiveInstalls int64
CurrentVersion *string
WporgVersion *string
Rating *float64
NumRatings int
IsActive bool
PermanentlyClosed bool
LastCommitted *time.Time
LastSyncedAt *time.Time
LastSyncRunID *int64
TrunkRevision *int64
ContentHash *string
DeployedHash *string
ContentChangedAt *time.Time
WpPackagesInstallsTotal int
WpPackagesInstalls30d int
LastInstalledAt *time.Time
CreatedAt time.Time
UpdatedAt time.Time
// RawVersions holds the pre-normalization version map from the API.
// Not persisted directly — normalized into VersionsJSON before storage.
RawVersions map[string]string `json:"-"`
}
func GetAllPackages ¶
GetAllPackages returns all packages, optionally filtered by type.
func GetDeactivatedDeployedPackages ¶
GetDeactivatedDeployedPackages returns inactive packages that still have a deployed_hash (i.e. their p2 files are still on R2 and need to be deleted).
func GetDirtyPackages ¶
GetDirtyPackages returns active packages whose content_hash differs from deployed_hash.
func GetPackagesNeedingUpdate ¶
func GetPackagesNeedingUpdate(ctx context.Context, db *sql.DB, opts UpdateQueryOpts) ([]*Package, error)
GetPackagesNeedingUpdate returns packages that should be updated.
func PackageFromAPIData ¶
PackageFromAPIData maps a WordPress.org API response to a Package struct.
func (*Package) ComposerMeta ¶
func (p *Package) ComposerMeta() composer.PackageMeta
ComposerMeta builds a composer.PackageMeta from a Package's nullable DB fields.
func (*Package) NormalizeAndStoreVersions ¶
NormalizeAndStoreVersions normalizes raw versions and serializes to VersionsJSON. It also sets CurrentVersion to the highest available version. Returns the number of valid versions.
type Seeds ¶
type ShellEntry ¶
ShellEntry holds minimal package data for batch SVN discovery upserts.
type StatusCheck ¶
type StatusCheck struct {
ID int64
StartedAt string
FinishedAt string
Status string
Checked int64
Deactivated int64
Reactivated int64
Failed int64
DurationSeconds *int
ErrorMessage string
}
StatusCheck represents a row from the status_checks table.
func GetStatusChecks ¶
GetStatusChecks returns the most recent status check runs.
type StatusCheckChange ¶
StatusCheckChange represents a per-package event from a status check run.
func GetStatusCheckChanges ¶
func GetStatusCheckChanges(ctx context.Context, db *sql.DB, statusCheckID int64) ([]StatusCheckChange, error)
GetStatusCheckChanges returns the per-package changes for a given status check.