|
@@ -39,31 +39,28 @@ export function formatMongoDBQuery(query: string, command: string) {
|
|
|
const tempTokens: ReactElement[] = [];
|
|
|
|
|
|
const queryEntries = Object.entries(queryObject);
|
|
|
- queryEntries.forEach(([key, val], index) => {
|
|
|
+ queryEntries.forEach(([key, val]) => {
|
|
|
+ const isBoldedEntry = key.toLowerCase() === command.toLowerCase();
|
|
|
+
|
|
|
// Push the bolded entry into tokens so it is the first entry displayed.
|
|
|
// The other tokens will be pushed into tempTokens, and then copied into tokens afterwards
|
|
|
- const isBoldedEntry = key.toLowerCase() === command.toLowerCase();
|
|
|
+ isBoldedEntry
|
|
|
+ ? tokens.push(jsonEntryToToken(key, val, true))
|
|
|
+ : tempTokens.push(jsonEntryToToken(key, val));
|
|
|
+ });
|
|
|
|
|
|
- if (index === queryEntries.length - 1) {
|
|
|
- isBoldedEntry
|
|
|
- ? tokens.push(jsonEntryToToken(key, val, true))
|
|
|
- : tempTokens.push(jsonEntryToToken(key, val));
|
|
|
+ if (tokens.length === 1 && tempTokens.length > 0) {
|
|
|
+ tokens.push(stringToToken(', ', `${tokens[0].key}:,`));
|
|
|
+ }
|
|
|
|
|
|
- return;
|
|
|
- }
|
|
|
+ tempTokens.forEach((token, index) => {
|
|
|
+ tokens.push(token);
|
|
|
|
|
|
- if (isBoldedEntry) {
|
|
|
- tokens.push(jsonEntryToToken(key, val, true));
|
|
|
- tokens.push(stringToToken(', ', `${key}:${val},`));
|
|
|
- return;
|
|
|
+ if (index !== tempTokens.length - 1) {
|
|
|
+ tokens.push(stringToToken(', ', `${token.key}:${index}`));
|
|
|
}
|
|
|
-
|
|
|
- tempTokens.push(jsonEntryToToken(key, val));
|
|
|
- tempTokens.push(stringToToken(', ', `${key}:${val},`));
|
|
|
});
|
|
|
|
|
|
- tempTokens.forEach(token => tokens.push(token));
|
|
|
-
|
|
|
sentrySpan.end();
|
|
|
|
|
|
return tokens;
|