MCPcopy Create free account
hub / github.com/crossjoin-io/crossjoin / refreshDataset

Method refreshDataset

api/datasets.go:107–141  ·  view source on GitHub ↗
(hash string, id string)

Source from the content-addressed store, hash-verified

105}
106
107func (api *API) refreshDataset(hash string, id string) error {
108 text := ""
109 err := api.db.QueryRow("SELECT text FROM datasets WHERE config_hash = $1 AND id = $2", hash, id).Scan(&text)
110 if err != nil {
111 return err
112 }
113 dataset := config.Dataset{}
114 err = yaml.Unmarshal([]byte(text), &dataset)
115 if err != nil {
116 return err
117 }
118 err = api.createDataset(hash, dataset)
119 if err != nil {
120 return fmt.Errorf("create dataset: %w", err)
121 }
122 workflows, err := api.GetWorkflows(hash)
123 if err != nil {
124 return fmt.Errorf("get workflows: %w", err)
125 }
126
127 for _, workflow := range workflows {
128 if workflow.On == nil {
129 continue
130 }
131 for _, datasetID := range workflow.On.DatasetRefresh {
132 if datasetID == id {
133 err = api.StartWorkflow(hash, workflow.ID, nil)
134 if err != nil {
135 return fmt.Errorf("start workflow: %w", err)
136 }
137 }
138 }
139 }
140 return nil
141}
142
143func (api *API) createDataset(hash string, dataset config.Dataset) error {
144 filename := filepath.Join(api.dataDir, dataset.ID+".db")

Callers 1

TickMethod · 0.95

Calls 3

createDatasetMethod · 0.95
GetWorkflowsMethod · 0.95
StartWorkflowMethod · 0.95

Tested by

no test coverage detected