Documentation
¶
Index ¶
- Constants
- func Activate(id int) error
- func AdLocationDisplay(a Ad) string
- func AppendHistoryEntry(desc, label, body string, at time.Time, tz *time.Location) string
- func BuildFieldChangeEntries(oldAd Ad, newTitle string, newLocationText string, ...) []struct{ ... }
- func ComputeExpiresAt(now time.Time) time.Time
- func ConfirmImages(userID, adID, newCount int, tz *time.Location) error
- func CountActiveAdsByUser(userID int) (int, error)
- func CreateAd(input CreateInput) (int, error)
- func DefaultCategoryID() int
- func DisplayDescription(desc string) string
- func EncodeSuggestionFormValue(label, value string) string
- func EnsureDescriptionFits(desc string, at time.Time, tz *time.Location) (string, error)
- func FormalFacetLines(category Category, values map[string]facet.Value) []string
- func FormatTagUpdates(old, new []Suggestion) string
- func GetAdsWithoutVectors() ([]int, error)
- func GetCategoryIDByName(name string) (int, error)
- func GetCategoryImageFile(categoryID int) (string, error)
- func GetCategoryName(categoryID int) (string, error)
- func GetUserAdIDs(userID int, filterType string) ([]int, error)
- func HasLocationFacet(category Category) bool
- func IncrementAdClickForUser(adID, userID int) error
- func IncrementAdImageClickForUser(adID, userID, imageIndex int) error
- func LoadCategories() error
- func LoadTags(a *Ad) error
- func LocationFacetKey(category Category) string
- func LocationTextFromFacets(category Category, facets map[string]facet.Value) string
- func ParseCategory(categoryStr string) int
- func ParseSuggestionFormValue(raw string) (label, value string, ok bool)
- func Pause(id int) error
- func PermanentlyDelete(id int) error
- func PermanentlyDeleteByUser(userID int) ([]int, error)
- func Renew(id int) error
- func RenewEligible(expiresAt, now time.Time) bool
- func SanitizeAdText(s string) string
- func SplitDescription(desc string) (original, history string)
- func TagsJSON(suggestions []Suggestion) string
- func TitleContainsEmoji(s string) bool
- func UpdateAd(input UpdateInput) error
- func WrapDescription(body string, at time.Time, tz *time.Location) string
- type Ad
- type Category
- type ClickSummary
- type CreateInput
- type DescriptionDisplay
- type DescriptionLink
- type DescriptionSegment
- type DueExpire
- type EmbeddingInput
- type EmbeddingStats
- type HistoryEntryDisplay
- type MissingEmbedding
- type MonthlyFunStat
- type RecentClick
- type SuggestInput
- type Suggestion
- type TopAdClick
- type TopImageClick
- type TopUserClick
- type UpdateInput
Constants ¶
const DescriptionAdditionLabel = "Description Addition"
DescriptionAdditionLabel is the legacy append-via-edit history marker.
const DescriptionChangeLabel = "Description change"
DescriptionChangeLabel is the history label for a description rewrite.
const OriginalLabel = "original"
Variables ¶
This section is empty.
Functions ¶
func AdLocationDisplay ¶
AdLocationDisplay returns the location line for cards, detail, and flyers.
func AppendHistoryEntry ¶
AppendHistoryEntry prepends a labeled, timestamped history block (newest first).
func BuildFieldChangeEntries ¶
func BuildFieldChangeEntries(oldAd Ad, newTitle string, newLocationText string, newFacets map[string]facet.Value, category Category) []struct { label string body string }
BuildFieldChangeEntries returns history entry bodies for changed ad fields.
func ComputeExpiresAt ¶
ComputeExpiresAt is the listing lifetime measured from now.
func ConfirmImages ¶
ConfirmImages sets image_count after client uploads succeed. newCount must be >= current count and <= MaxImagesPerAd.
func CountActiveAdsByUser ¶
CountActiveAdsByUser returns the number of live ads for a user
func CreateAd ¶
func CreateAd(input CreateInput) (int, error)
func DefaultCategoryID ¶
func DefaultCategoryID() int
func DisplayDescription ¶
DisplayDescription renders stored description as plain text for display.
func EnsureDescriptionFits ¶
EnsureDescriptionFits compresses description text until it fits MaxAdDescriptionLength.
func FormalFacetLines ¶
FormalFacetLines formats all formal facet fields for the suggestions prompt, including empty ones so the model knows which fields exist on the form.
func FormatTagUpdates ¶
func FormatTagUpdates(old, new []Suggestion) string
FormatTagUpdates describes added and removed tag pills.
func GetAdsWithoutVectors ¶
func GetCategoryIDByName ¶
GetCategoryIDByName returns the ID of a category by its name
func GetCategoryImageFile ¶
func GetCategoryName ¶
func GetUserAdIDs ¶
GetUserAdIDs returns ad IDs for a user based on filter type filterType: "bookmarked", "active", "inactive", or "deleted"
func HasLocationFacet ¶
HasLocationFacet reports whether the category uses a location facet.
func IncrementAdClickForUser ¶
func LoadCategories ¶
func LoadCategories() error
func LocationFacetKey ¶
LocationFacetKey returns the facet key used for geo lookup on this category.
func LocationTextFromFacets ¶
LocationTextFromFacets returns trimmed location text from facets.
func ParseCategory ¶
func PermanentlyDelete ¶
PermanentlyDelete soft-deletes an ad as a zombie that cannot be restored.
func PermanentlyDeleteByUser ¶
PermanentlyDeleteByUser soft-deletes all non-zombie ads owned by userID.
func RenewEligible ¶
RenewEligible is true when expires_at is within AdExpireRenewWithinMonths.
func SanitizeAdText ¶
SanitizeAdText normalizes common paste artifacts and removes invisible or control characters unsuitable for stored ad title/description.
func SplitDescription ¶
SplitDescription separates the original body from server history.
func TagsJSON ¶
func TagsJSON(suggestions []Suggestion) string
TagsJSON serializes tags for storage in ads.tags.
func TitleContainsEmoji ¶
TitleContainsEmoji reports whether s includes emoji or other pictographs unsuitable for ad titles (e.g. flag or warning icons).
func UpdateAd ¶
func UpdateAd(input UpdateInput) error
Types ¶
type Ad ¶
type Ad struct {
// Core database fields
ID int `db:"id"`
CategoryID int `db:"category_id"`
Title string `db:"title"`
Description string `db:"description"`
CreatedAt time.Time `db:"created_at"`
ExpiresAt time.Time `db:"expires_at"`
InactiveAt *time.Time `db:"inactive_at"`
DeletedAt *time.Time `db:"deleted_at"`
UserID int `db:"user_id"`
ImageCount int `db:"image_count"`
LocationID *int `db:"location_id"`
// Location fields from join
City string `db:"city"`
AdminArea string `db:"admin_area"`
Country string `db:"country"`
RawLocation string `db:"raw_location"`
// Computed fields
Bookmarked bool `db:"bookmarked"`
FlagCount int `db:"flag_count"`
// Category-specific facet values
Facets map[string]facet.Value
// Tags selected for the ad; loaded lazily on ad detail (ads.tags JSON)
Tags []Suggestion
}
func (Ad) IsInactive ¶
type Category ¶
type Category struct {
ID int `json:"id"`
Name string `json:"name"`
ImageFile string `json:"image_file"`
FacetKeys []string `json:"facets"`
}
func GetCategories ¶
func GetCategory ¶
type ClickSummary ¶
type ClickSummary struct {
UsersWithClicks int
AdsClicked int
AdDetailViews int
ActiveLast7Days int
}
func GetClickSummary ¶
func GetClickSummary() (ClickSummary, error)
type CreateInput ¶
type DescriptionDisplay ¶
type DescriptionDisplay struct {
// Original is the current listing text.
Original string
// Body is the current listing text (same as Original).
Body string
History []HistoryEntryDisplay
}
DescriptionDisplay holds original ad text and edit history for display.
func ParseDescriptionForDisplay ¶
func ParseDescriptionForDisplay(desc string) DescriptionDisplay
ParseDescriptionForDisplay splits stored description into original and history.
type DescriptionLink ¶
DescriptionLink is a validated https URL rendered as link text.
type DescriptionSegment ¶
type DescriptionSegment struct {
Text string
Link *DescriptionLink
}
DescriptionSegment is plain text or a link within a description.
func SplitDescriptionLinks ¶
func SplitDescriptionLinks(s string) []DescriptionSegment
SplitDescriptionLinks splits s into text and auto-detected https URL segments.
type DueExpire ¶
DueExpire holds an active ad past its expires_at.
func ListAdsDueToExpire ¶
ListAdsDueToExpire returns active ads whose expires_at is in the past.
type EmbeddingInput ¶
type EmbeddingInput struct {
ID int
CategoryID int
Title string
Description string
TagLabels []string
City string
AdminArea string
Country string
Latitude float64
Longitude float64
HasLocation bool
FlagCount int
Facets map[string]facet.Value
FacetDefs []facet.Def
}
func GetForEmbedding ¶
func GetForEmbedding(adID int) (EmbeddingInput, error)
func (EmbeddingInput) PriceValue ¶
func (in EmbeddingInput) PriceValue() (amount int, currency string, ok bool)
type EmbeddingStats ¶
func GetEmbeddingStats ¶
func GetEmbeddingStats() (EmbeddingStats, error)
type HistoryEntryDisplay ¶
HistoryEntryDisplay is one parsed edit-history block for UI rendering.
type MissingEmbedding ¶
type MissingEmbedding struct {
ID int `db:"id"`
Title string `db:"title"`
CategoryID int `db:"category_id"`
CategoryName string `db:"category_name"`
}
func ListMissingEmbeddings ¶
func ListMissingEmbeddings(limit int) ([]MissingEmbedding, error)
type MonthlyFunStat ¶
type MonthlyFunStat struct {
Month time.Time `db:"month"`
RegisteredUsers int `db:"registered_users"`
UsersWithActiveAds int `db:"users_with_active_ads"`
ActiveAds int `db:"active_ads"`
}
MonthlyFunStat is a month-end snapshot of public site totals.
func MonthlyFunStats ¶
func MonthlyFunStats() ([]MonthlyFunStat, error)
MonthlyFunStats returns one row per calendar month from the earliest user or ad through the current month. Counts are as-of the end of each past month (or now for the current month): a user or ad is included if it already existed and had not yet been deleted or inactivated.
type RecentClick ¶
type RecentClick struct {
LastClickedAt time.Time `db:"last_clicked_at"`
UserID int `db:"user_id"`
AdID int `db:"ad_id"`
Title string `db:"title"`
ClickType string `db:"click_type"`
ImageIndex *int `db:"image_index"`
ClickCount int `db:"click_count"`
}
func GetRecentClickActivity ¶
func GetRecentClickActivity(limit int) ([]RecentClick, error)
type SuggestInput ¶
type Suggestion ¶
func GenerateSuggestions ¶
func GenerateSuggestions(in SuggestInput) ([]Suggestion, error)
func ParseFormSuggestion ¶
func ParseFormSuggestion(raw string) (Suggestion, bool)
ParseFormSuggestion parses an encoded form checkbox value into a normalized suggestion.
func (Suggestion) Display ¶
func (s Suggestion) Display() string
func (Suggestion) Key ¶
func (s Suggestion) Key() string
func (Suggestion) PromptDisplay ¶
func (s Suggestion) PromptDisplay() string
PromptDisplay formats a suggestion for LLM context (includes ": yes" for binary).
type TopAdClick ¶
type TopAdClick struct {
AdID int `db:"ad_id"`
Title string `db:"title"`
CategoryName string `db:"category_name"`
UserCount int `db:"user_count"`
AdViews int `db:"ad_views"`
ImageClicks int `db:"image_clicks"`
LastActivity *time.Time `db:"last_activity"`
}
func GetTopAdsByClicks ¶
func GetTopAdsByClicks(limit int) ([]TopAdClick, error)
type TopImageClick ¶
type TopImageClick struct {
AdID int `db:"ad_id"`
Title string `db:"title"`
ImageIndex int `db:"image_index"`
UserCount int `db:"user_count"`
Clicks int `db:"clicks"`
LastClickedAt *time.Time `db:"last_clicked_at"`
}
func GetTopImagesByClicks ¶
func GetTopImagesByClicks(limit int) ([]TopImageClick, error)
type TopUserClick ¶
type TopUserClick struct {
UserID int `db:"user_id"`
AdClicks int `db:"ad_clicks"`
ImageClicks int `db:"image_clicks"`
LastActive *time.Time `db:"last_active"`
}
func GetTopUsersByClicks ¶
func GetTopUsersByClicks(limit int) ([]TopUserClick, error)