feat: implemented getting of all anthrove user ids

This commit is contained in:
SoXX 2024-02-16 21:40:06 +01:00
parent 820a8dd8d7
commit 2a33c60d2e
2 changed files with 39 additions and 2 deletions

View File

@ -213,3 +213,41 @@ func GetAnthroveUser(ctx context.Context, driver neo4j.DriverWithContext, anthro
return &anthroveUser, nil
}
func GetAllAnthroveUserIDs(ctx context.Context, driver neo4j.DriverWithContext) ([]models.AnthroveUserID, error) {
var err error
var anthroveUsers []models.AnthroveUserID
query := `
MATCH (anthroveUser:User)
RETURN anthroveUser
`
result, err := neo4j.ExecuteQuery(ctx, driver, query, nil, neo4j.EagerResultTransformer)
if err != nil {
return nil, err
}
if len(result.Records) == 0 {
log.Warnf("No users found, this should not be happening!")
return []models.AnthroveUserID{}, nil
}
for i := range result.Records {
record := result.Records[i]
user, _, err := neo4j.GetRecordValue[neo4j.Node](record, "anthroveUser")
if err != nil {
return nil, err
}
anthroveUsers = append(anthroveUsers, models.AnthroveUserID(fmt.Sprintf(user.Props["user_id"].(string))))
}
log.WithFields(log.Fields{
"anthrove_user_id_count": len(anthroveUsers),
}).Trace("graph: got al anthrove user IDs")
return anthroveUsers, nil
}

View File

@ -89,8 +89,7 @@ func (g *graphConnection) GetAnthroveUser(ctx context.Context, anthroveUserID mo
}
func (g *graphConnection) GetAllAnthroveUserIDs(ctx context.Context) ([]models.AnthroveUserID, error) {
//TODO implement me
panic("implement me")
return internal.GetAllAnthroveUserIDs(ctx, g.driver)
}
func logger(graphDebug bool) func(config *config.Config) {