Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved string-formatting of sparql queries for cleaner log output #27

Merged
merged 1 commit into from
Jan 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions sparql-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,31 @@ const SPARQL_ENDPOINT_HEADERS = extractEndpointHeadersFromEnv(SPARQL_ENDPOINT_HE
function constructTriplesString (quads: RDF.Quad[]) {
const triplesString = quads.map(toString)
.filter((item, index, array) => array.indexOf(item) === index)
.join("\n");
.join("\n ");
return triplesString;
}

export function constructInsertQuery (quads: RDF.Quad[]) {
const triplesString = constructTriplesString(quads);
const sparql_query = `
INSERT DATA {
GRAPH <${MU_APPLICATION_GRAPH}> {
${triplesString}
}
const sparql_query = `INSERT DATA {
GRAPH <${MU_APPLICATION_GRAPH}> {
${triplesString}
}
`;
}`;
return sparql_query;
}

export function constructDeleteQuery (quads: RDF.Quad[]) {
const triplesString = constructTriplesString(quads);
const sparql_query = `
DELETE {
GRAPH <${MU_APPLICATION_GRAPH}> {
${triplesString}
}
} WHERE {
GRAPH <${MU_APPLICATION_GRAPH}> {
${triplesString}
}
const sparql_query = `DELETE {
GRAPH <${MU_APPLICATION_GRAPH}> {
${triplesString}
}
} WHERE {
GRAPH <${MU_APPLICATION_GRAPH}> {
${triplesString}
}
`;
}`;
return sparql_query;
}

Expand All @@ -58,13 +54,11 @@ export function constructSelectQuery (
) {
const triplesString = constructTriplesString(quads);
const variablesString = variables.map(toString).join(" ");
const sparql_query = `
SELECT ${variablesString} where {
GRAPH <${MU_APPLICATION_GRAPH}> {
const sparql_query = `SELECT ${variablesString} WHERE {
GRAPH <${MU_APPLICATION_GRAPH}> {
${triplesString}
}
}
`;
}`;
return sparql_query;
}

Expand Down