MCPcopy
hub / github.com/wavetermdev/waveterm / SavePlotData

Function SavePlotData

pkg/wshrpc/wshserver/wshserver.go:128–145  ·  view source on GitHub ↗
(ctx context.Context, blockId string, history string)

Source from the content-addressed store, hash-verified

126}
127
128func SavePlotData(ctx context.Context, blockId string, history string) error {
129 block, err := wstore.DBMustGet[*waveobj.Block](ctx, blockId)
130 if err != nil {
131 return err
132 }
133 viewName := block.Meta.GetString(waveobj.MetaKey_View, "")
134 if viewName != "cpuplot" && viewName != "sysinfo" {
135 return fmt.Errorf("invalid view type: %s", viewName)
136 }
137 // todo: interpret the data being passed
138 // for now, this is just to throw an error if the block was closed
139 historyBytes, err := json.Marshal(history)
140 if err != nil {
141 return fmt.Errorf("unable to serialize plot data: %v", err)
142 }
143 // ignore MakeFile error (already exists is ok)
144 return filestore.WFS.WriteFile(ctx, blockId, "cpuplotdata", historyBytes)
145}
146
147func (ws *WshServer) GetMetaCommand(ctx context.Context, data wshrpc.CommandGetMetaData) (waveobj.MetaMapType, error) {
148 obj, err := wstore.DBGetORef(ctx, data.ORef)

Callers

nothing calls this directly

Calls 3

DBMustGetFunction · 0.92
GetStringMethod · 0.80
WriteFileMethod · 0.80

Tested by

no test coverage detected