learning

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
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

func IndexCacheAge(cacheDir string) time.Duration

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

func SearchCacheKey(query string, level, role string) string

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(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.

func SearchAPI

func SearchAPI(query string, limit int) ([]LearningJourney, error)

SearchAPI calls the learning.sap.com search endpoint and returns results.

Jump to

Keyboard shortcuts

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