| 476 | } |
| 477 | |
| 478 | func (s *server) listGraphs(ctx context.Context, req *listGraphsRequest) (*listGraphsResponse, error) { |
| 479 | graphs, err := s.db.Graphs(ctx) |
| 480 | if err != nil { |
| 481 | return nil, httperr.Internal("failed to load graphs: %w", err) |
| 482 | } |
| 483 | |
| 484 | var out []listGraphsResponseGraph |
| 485 | for _, g := range graphs { |
| 486 | out = append(out, listGraphsResponseGraph{ |
| 487 | GraphStorageLimit: 2 << 32, // A few GB |
| 488 | GraphName: g.Name, |
| 489 | GraphUUID: string(g.ID), |
| 490 | // TODO: There's a bunch of ways we could actually return this accurately if it |
| 491 | // matters. In no particular order: |
| 492 | // 1. We store this info in FileMeta.Size, we could just sum that up (maybe as a DB method for efficient SQL implementations) |
| 493 | // 2. We could keep a running tally every time /update_files is called |
| 494 | // - Less good because of the potential to get out of sync. |
| 495 | // 3. We could query our blob store for the aggregate size of everything under a prefix. |
| 496 | GraphStorageUsage: 123456, |
| 497 | }) |
| 498 | } |
| 499 | return &listGraphsResponse{ |
| 500 | Graphs: out, |
| 501 | }, nil |
| 502 | } |
| 503 | |
| 504 | type createGraphRequest struct { |
| 505 | GraphName string `json:"GraphName"` |