add show course and map names
This commit is contained in:
@ -10,9 +10,11 @@ import (
|
||||
"os/signal"
|
||||
"time"
|
||||
|
||||
"git.loyso.art/frx/kurious/internal/common/client/sravni"
|
||||
"git.loyso.art/frx/kurious/internal/common/config"
|
||||
"git.loyso.art/frx/kurious/internal/common/generator"
|
||||
"git.loyso.art/frx/kurious/internal/common/xcontext"
|
||||
"git.loyso.art/frx/kurious/internal/kurious/adapters"
|
||||
xhttp "git.loyso.art/frx/kurious/internal/kurious/ports/http"
|
||||
"git.loyso.art/frx/kurious/internal/kurious/service"
|
||||
"golang.org/x/sync/errgroup"
|
||||
@ -46,10 +48,35 @@ func app(ctx context.Context) error {
|
||||
|
||||
log := config.NewSLogger(cfg.Log)
|
||||
|
||||
sravniClient, err := sravni.NewClient(ctx, log, false)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to make new sravni client: %w", err)
|
||||
}
|
||||
|
||||
mainPageState, err := sravniClient.GetMainPageState()
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting main page state: %w", err)
|
||||
}
|
||||
|
||||
dictionaries := mainPageState.Props.InitialReduxState.Dictionaries.Data
|
||||
|
||||
dictFieldsAsMap := func(fields ...sravni.Field) map[string]string {
|
||||
out := make(map[string]string, len(fields))
|
||||
for _, field := range fields {
|
||||
out[field.Value] = field.Name
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
courseThematcisMapped := dictFieldsAsMap(dictionaries.CourseThematics.Fields...)
|
||||
learningTypeMapped := dictFieldsAsMap(dictionaries.LearningType.Fields...)
|
||||
|
||||
mapper := adapters.NewMemoryMapper(courseThematcisMapped, learningTypeMapped)
|
||||
|
||||
app, err := service.NewApplication(ctx, service.ApplicationConfig{
|
||||
LogConfig: cfg.Log,
|
||||
YDB: cfg.YDB,
|
||||
})
|
||||
}, mapper)
|
||||
if err != nil {
|
||||
return fmt.Errorf("making new application: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user