Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilShahi committed Sep 28, 2022
1 parent 0220746 commit ebd50a6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
21 changes: 12 additions & 9 deletions backend/src/services/jobs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import { DataFieldService } from "services/data-field"
import { DatabaseService } from "services/database"
import axios from "axios"
import { SpecService } from "services/spec"
import { aggregateTracesDataHourlyQuery, aggregateTracesDataMinutelyQuery } from "./queries"
import {
aggregateTracesDataHourlyQuery,
aggregateTracesDataMinutelyQuery,
} from "./queries"

interface GenerateEndpoint {
parameterizedPath: string
Expand Down Expand Up @@ -68,8 +71,8 @@ export class JobsService {
bodySchema = {
type: DataType.OBJECT,
properties: {
...bodySchema?.properties
}
...bodySchema?.properties,
},
}
}
for (let property in parsedBody) {
Expand All @@ -91,8 +94,8 @@ export class JobsService {
bodySchema = {
type: DataType.ARRAY,
items: {
...bodySchema?.items
}
...bodySchema?.items,
},
}
}
for (let i = 0; i < l; i++) {
Expand All @@ -105,7 +108,7 @@ export class JobsService {
} else if (dataType === DataType.UNKNOWN) {
return {
type: dataType,
nullable: true
nullable: true,
}
} else {
return {
Expand All @@ -121,8 +124,7 @@ export class JobsService {
nonNullKey = key || "default"
parsedBody = bodyString
} else if (parsedBody) {
nonNullKey =
key || "default"
nonNullKey = key || "default"
} else {
return
}
Expand Down Expand Up @@ -270,7 +272,8 @@ export class JobsService {
.from(ApiTrace)
.where('"apiEndpointUuid" IS NOT NULL')
.andWhere("analyzed = TRUE")
.andWhere('"createdAt" <= :maxTime', { maxTime }).execute()
.andWhere('"createdAt" <= :maxTime', { maxTime })
.execute()
await queryRunner.commitTransaction()
}
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/services/jobs/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ export const aggregateTracesDataHourlyQuery = `
GROUP BY 1, 2
ON CONFLICT ON CONSTRAINT unique_constraint_hourly
DO UPDATE SET "numCalls" = EXCLUDED."numCalls" + aggregate_trace_data_hourly."numCalls"
`
`
2 changes: 1 addition & 1 deletion backend/src/services/spec/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ export const insertAggregateMinutelyQuery = `
$2 as "apiEndpointUuid"
FROM traces_by_minute traces
JOIN minute_count_by_status_code status_code_map ON traces.minute = status_code_map.minute
`
`
17 changes: 13 additions & 4 deletions backend/src/services/spec/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ export const generateAlertMessageFromReqErrors = (
let pathArray = error.instancePath?.split("/")?.slice(2)
const message = error.message
const defaultErrorMessage =
message[0].toUpperCase() + message.slice(1, message[message.length - 1] === "." ? -1 : message.length)
message[0].toUpperCase() +
message.slice(
1,
message[message.length - 1] === "." ? -1 : message.length,
)
let errorMessage = `${defaultErrorMessage} in request${
error["location"] ? ` ${error["location"]}` : ""
}.`
Expand Down Expand Up @@ -218,7 +222,11 @@ export const generateAlertMessageFromRespErrors = (
let pathArray = error.instancePath?.split("/")?.slice(2)
const message = error.message
const defaultErrorMessage =
message[0].toUpperCase() + message.slice(1, message[message.length - 1] === "." ? -1 : message.length)
message[0].toUpperCase() +
message.slice(
1,
message[message.length - 1] === "." ? -1 : message.length,
)
let errorMessage = `${defaultErrorMessage} in response body.`
let path = pathArray?.length > 0 ? pathArray.join(".") : ""
let ignoreError = false
Expand Down Expand Up @@ -309,7 +317,8 @@ export const recursiveTransformSpec = (schema: any) => {
const combineKeywords = ["anyOf", "allOf", "oneOf"]
for (const keyword of combineKeywords) {
if (schema[keyword]) {
if (!schema["unevaluatedProperties"]) schema["unevaluatedProperties"] = false
if (!schema["unevaluatedProperties"])
schema["unevaluatedProperties"] = false
for (let i = 0; i < schema[keyword]?.length; i++) {
if (schema[keyword][i]) {
const properties = schema[keyword][i]["properties"]
Expand All @@ -325,7 +334,7 @@ export const recursiveTransformSpec = (schema: any) => {
const isPropertyObject = typeof schema["properties"] === "object"
const isItemsObject = typeof schema["items"] === "object"
if (schema["type"] === "object" || isPropertyObject) {
if(!schema["additionalProperties"]) schema["additionalProperties"] = false
if (!schema["additionalProperties"]) schema["additionalProperties"] = false
const properties = schema["properties"]
if (properties && isPropertyObject) {
for (const property in properties) {
Expand Down

0 comments on commit ebd50a6

Please sign in to comment.