Compare commits
No commits in common. "ea2958b27d406cc4b3f19914bb7a1e98c2696440" and "0d5274eb27ed14c7443ac8172f193cfe4257accb" have entirely different histories.
ea2958b27d
...
0d5274eb27
@ -1,25 +0,0 @@
|
|||||||
package postgres
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetAllSourceNodes returns a list of all models.AnthroveSource
|
|
||||||
func GetAllSourceNodes(ctx context.Context, db *gorm.DB) ([]models.AnthroveSource, error) {
|
|
||||||
var sources []models.AnthroveSource
|
|
||||||
|
|
||||||
result := db.WithContext(ctx).Find(&sources)
|
|
||||||
|
|
||||||
if result.Error != nil {
|
|
||||||
return nil, result.Error
|
|
||||||
}
|
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
|
||||||
"tag_amount": result.RowsAffected,
|
|
||||||
}).Trace("database: get all source nodes")
|
|
||||||
|
|
||||||
return sources, nil
|
|
||||||
}
|
|
@ -3,6 +3,7 @@ package database
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"git.dragse.it/anthrove/otter-space-sdk/internal/graph"
|
"git.dragse.it/anthrove/otter-space-sdk/internal/graph"
|
||||||
|
|
||||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
||||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j/config"
|
"github.com/neo4j/neo4j-go-driver/v5/neo4j/config"
|
@ -3,9 +3,8 @@ package database
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.dragse.it/anthrove/otter-space-sdk/internal/postgres"
|
|
||||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||||
gormPostgres "gorm.io/driver/postgres"
|
"gorm.io/driver/postgres"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,7 +21,7 @@ func NewPostgresqlConnection() OtterSpace {
|
|||||||
func (p postgresqlConnection) Connect(ctx context.Context, endpoint string, username string, password string, database string, port int, ssl string, timezone string) error {
|
func (p postgresqlConnection) Connect(ctx context.Context, endpoint string, username string, password string, database string, port int, ssl string, timezone string) error {
|
||||||
|
|
||||||
dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%d sslmode=%s TimeZone=%s", endpoint, username, password, database, port, ssl, timezone)
|
dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%d sslmode=%s TimeZone=%s", endpoint, username, password, database, port, ssl, timezone)
|
||||||
db, err := gorm.Open(gormPostgres.Open(dsn), &gorm.Config{})
|
db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
|
||||||
p.db = db
|
p.db = db
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -121,7 +120,8 @@ func (p postgresqlConnection) GetAllTags(ctx context.Context) ([]models.TagsWith
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p postgresqlConnection) GetAllSources(ctx context.Context) ([]models.AnthroveSource, error) {
|
func (p postgresqlConnection) GetAllSources(ctx context.Context) ([]models.AnthroveSource, error) {
|
||||||
return postgres.GetAllSourceNodes(ctx, p.db)
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p postgresqlConnection) GetSourceByURL(ctx context.Context, sourceUrl string) (*models.AnthroveSource, error) {
|
func (p postgresqlConnection) GetSourceByURL(ctx context.Context, sourceUrl string) (*models.AnthroveSource, error) {
|
Reference in New Issue
Block a user