Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/unfinished sessions #10328

Merged
merged 9 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
removed session.Database interface
  • Loading branch information
GrimmiMeloni committed Oct 14, 2023
commit a3351447f9fbecc3ad9b5e7301210eee43832d88
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