mirror of
				https://github.com/ClusterCockpit/cc-backend
				synced 2025-10-31 16:05:06 +01:00 
			
		
		
		
	initial branch commit, improve countstate backend logic
- stacked component rough sketch - gql data request pipeline layed out
This commit is contained in:
		| @@ -366,17 +366,66 @@ func (r *queryResolver) AllocatedNodes(ctx context.Context, cluster string) ([]* | ||||
|  | ||||
| // Node is the resolver for the node field. | ||||
| func (r *queryResolver) Node(ctx context.Context, id string) (*schema.Node, error) { | ||||
| 	panic(fmt.Errorf("not implemented: Node - node")) | ||||
| 	repo := repository.GetNodeRepository() | ||||
| 	numericId, err := strconv.ParseInt(id, 10, 64) | ||||
| 	if err != nil { | ||||
| 		cclog.Warn("Error while parsing job id") | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return repo.GetNodeById(numericId, false) | ||||
| } | ||||
|  | ||||
| // Nodes is the resolver for the nodes field. | ||||
| func (r *queryResolver) Nodes(ctx context.Context, filter []*model.NodeFilter, order *model.OrderByInput) (*model.NodeStateResultList, error) { | ||||
| 	panic(fmt.Errorf("not implemented: Nodes - nodes")) | ||||
| 	repo := repository.GetNodeRepository() | ||||
| 	nodes, err := repo.QueryNodes(ctx, filter, order) | ||||
| 	count := len(nodes) | ||||
| 	return &model.NodeStateResultList{Items: nodes, Count: &count}, err | ||||
| } | ||||
|  | ||||
| // NodeStates is the resolver for the nodeStates field. | ||||
| func (r *queryResolver) NodeStates(ctx context.Context, filter []*model.NodeFilter) ([]*model.NodeStates, error) { | ||||
| 	panic(fmt.Errorf("not implemented: NodeStates - nodeStates")) | ||||
| 	repo := repository.GetNodeRepository() | ||||
|  | ||||
| 	stateCounts, serr := repo.CountNodeStates(ctx, filter) | ||||
| 	if serr != nil { | ||||
| 		cclog.Warnf("Error while counting nodeStates: %s", serr.Error()) | ||||
| 		return nil, serr | ||||
| 	} | ||||
|  | ||||
| 	healthCounts, herr := repo.CountHealthStates(ctx, filter) | ||||
| 	if herr != nil { | ||||
| 		cclog.Warnf("Error while counting healthStates: %s", herr.Error()) | ||||
| 		return nil, herr | ||||
| 	} | ||||
|  | ||||
| 	allCounts := make([]*model.NodeStates, 0) | ||||
| 	allCounts = append(stateCounts, healthCounts...) | ||||
|  | ||||
| 	return allCounts, nil | ||||
| } | ||||
|  | ||||
| // NodeStatesTimed is the resolver for the nodeStatesTimed field. | ||||
| func (r *queryResolver) NodeStatesTimed(ctx context.Context, filter []*model.NodeFilter) ([]*model.NodeStatesTimed, error) { | ||||
| 	panic(fmt.Errorf("not implemented: NodeStatesTimed - NodeStatesTimed")) | ||||
| 	// repo := repository.GetNodeRepository() | ||||
|  | ||||
| 	// stateCounts, serr := repo.CountNodeStates(ctx, filter) | ||||
| 	// if serr != nil { | ||||
| 	// 	cclog.Warnf("Error while counting nodeStates: %s", serr.Error()) | ||||
| 	// 	return nil, serr | ||||
| 	// } | ||||
|  | ||||
| 	// healthCounts, herr := repo.CountHealthStates(ctx, filter) | ||||
| 	// if herr != nil { | ||||
| 	// 	cclog.Warnf("Error while counting healthStates: %s", herr.Error()) | ||||
| 	// 	return nil, herr | ||||
| 	// } | ||||
|  | ||||
| 	// allCounts := make([]*model.NodeStates, 0) | ||||
| 	// allCounts = append(stateCounts, healthCounts...) | ||||
|  | ||||
| 	// return allCounts, nil | ||||
| } | ||||
|  | ||||
| // Job is the resolver for the job field. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user