add sqlite support
This commit is contained in:
@ -8,10 +8,20 @@ import (
|
||||
"git.loyso.art/frx/kurious/internal/common/config"
|
||||
)
|
||||
|
||||
type dbEngine string
|
||||
|
||||
const (
|
||||
DBEngineUnknown dbEngine = ""
|
||||
DBEngineYDB dbEngine = "ydb"
|
||||
DBEngineSqlite dbEngine = "sqlite"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Log config.Log `json:"log"`
|
||||
YDB config.YDB `json:"ydb"`
|
||||
SyncSravniCron string `json:"sync_sravni_cron"`
|
||||
Log config.Log `json:"log"`
|
||||
YDB config.YDB `json:"ydb"`
|
||||
Sqlite config.Sqlite `json:"sqlite"`
|
||||
DBEngine dbEngine `json:"db_engine"`
|
||||
SyncSravniCron string `json:"sync_sravni_cron"`
|
||||
|
||||
DebugHTTP bool `json:"debug_http"`
|
||||
}
|
||||
@ -37,5 +47,7 @@ func defaultConfig() Config {
|
||||
Level: config.LogLevelInfo,
|
||||
Format: config.LogFormatText,
|
||||
},
|
||||
// TODO: change to sqlite once it proven to be working
|
||||
DBEngine: DBEngineYDB,
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,9 +69,19 @@ func app(ctx context.Context) error {
|
||||
|
||||
mapper := adapters.NewMemoryMapper(courseThematcisMapped, learningTypeMapped)
|
||||
|
||||
var dbEngine service.RepositoryEngine
|
||||
switch cfg.DBEngine {
|
||||
case DBEngineSqlite:
|
||||
dbEngine = service.RepositoryEngineSqlite
|
||||
case DBEngineYDB:
|
||||
dbEngine = service.RepositoryEngineYDB
|
||||
}
|
||||
|
||||
app, err := service.NewApplication(ctx, service.ApplicationConfig{
|
||||
LogConfig: cfg.Log,
|
||||
YDB: cfg.YDB,
|
||||
Sqlite: cfg.Sqlite,
|
||||
Engine: dbEngine,
|
||||
}, mapper)
|
||||
if err != nil {
|
||||
return fmt.Errorf("making new application: %w", err)
|
||||
|
||||
@ -136,11 +136,14 @@ func (a *listProductsAction) parse(args []string, options map[string]string) err
|
||||
|
||||
func (a *listProductsAction) handle() error {
|
||||
params := sravni.ListEducationProductsParams{
|
||||
LearningType: a.params.learningType,
|
||||
CoursesThematics: []string{a.params.courseThematic},
|
||||
Limit: a.params.limit,
|
||||
Offset: a.params.offset,
|
||||
LearningType: a.params.learningType,
|
||||
Limit: a.params.limit,
|
||||
Offset: a.params.offset,
|
||||
}
|
||||
if a.params.courseThematic != "" {
|
||||
params.CoursesThematics = append(params.CoursesThematics, a.params.courseThematic)
|
||||
}
|
||||
|
||||
result, err := a.client.ListEducationalProducts(a.ctx, params)
|
||||
if err != nil {
|
||||
return fmt.Errorf("listing education products: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user