Compare commits

...

3 Commits

3 changed files with 38 additions and 4 deletions

View File

@ -0,0 +1,34 @@
import { Knex } from "knex";
import { TableName } from "../schemas";
export async function up(knex: Knex): Promise<void> {
const hasEventTypeCol = await knex.schema.hasColumn(TableName.AuditLog, "eventType");
const hasEventMetadataCol = await knex.schema.hasColumn(TableName.AuditLog, "eventMetadata");
const hasUserAgentTypeCol = await knex.schema.hasColumn(TableName.AuditLog, "userAgentType");
await knex.schema.alterTable(TableName.AuditLog, (t) => {
if (hasEventTypeCol) t.index("eventType");
if (hasUserAgentTypeCol) t.index("userAgentType");
});
if (hasEventMetadataCol) {
await knex.raw(`CREATE INDEX IF NOT EXISTS idx_audit_logs_secret_path
ON audit_logs ("projectId", ("eventMetadata"->>'secretPath'), "createdAt" DESC);`);
}
}
export async function down(knex: Knex): Promise<void> {
const hasEventTypeCol = await knex.schema.hasColumn(TableName.AuditLog, "eventType");
const hasEventMetadataCol = await knex.schema.hasColumn(TableName.AuditLog, "eventMetadata");
const hasUserAgentTypeCol = await knex.schema.hasColumn(TableName.AuditLog, "userAgentType");
await knex.schema.alterTable(TableName.AuditLog, (t) => {
if (hasEventTypeCol) t.dropIndex("eventType");
if (hasUserAgentTypeCol) t.dropIndex("userAgentType");
});
if (hasEventMetadataCol) {
await knex.raw(`DROP INDEX IF EXISTS idx_audit_logs_secret_path`);
}
}

View File

@ -91,7 +91,7 @@ export const auditLogDALFactory = (db: TDbClient) => {
} }
if (projectId && secretPath) { if (projectId && secretPath) {
void sqlQuery.whereRaw(`"eventMetadata" @> jsonb_build_object('secretPath', ?::text)`, [secretPath]); void sqlQuery.whereRaw(`"eventMetadata" ->> 'secretPath' = ?::text`, [secretPath]);
} }
// Filter by actor type // Filter by actor type
@ -112,8 +112,8 @@ export const auditLogDALFactory = (db: TDbClient) => {
void sqlQuery.whereRaw(`"${TableName.AuditLog}"."createdAt" <= ?::timestamptz`, [endDate]); void sqlQuery.whereRaw(`"${TableName.AuditLog}"."createdAt" <= ?::timestamptz`, [endDate]);
} }
// we timeout long running queries to prevent DB resource issues (2 minutes) // we time out long-running queries to prevent DB resource issues (a little less than 30 seconds [server timeout])
const docs = await sqlQuery.timeout(1000 * 120); const docs = await sqlQuery.timeout(1000 * 29.5);
return docs; return docs;
} catch (error) { } catch (error) {

View File

@ -106,7 +106,7 @@ export const LogsTable = ({
className="mb-20 mt-4 px-4 py-3 text-sm" className="mb-20 mt-4 px-4 py-3 text-sm"
isFullWidth isFullWidth
variant="star" variant="star"
isLoading={isFetchingNextPage} isLoading={isFetchingNextPage || isPending}
isDisabled={isFetchingNextPage || !hasNextPage} isDisabled={isFetchingNextPage || !hasNextPage}
onClick={() => fetchNextPage()} onClick={() => fetchNextPage()}
> >