Documentation
¶
Index ¶
- Constants
- func IndexCacheAge(cacheDir string) time.Duration
- func SaveIndex(cacheDir string, journeys []LearningJourney) error
- func SaveSearchCache(cacheDir, key string, results []LearningJourney) error
- func SearchCacheKey(query string, level, role string) string
- type LearningJourney
- func FetchCatalog() ([]LearningJourney, error)
- func FilterByLevel(journeys []LearningJourney, level string) []LearningJourney
- func FilterByRole(journeys []LearningJourney, role string) []LearningJourney
- func FindBySlug(journeys []LearningJourney, slug string) *LearningJourney
- func LoadIndex(cacheDir string, ttl time.Duration) ([]LearningJourney, bool)
- func LoadIndexStale(cacheDir string) ([]LearningJourney, bool)
- func LoadSearchCache(cacheDir, key string) ([]LearningJourney, bool)
- func Search(journeys []LearningJourney, query string) []LearningJourney
- func SearchAPI(query string, limit int) ([]LearningJourney, error)
Constants ¶
const ( CacheTTL = 7 * 24 * time.Hour // 7 days SearchCacheTTL = 1 * time.Hour CatalogURL = "https://learning.sap.com/service/catalog-download/json" SearchURL = "https://learning.sap.com/service/learning/search/getCards" BaseURL = "https://learning.sap.com/learning-journeys/" )
Variables ¶
This section is empty.
Functions ¶
func IndexCacheAge ¶
IndexCacheAge returns the age of the index cache, or -1 if missing.
func SaveIndex ¶
func SaveIndex(cacheDir string, journeys []LearningJourney) error
SaveIndex writes the learning journey index to cache.
func SaveSearchCache ¶
func SaveSearchCache(cacheDir, key string, results []LearningJourney) error
SaveSearchCache writes search results with a deterministic key.
func SearchCacheKey ¶
SearchCacheKey returns a deterministic cache name for a search query.
Types ¶
type LearningJourney ¶
type LearningJourney struct {
ObjectID string `json:"objectId"`
Title string `json:"title"`
Slug string `json:"slug"`
Description string `json:"description"`
Level string `json:"level"`
DurationHours string `json:"durationHours"`
Roles []string `json:"roles"`
Product string `json:"product"`
ProductCategory string `json:"productCategory"`
ProductSubcat string `json:"productSubcat"`
Objectives string `json:"objectives"`
AvailableFrom string `json:"availableFrom"`
URL string `json:"url"`
}
LearningJourney is the cached index entry for a single learning journey.
func FetchCatalog ¶
func FetchCatalog() ([]LearningJourney, error)
FetchCatalog downloads the full catalog and returns only learning journeys.
func FilterByLevel ¶
func FilterByLevel(journeys []LearningJourney, level string) []LearningJourney
FilterByLevel returns journeys matching the given level (case-insensitive exact match).
func FilterByRole ¶
func FilterByRole(journeys []LearningJourney, role string) []LearningJourney
FilterByRole returns journeys where at least one role matches (case-insensitive).
func FindBySlug ¶
func FindBySlug(journeys []LearningJourney, slug string) *LearningJourney
FindBySlug returns the first journey with the given slug, or nil.
func LoadIndex ¶
func LoadIndex(cacheDir string, ttl time.Duration) ([]LearningJourney, bool)
LoadIndex reads the cached learning journey index. Returns nil, false if the cache is missing or older than ttl.
func LoadIndexStale ¶
func LoadIndexStale(cacheDir string) ([]LearningJourney, bool)
LoadIndexStale reads the cached index ignoring TTL (offline fallback).
func LoadSearchCache ¶
func LoadSearchCache(cacheDir, key string) ([]LearningJourney, bool)
LoadSearchCache reads cached search results if fresh.
func Search ¶
func Search(journeys []LearningJourney, query string) []LearningJourney
Search performs case-insensitive multi-word matching across title, description, slug, and product. Multi-word queries use AND semantics: every word must appear somewhere in the combined text. Results are ranked: title matches first, then others.