Compare commits
No commits in common. "63b92c22c8b675ceb20e07ab3da5fd45b6039681" and "4cb887701b0532990274615252e654ec1e0e6249" have entirely different histories.
63b92c22c8
...
4cb887701b
@ -33,7 +33,6 @@ func CreateSourceNode(ctx context.Context, driver neo4j.DriverWithContext, anthr
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAllSourceNodes(ctx context.Context, driver neo4j.DriverWithContext) ([]models.AnthroveSource, error) {
|
func GetAllSourceNodes(ctx context.Context, driver neo4j.DriverWithContext) ([]models.AnthroveSource, error) {
|
||||||
var sources []models.AnthroveSource
|
var sources []models.AnthroveSource
|
||||||
|
|
||||||
@ -74,40 +73,3 @@ func GetAllSourceNodes(ctx context.Context, driver neo4j.DriverWithContext) ([]m
|
|||||||
|
|
||||||
return sources, nil
|
return sources, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetSourceNodesByURL(ctx context.Context, driver neo4j.DriverWithContext, sourceUrl string) (*models.AnthroveSource, error) {
|
|
||||||
|
|
||||||
var source models.AnthroveSource
|
|
||||||
|
|
||||||
query := `
|
|
||||||
MATCH (s:Source {domain: $source_url})
|
|
||||||
RETURN s as source
|
|
||||||
`
|
|
||||||
params := map[string]any{
|
|
||||||
"source_url": sourceUrl,
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := neo4j.ExecuteQuery(ctx, driver, query, params, neo4j.EagerResultTransformer)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(result.Records) == 0 {
|
|
||||||
return nil, fmt.Errorf("source not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
record, _, err := neo4j.GetRecordValue[neo4j.Node](result.Records[0], "source")
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
source.DisplayName = record.Props["display_name"].(string)
|
|
||||||
source.Domain = record.Props["domain"].(string)
|
|
||||||
source.Icon = record.Props["icon"].(string)
|
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
|
||||||
"source_url": sourceUrl,
|
|
||||||
}).Trace("graph: got source node")
|
|
||||||
|
|
||||||
return &source, nil
|
|
||||||
}
|
|
||||||
|
@ -110,7 +110,4 @@ type OtterSpace interface {
|
|||||||
|
|
||||||
// GetAllSources returns a list of Sources in the database
|
// GetAllSources returns a list of Sources in the database
|
||||||
GetAllSources(ctx context.Context) ([]models.AnthroveSource, error)
|
GetAllSources(ctx context.Context) ([]models.AnthroveSource, error)
|
||||||
|
|
||||||
// GetSourceByURL returns the Source Node based on the URL
|
|
||||||
GetSourceByURL(ctx context.Context, sourceUrl string) (*models.AnthroveSource, error)
|
|
||||||
}
|
}
|
||||||
|
@ -112,10 +112,6 @@ func (g *graphConnection) GetAllSources(ctx context.Context) ([]models.AnthroveS
|
|||||||
return internal.GetAllSourceNodes(ctx, g.driver)
|
return internal.GetAllSourceNodes(ctx, g.driver)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *graphConnection) GetSourceByURL(ctx context.Context, sourceUrl string) (*models.AnthroveSource, error) {
|
|
||||||
return internal.GetSourceNodesByURL(ctx, g.driver, sourceUrl)
|
|
||||||
}
|
|
||||||
|
|
||||||
func logger(graphDebug bool) func(config *config.Config) {
|
func logger(graphDebug bool) func(config *config.Config) {
|
||||||
return func(config *config.Config) {
|
return func(config *config.Config) {
|
||||||
config.Log = internal.NewGraphLogger(graphDebug)
|
config.Log = internal.NewGraphLogger(graphDebug)
|
||||||
|
Reference in New Issue
Block a user