MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / acceptUpstreamDML

Function acceptUpstreamDML

packages/wl-sdk/src/commons/dml.generated.ts:215–247  ·  view source on GitHub ↗
(input: AcceptUpstreamInput)

Source from the content-addressed store, hash-verified

213 * fork completion, UPDATE wanted, INSERT stamp, UPDATE completion w/ stamp ref.
214 */
215export function acceptUpstreamDML(input: AcceptUpstreamInput): string[] {
216 const tagsField = formatTagsJson(input.stamp.skillTags);
217 const msgField = sqlStringOrNull(input.stamp.message);
218 const hopField = sqlStringOrNull(input.hopUri);
219
220 const valence = `{"quality": ${input.stamp.quality}, "reliability": ${input.stamp.reliability}}`;
221
222 const deleteCompletion = `DELETE FROM completions WHERE wanted_id='${escapeSqlString(input.wantedId)}'`;
223
224 const insertCompletion =
225 `INSERT IGNORE INTO completions (id, wanted_id, completed_by, evidence, hop_uri, completed_at) ` +
226 `VALUES ('${escapeSqlString(input.completionId)}', '${escapeSqlString(input.wantedId)}', ` +
227 `'${escapeSqlString(input.completedBy)}', '${escapeSqlString(input.evidence)}', ${hopField}, NOW())`;
228
229 const updateWanted =
230 `UPDATE wanted SET status='completed', claimed_by='${escapeSqlString(input.completedBy)}', ` +
231 `evidence_url='${escapeSqlString(input.evidence)}', updated_at=NOW() ` +
232 `WHERE id='${escapeSqlString(input.wantedId)}'`;
233
234 const insertStamp =
235 `INSERT INTO stamps (id, author, subject, valence, confidence, severity, context_id, context_type, skill_tags, message, hop_uri, created_at) ` +
236 `VALUES ('${escapeSqlString(input.stamp.id)}', '${escapeSqlString(input.rigHandle)}', ` +
237 `'${escapeSqlString(input.stamp.subject)}', '${escapeSqlString(valence)}', 1.0, ` +
238 `'${escapeSqlString(input.stamp.severity)}', '${escapeSqlString(input.completionId)}', 'completion', ` +
239 `${tagsField}, ${msgField}, ${hopField}, NOW())`;
240
241 const updateCompletion =
242 `UPDATE completions SET validated_by='${escapeSqlString(input.rigHandle)}', ` +
243 `stamp_id='${escapeSqlString(input.stamp.id)}', validated_at=NOW() ` +
244 `WHERE id='${escapeSqlString(input.completionId)}'`;
245
246 return [deleteCompletion, insertCompletion, updateWanted, insertStamp, updateCompletion];
247}
248
249// CloseUpstreamDML (commons.go:751)
250

Callers 2

acceptUpstreamFunction · 0.90

Calls 3

sqlStringOrNullFunction · 0.90
escapeSqlStringFunction · 0.90
formatTagsJsonFunction · 0.85

Tested by

no test coverage detected