add filters for courses
This commit is contained in:
@ -13,22 +13,24 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
learningTypeOptName = "learning-type"
|
learningTypeOptName = "learning-type"
|
||||||
courseThematicOptName = "course-thematic"
|
courseThematicOptName = "course-thematic"
|
||||||
|
learningTypeSelectionOptName = "learning-selection"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupAPICommand(ctx context.Context) cli.Command {
|
func setupAPICommand(ctx context.Context) cli.Command {
|
||||||
learningTypeOpt := cli.NewOption(learningTypeOptName, "Specify learning type").
|
learningTypeOpt := cli.NewOption(learningTypeOptName, "Specify learning type").
|
||||||
WithChar('l').
|
|
||||||
WithType(cli.TypeString)
|
WithType(cli.TypeString)
|
||||||
courseThematic := cli.NewOption(courseThematicOptName, "Specify course thematic").
|
courseThematic := cli.NewOption(courseThematicOptName, "Specify course thematic").
|
||||||
WithChar('t').
|
WithType(cli.TypeString)
|
||||||
|
learningSelectionOpt := cli.NewOption(learningTypeSelectionOptName, "Specify learning type selection").
|
||||||
WithType(cli.TypeString)
|
WithType(cli.TypeString)
|
||||||
|
|
||||||
apiEducationListProducts := buildCLICommand(func() cli.Command {
|
apiEducationListProducts := buildCLICommand(func() cli.Command {
|
||||||
return cli.NewCommand("list_products", "List products by some filters").
|
return cli.NewCommand("list_products", "List products by some filters").
|
||||||
WithOption(learningTypeOpt).
|
WithOption(learningTypeOpt).
|
||||||
WithOption(courseThematic).
|
WithOption(courseThematic).
|
||||||
|
WithOption(learningSelectionOpt).
|
||||||
WithOption(limitOption).
|
WithOption(limitOption).
|
||||||
WithOption(offsetOption).
|
WithOption(offsetOption).
|
||||||
WithAction(newListProductAction(ctx))
|
WithAction(newListProductAction(ctx))
|
||||||
@ -67,10 +69,11 @@ func asCLIAction(a action) cli.Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type listProductsActionParams struct {
|
type listProductsActionParams struct {
|
||||||
learningType string
|
learningType string
|
||||||
courseThematic string
|
courseThematic string
|
||||||
limit int
|
learningSelectionType string
|
||||||
offset int
|
limit int
|
||||||
|
offset int
|
||||||
}
|
}
|
||||||
|
|
||||||
type listProductsAction struct {
|
type listProductsAction struct {
|
||||||
@ -102,6 +105,7 @@ func (a *listProductsAction) parse(args []string, options map[string]string) err
|
|||||||
}
|
}
|
||||||
|
|
||||||
a.params.courseThematic = options[courseThematicOptName]
|
a.params.courseThematic = options[courseThematicOptName]
|
||||||
|
a.params.learningSelectionType = options[learningTypeSelectionOptName]
|
||||||
|
|
||||||
if value, ok := options[limitOption.Key()]; ok {
|
if value, ok := options[limitOption.Key()]; ok {
|
||||||
a.params.limit, _ = strconv.Atoi(value)
|
a.params.limit, _ = strconv.Atoi(value)
|
||||||
|
|||||||
@ -82,24 +82,85 @@ type ListEducationProductsParams struct {
|
|||||||
Offset int
|
Offset int
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListEducationProductsRequest struct {
|
type stringifiedBool string
|
||||||
Fingerprint string `json:"fingerPrint,omitempty"`
|
|
||||||
ProductName string `json:"productName,omitempty"`
|
|
||||||
AdvertisingOnly bool `json:"advertisingOnly"`
|
|
||||||
Location string `json:"location"`
|
|
||||||
OfferTypes []string `json:"offerTypes"`
|
|
||||||
IsMix bool `json:"isMix"`
|
|
||||||
MixRepeated bool `json:"mixRepeated"`
|
|
||||||
Fields []string `json:"fields"`
|
|
||||||
SortProperty string `json:"sortProperty"`
|
|
||||||
SortDirection string `json:"sortDirection"`
|
|
||||||
LearningType []string `json:"learningtype"`
|
|
||||||
CoursesThematics []string `json:"coursesThematics"`
|
|
||||||
NotSubIsWebinar string `json:"not-sub-isWebinar"`
|
|
||||||
NotB2B string `json:"not-b2b"`
|
|
||||||
|
|
||||||
Limit int `json:"limit"`
|
func AsStringifiedBool(b bool) stringifiedBool {
|
||||||
Offset int `json:"offset"`
|
return stringifiedBool(strconv.FormatBool(b))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FilterLevel is a Уровень сложности
|
||||||
|
type FilterLevel string
|
||||||
|
|
||||||
|
const (
|
||||||
|
FilterLevelJunior FilterLevel = "levelJuniorNew"
|
||||||
|
FilterLevelMiddle FilterLevel = "levelMiddleNew"
|
||||||
|
FilterLevelChildren FilterLevel = "levelChildNew"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FilterTime is a срок обучения
|
||||||
|
type FilterTime string
|
||||||
|
|
||||||
|
const (
|
||||||
|
FilterTimeLessMonth FilterTime = "1" // less than month
|
||||||
|
FilterTimeFrom1To3Month FilterTime = "2" // from month to three month
|
||||||
|
FilterTimeFrom3To6 FilterTime = "3" // from three to six months
|
||||||
|
FilterTimeFrom6To12 FilterTime = "4" // from six to twelve months
|
||||||
|
FilterTimeFrom12 FilterTime = "5" // from twelve months
|
||||||
|
)
|
||||||
|
|
||||||
|
// FilterFormat is a Форма обучение
|
||||||
|
type FilterFormat string
|
||||||
|
|
||||||
|
const (
|
||||||
|
FilterFormatRecord FilterFormat = "formatRecordNew"
|
||||||
|
FilterFormatOnline FilterFormat = "formatOnlineNew"
|
||||||
|
FilterFormatOffline FilterFormat = "formatOfflineNew"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FilterGraphic is a График прохождения
|
||||||
|
type FilterGraphic string
|
||||||
|
|
||||||
|
const (
|
||||||
|
FilterGraphicTimeLength FilterGraphic = "courseTimeLengthNew"
|
||||||
|
FilterGraphicTerm FilterGraphic = "courseTimeTermNew"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ListEducationProductsRequest struct {
|
||||||
|
Fingerprint string `json:"fingerPrint,omitempty"`
|
||||||
|
ProductName string `json:"productName,omitempty"`
|
||||||
|
Location string `json:"location"`
|
||||||
|
OfferTypes []string `json:"offerTypes"`
|
||||||
|
IsMix bool `json:"isMix"`
|
||||||
|
MixRepeated bool `json:"mixRepeated"`
|
||||||
|
Fields []string `json:"fields"`
|
||||||
|
|
||||||
|
// Filters
|
||||||
|
LearningType []string `json:"learningtype"`
|
||||||
|
CoursesThematics []string `json:"coursesThematics"`
|
||||||
|
Organizations []string `json:"organizations"` // list of ids
|
||||||
|
DictionatyFormatFilterNew []FilterFormat `json:"dictionaryFormatFilterNew"`
|
||||||
|
DictionaryTimeFilter []FilterTime `json:"dictionaryTimeFilter"`
|
||||||
|
DictionaryGraphicFilterNew []FilterGraphic `json:"dictionaryGraphicFilterNew"`
|
||||||
|
DictionatyLevelFilterNew []FilterLevel `json:"dictionaryLevelFilterNew"`
|
||||||
|
|
||||||
|
// Options
|
||||||
|
SubMentor []stringifiedBool `json:"sub-mentor"` // option with mentor
|
||||||
|
SubTimeFree []stringifiedBool `json:"sub-timeFree"` // option with trial
|
||||||
|
SubJobGarantSub []stringifiedBool `json:"sub-jobGarantsub"` // option for job garantee
|
||||||
|
SubPriceFree []stringifiedBool `json:"sub-priceFree"` // only free
|
||||||
|
SubInstallment []stringifiedBool `json:"sub-installment"` // with credit
|
||||||
|
SubIsCourseProfession []stringifiedBool `json:"sub-isCourseProfession"` // освоить профессию с нуля
|
||||||
|
DevelopSkills []stringifiedBool `json:"developSkills"` // развить навыки
|
||||||
|
|
||||||
|
NotSubIsWebinar string `json:"not-sub-isWebinar"`
|
||||||
|
NotB2B string `json:"not-b2b"`
|
||||||
|
AdvertisingOnly bool `json:"advertisingOnly"`
|
||||||
|
|
||||||
|
// Pagination and sorting
|
||||||
|
Limit int `json:"limit"`
|
||||||
|
Offset int `json:"offset"`
|
||||||
|
SortProperty string `json:"sortProperty"`
|
||||||
|
SortDirection string `json:"sortDirection"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListEducationProductsResponse struct {
|
type ListEducationProductsResponse struct {
|
||||||
|
|||||||
@ -27,7 +27,9 @@ type Course struct {
|
|||||||
// FullPrice is a course full price without discount.
|
// FullPrice is a course full price without discount.
|
||||||
FullPrice float64
|
FullPrice float64
|
||||||
// Discount for the course.
|
// Discount for the course.
|
||||||
Discount float64
|
Discount float64
|
||||||
|
Thematic string
|
||||||
|
LearningType string
|
||||||
|
|
||||||
// Duration for the course. It will be splitted in values like:
|
// Duration for the course. It will be splitted in values like:
|
||||||
// full month / full day / full hour.
|
// full month / full day / full hour.
|
||||||
|
|||||||
@ -79,7 +79,8 @@ func (s NextRunStats) String() string {
|
|||||||
func (bp *BackgroundProcess) GetNextRunStats() NextRunStats {
|
func (bp *BackgroundProcess) GetNextRunStats() NextRunStats {
|
||||||
out := make(NextRunStats)
|
out := make(NextRunStats)
|
||||||
if bp.syncSravniHandlerEntryID.Valid() {
|
if bp.syncSravniHandlerEntryID.Valid() {
|
||||||
sEntry := bp.scheduler.Entry(bp.syncSravniHandlerEntryID.Value())
|
entryID := bp.syncSravniHandlerEntryID.Value()
|
||||||
|
sEntry := bp.scheduler.Entry(entryID)
|
||||||
out["sravni_handler"] = sEntry.Next
|
out["sravni_handler"] = sEntry.Next
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,11 +119,11 @@ func (bp *BackgroundProcess) registerHandler(ctx context.Context, spec, name str
|
|||||||
xcontext.LogInfo(jctx, bp.log, "iteration completed")
|
xcontext.LogInfo(jctx, bp.log, "iteration completed")
|
||||||
}))
|
}))
|
||||||
|
|
||||||
var out nullable.Value[cron.EntryID]
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return out, fmt.Errorf("adding %s job: %w", name, err)
|
return nullable.Value[cron.EntryID]{}, fmt.Errorf("adding %s job: %w", name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var out nullable.Value[cron.EntryID]
|
||||||
out.Set(entry)
|
out.Set(entry)
|
||||||
|
|
||||||
return out, nil
|
return out, nil
|
||||||
|
|||||||
3
internal/kurious/ports/http/server.go
Normal file
3
internal/kurious/ports/http/server.go
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
package http
|
||||||
|
|
||||||
|
type Server struct{}
|
||||||
8
internal/kurious/ports/services.go
Normal file
8
internal/kurious/ports/services.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package ports
|
||||||
|
|
||||||
|
import "git.loyso.art/frx/kurious/internal/kurious/ports/http"
|
||||||
|
|
||||||
|
type Services struct {
|
||||||
|
HTTP *http.Server
|
||||||
|
Background *BackgroundProcess
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user