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

Release version v1.0.0-138 #2197

Merged
merged 6 commits into from
Jan 11, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore: optimize code
nichenqin committed Jan 10, 2025

Verified

This commit was signed with the committer’s verified signature.
samuelattwood Samuel Attwood
commit 5726e762d30af076b6f050908106a96dd681af11
4 changes: 1 addition & 3 deletions apps/backend/src/modules/space/space.module.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import { getCurrentMember } from "@undb/context/server"
import { CommandBus } from "@undb/cqrs"
import { inject, singleton } from "@undb/di"
import type { ITxContext } from "@undb/persistence/server"
import { injectQueryBuilder, injectTxCTX, type IQueryBuilder } from "@undb/persistence/server"
import { injectTxCTX } from "@undb/persistence/server"
import { injectSpaceService, type ISpaceService } from "@undb/space"
import Elysia, { t } from "elysia"
import { type Lucia } from "lucia"
@@ -20,8 +20,6 @@ export class SpaceModule {
private readonly spaceService: ISpaceService,
@inject(CommandBus)
private readonly commandBus: CommandBus,
@injectQueryBuilder()
private readonly qb: IQueryBuilder,
@injectContext()
private readonly context: IContext,
@injectTxCTX()
4 changes: 0 additions & 4 deletions packages/persistence/src/base/base.repository.ts
Original file line number Diff line number Diff line change
@@ -13,8 +13,6 @@ import { None, Some, type Option } from "@undb/domain"
import { injectTableRepository, TableBaseIdSpecification, type ITableRepository } from "@undb/table"
import type { ITxContext } from "../ctx.interface"
import { injectTxCTX } from "../ctx.provider"
import { injectQueryBuilder } from "../qb.provider"
import type { IQueryBuilder } from "../qb.type"
import { UnderlyingTableService } from "../underlying/underlying-table.service"
import { BaseFilterVisitor } from "./base.filter-visitor"
import { BaseMapper } from "./base.mapper"
@@ -27,8 +25,6 @@ export class BaseRepository implements IBaseRepository {
private readonly mapper: BaseMapper,
@injectBaseOutboxService()
private readonly outboxService: IBaseOutboxService,
@injectQueryBuilder()
private readonly qb: IQueryBuilder,
@injectTableRepository()
private readonly tableRepository: ITableRepository,
@inject(UnderlyingTableService)
16 changes: 10 additions & 6 deletions packages/persistence/src/dashboard/dashboard.repository.ts
Original file line number Diff line number Diff line change
@@ -35,21 +35,23 @@ export class DashboardRepository implements IDashboardRepository {
) {}

async find(spec: IDashboardSpecification): Promise<Dashboard[]> {
const dashboards = await this.qb
const trx = this.txContext.getCurrentTransaction()
const dashboards = await trx
.selectFrom("undb_dashboard")
.selectAll()
.$call((qb) => new DashboardReferenceVisitor(qb).call(spec))
.where((eb) => new DashboardFilterVisitor(eb, this.qb).$where(spec))
.where((eb) => new DashboardFilterVisitor(eb, trx).$where(spec))
.execute()

return dashboards.map((dashboard) => this.mapper.toDo(dashboard))
}
async findOne(spec: IDashboardSpecification): Promise<Option<Dashboard>> {
const dashboard = await this.qb
const trx = this.txContext.getCurrentTransaction()
const dashboard = await trx
.selectFrom("undb_dashboard")
.selectAll()
.$call((qb) => new DashboardReferenceVisitor(qb).call(spec))
.where((eb) => new DashboardFilterVisitor(eb, this.qb).$where(spec))
.where((eb) => new DashboardFilterVisitor(eb, trx).$where(spec))
.executeTakeFirst()

return dashboard ? Some(this.mapper.toDo(dashboard)) : None
@@ -58,11 +60,13 @@ export class DashboardRepository implements IDashboardRepository {
const spaceId = this.context.mustGetCurrentSpaceId()
const spec = WithDashboardId.fromString(id).and(new WithDashboardSpaceId(spaceId))

const dashboard = await this.qb
const trx = this.txContext.getCurrentTransaction()

const dashboard = await trx
.selectFrom("undb_dashboard")
.selectAll()
.$call((qb) => new DashboardReferenceVisitor(qb).call(spec))
.where((eb) => new DashboardFilterVisitor(eb, this.qb).$where(spec))
.where((eb) => new DashboardFilterVisitor(eb, trx).$where(spec))
.executeTakeFirst()

return dashboard ? Some(this.mapper.toDo(dashboard)) : None
4 changes: 0 additions & 4 deletions packages/persistence/src/table/table.repository.ts
Original file line number Diff line number Diff line change
@@ -14,8 +14,6 @@ import {
import type { ITxContext } from "../ctx.interface"
import { injectTxCTX } from "../ctx.provider"
import type { InsertTable, InsertTableIdMapping } from "../db"
import { injectQueryBuilder } from "../qb.provider"
import type { IQueryBuilder } from "../qb.type"
import { json } from "../qb.util"
import { UnderlyingTableService } from "../underlying/underlying-table.service"
import { TableFilterVisitor } from "./table.filter-visitor"
@@ -30,8 +28,6 @@ export class TableRepository implements ITableRepository {
private readonly underlyingTableService: UnderlyingTableService,
@injectTableOutboxService()
private readonly outboxService: ITableOutboxService,
@injectQueryBuilder()
private readonly qb: IQueryBuilder,
@injectContext()
private readonly context: IContext,
@injectTxCTX()
4 changes: 0 additions & 4 deletions packages/persistence/src/webhook/webhook.repository.ts
Original file line number Diff line number Diff line change
@@ -4,8 +4,6 @@ import { None, Some, type Option } from "@undb/domain"
import { type IWebhookRepository, type WebhookDo, type WebhookSpecification } from "@undb/webhook"
import type { ITxContext } from "../ctx.interface"
import { injectTxCTX } from "../ctx.provider"
import { injectQueryBuilder } from "../qb.provider"
import type { IQueryBuilder } from "../qb.type"
import { WebhookFilterVisitor } from "./webhook.filter-visitor"
import { WebhookMapper } from "./webhook.mapper"
import { WebhookMutationVisitor } from "./webhook.mutation-visitor"
@@ -15,8 +13,6 @@ export class WebhookRepository implements IWebhookRepository {
constructor(
@inject(WebhookMapper)
private readonly mapper: WebhookMapper,
@injectQueryBuilder()
private readonly qb: IQueryBuilder,
@injectContext()
private readonly context: IContext,
@injectTxCTX()