-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imager: move all database operations into service layer
- Loading branch information
Showing
22 changed files
with
263 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package services | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jackc/pgx/v5" | ||
"github.com/jsec/f1-data-hub/internal/database" | ||
) | ||
|
||
type CircuitService struct { | ||
db *database.Queries | ||
} | ||
|
||
func NewCircuitService(db *database.Queries) CircuitService { | ||
return CircuitService{db} | ||
} | ||
|
||
func (c *CircuitService) SeedCircuits(ctx context.Context, tx pgx.Tx, records []database.SaveCircuitsParams) error { | ||
_, err := c.db.SaveCircuits(ctx, records) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package services | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jackc/pgx/v5" | ||
"github.com/jsec/f1-data-hub/internal/database" | ||
) | ||
|
||
type ConstructorService struct { | ||
db *database.Queries | ||
} | ||
|
||
func NewConstructorService(db *database.Queries) ConstructorService { | ||
return ConstructorService{db} | ||
} | ||
|
||
func (s *ConstructorService) SeedConstructors(ctx context.Context, tx pgx.Tx, records []database.SaveConstructorsParams) error { | ||
_, err := s.db.WithTx(tx).SaveConstructors(ctx, records) | ||
return err | ||
} | ||
|
||
func (s *ConstructorService) SeedConstructorResults(ctx context.Context, tx pgx.Tx, records []database.SaveConstructorResultsParams) error { | ||
_, err := s.db.WithTx(tx).SaveConstructorResults(ctx, records) | ||
return err | ||
} | ||
|
||
func (s *ConstructorService) SeedConstructorStandings(ctx context.Context, tx pgx.Tx, records []database.SaveConstructorStandingsParams) error { | ||
_, err := s.db.WithTx(tx).SaveConstructorStandings(ctx, records) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package services | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jackc/pgx/v5" | ||
"github.com/jsec/f1-data-hub/internal/database" | ||
) | ||
|
||
type DriverService struct { | ||
db *database.Queries | ||
} | ||
|
||
func NewDriverService(db *database.Queries) DriverService { | ||
return DriverService{db} | ||
} | ||
|
||
func (s *DriverService) SeedDrivers(ctx context.Context, tx pgx.Tx, records []database.SaveDriversParams) error { | ||
_, err := s.db.WithTx(tx).SaveDrivers(ctx, records) | ||
return err | ||
} | ||
|
||
func (s *DriverService) SeedDriverStandings(ctx context.Context, tx pgx.Tx, records []database.SaveDriverStandingsParams) error { | ||
_, err := s.db.WithTx(tx).SaveDriverStandings(ctx, records) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package services | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jackc/pgx/v5" | ||
"github.com/jsec/f1-data-hub/internal/database" | ||
) | ||
|
||
type LapTimeService struct { | ||
db *database.Queries | ||
} | ||
|
||
func NewLapTimeService(db *database.Queries) LapTimeService { | ||
return LapTimeService{db} | ||
} | ||
|
||
func (s *LapTimeService) SeedLapTimes(ctx context.Context, tx pgx.Tx, records []database.SaveLapTimesParams) error { | ||
_, err := s.db.WithTx(tx).SaveLapTimes(ctx, records) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package services | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jackc/pgx/v5" | ||
"github.com/jsec/f1-data-hub/internal/database" | ||
) | ||
|
||
type PitStopService struct { | ||
db *database.Queries | ||
} | ||
|
||
func NewPitStopService(db *database.Queries) PitStopService { | ||
return PitStopService{db} | ||
} | ||
|
||
func (s *PitStopService) SeedPitStops(ctx context.Context, tx pgx.Tx, records []database.SavePitStopsParams) error { | ||
_, err := s.db.WithTx(tx).SavePitStops(ctx, records) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package services | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jackc/pgx/v5" | ||
"github.com/jsec/f1-data-hub/internal/database" | ||
) | ||
|
||
type QualifyingService struct { | ||
db *database.Queries | ||
} | ||
|
||
func NewQualifyingService(db *database.Queries) QualifyingService { | ||
return QualifyingService{db} | ||
} | ||
|
||
func (s *QualifyingService) SeedQualifyingResults(ctx context.Context, tx pgx.Tx, records []database.SaveQualifyingResultsParams) error { | ||
_, err := s.db.WithTx(tx).SaveQualifyingResults(ctx, records) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package services | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jackc/pgx/v5" | ||
"github.com/jsec/f1-data-hub/internal/database" | ||
) | ||
|
||
type RaceService struct { | ||
db *database.Queries | ||
} | ||
|
||
func NewRaceService(db *database.Queries) RaceService { | ||
return RaceService{db} | ||
} | ||
|
||
func (s *RaceService) SeedRaces(ctx context.Context, tx pgx.Tx, records []database.SaveRacesParams) error { | ||
_, err := s.db.WithTx(tx).SaveRaces(ctx, records) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package services | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jackc/pgx/v5" | ||
"github.com/jsec/f1-data-hub/internal/database" | ||
) | ||
|
||
type ResultsService struct { | ||
db *database.Queries | ||
} | ||
|
||
func NewResultsService(db *database.Queries) ResultsService { | ||
return ResultsService{db} | ||
} | ||
|
||
func (s *ResultsService) SeedResults(ctx context.Context, tx pgx.Tx, records []database.SaveResultsParams) error { | ||
_, err := s.db.WithTx(tx).SaveResults(ctx, records) | ||
return err | ||
} | ||
|
||
func (s *ResultsService) SeedSprintResults(ctx context.Context, tx pgx.Tx, records []database.SaveSprintResultsParams) error { | ||
_, err := s.db.WithTx(tx).SaveSprintResults(ctx, records) | ||
return err | ||
} |
Oops, something went wrong.