Skip to content

Commit

Permalink
removed session.Database interface
Browse files Browse the repository at this point in the history
  • Loading branch information
GrimmiMeloni committed Oct 14, 2023
1 parent 1341a7a commit a335144
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/loadpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ type Loadpoint struct {
progress *Progress // Step-wise progress indicator

// session log
db session.Database
db *session.DB
session *session.Session

tasks *util.Queue[Task] // tasks to be executed
Expand Down
5 changes: 0 additions & 5 deletions core/session/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ type DB struct {
name string
}

type Database interface {
New(startEnergy float64) *Session
Persist(session interface{})
}

// NewStore creates a session store
func NewStore(name string, db *gorm.DB) (*DB, error) {
err := db.AutoMigrate(new(Session))
Expand Down
6 changes: 2 additions & 4 deletions core/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,11 @@ func NewSiteFromConfig(

if db.Instance != nil {
var err error
var sessionDb *session.DB
if sessionDb, err = session.NewStore(lp.Title(), db.Instance); err != nil {
if lp.db, err = session.NewStore(lp.Title(), db.Instance); err != nil {
return nil, err
}
lp.db = sessionDb
//Fix any dangling history
if err = sessionDb.ClosePendingSessionsInHistory(lp.chargeMeterTotal()); err != nil {
if err = lp.db.ClosePendingSessionsInHistory(lp.chargeMeterTotal()); err != nil {
return nil, err
}

Expand Down

0 comments on commit a335144

Please sign in to comment.