Skip to content

Commit

Permalink
fix: a bug of broken/ugly edgedb queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Gobot1234 committed Apr 15, 2024
1 parent 6e14fd6 commit d53fdb2
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions apps/anvil/src/sign-in/sign-in.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ export class SignInService implements OnModuleInit {
return await this.dbService.query(
e.count(
e.select(e.sign_in.List, () => ({
sign_ins: true,
filter_single: {
location: castLocation(location),
},
Expand Down Expand Up @@ -257,8 +256,11 @@ export class SignInService implements OnModuleInit {
e.count(
e.select(e.sign_in.List, () => ({
sign_ins: (sign_in) => ({
user: e.is(e.users.Rep, {}),
filter: e.op(sign_in.reason.name, "=", REP_OFF_SHIFT),
filter: e.op(
e.op(sign_in.user.__type__.name, "=", "users::Rep"),
"and",
e.op(sign_in.reason.name, "=", REP_OFF_SHIFT),
),
}),
filter_single: {
location: castLocation(location),
Expand All @@ -273,8 +275,11 @@ export class SignInService implements OnModuleInit {
e.count(
e.select(e.sign_in.List, () => ({
sign_ins: (sign_in) => ({
user: e.is(e.users.Rep, {}),
filter: e.op(sign_in.reason.name, "=", REP_ON_SHIFT),
filter: e.op(
e.op(sign_in.user.__type__.name, "=", "users::Rep"),
"and",
e.op(sign_in.reason.name, "=", REP_ON_SHIFT),
),
}),
filter_single: {
location: castLocation(location),
Expand All @@ -288,7 +293,6 @@ export class SignInService implements OnModuleInit {
return await this.dbService.query(
e.count(
e.select(e.sign_in.List, () => ({
queued: true,
filter_single: {
location: castLocation(location),
},
Expand Down Expand Up @@ -400,7 +404,6 @@ export class SignInService implements OnModuleInit {
const user_agreement = await this.dbService.query(
e.assert_exists(
e.select(e.sign_in.SignInReason, (reason) => ({
agreement: true,
filter_single: e.op(reason.category, "=", e.sign_in.SignInReasonCategory.PERSONAL_PROJECT),
})).agreement,
),
Expand Down Expand Up @@ -726,7 +729,6 @@ export class SignInService implements OnModuleInit {
e.assert_exists(
e.assert_single(
e.select(e.sign_in.SignInReason, (sign_in) => ({
created_at: true,
order_by: {
expression: sign_in.created_at,
direction: e.DESC,
Expand Down

0 comments on commit d53fdb2

Please sign in to comment.