Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit 1c1b651

Browse files
committed
Revert "fix: use active reservations in reservation quota check"
This reverts commit 7355b3e.
1 parent 046a8f8 commit 1c1b651

4 files changed

Lines changed: 124 additions & 8 deletions

File tree

apps/ui/modules/queries/reservationUnit.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ const RESERVATION_UNIT_PAGE_FRAGMENT = gql`
5353
minReservationDuration
5454
maxReservationDuration
5555
maxReservationsPerUser
56-
numActiveUserReservations
5756
reservationsMinDaysBefore
5857
reservationsMaxDaysBefore
5958
requireReservationHandling

apps/ui/pages/reservation-unit/[id].tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -610,14 +610,10 @@ const ReservationUnit = ({
610610
const isReservationQuotaReached = useMemo(() => {
611611
return (
612612
reservationUnit?.maxReservationsPerUser != null &&
613-
reservationUnit?.numActiveUserReservations != null &&
614-
reservationUnit?.numActiveUserReservations >=
615-
reservationUnit?.maxReservationsPerUser
613+
userReservations?.length != null &&
614+
userReservations?.length >= reservationUnit?.maxReservationsPerUser
616615
);
617-
}, [
618-
reservationUnit?.maxReservationsPerUser,
619-
reservationUnit?.numActiveUserReservations,
620-
]);
616+
}, [reservationUnit?.maxReservationsPerUser, userReservations]);
621617

622618
const shouldDisplayApplicationRoundTimeSlots =
623619
!!activeApplicationRounds?.length;

packages/common/types/gql-types.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,59 @@ export enum CustomerTypeChoice {
917917
Nonprofit = "NONPROFIT",
918918
}
919919

920+
/** Debugging information for the current query. */
921+
export type DjangoDebug = {
922+
__typename?: "DjangoDebug";
923+
/** Raise exceptions for this API query. */
924+
exceptions?: Maybe<Array<Maybe<DjangoDebugException>>>;
925+
/** Executed SQL queries for this API query. */
926+
sql?: Maybe<Array<Maybe<DjangoDebugSql>>>;
927+
};
928+
929+
/** Represents a single exception raised. */
930+
export type DjangoDebugException = {
931+
__typename?: "DjangoDebugException";
932+
/** The class of the exception */
933+
excType: Scalars["String"]["output"];
934+
/** The message of the exception */
935+
message: Scalars["String"]["output"];
936+
/** The stack trace */
937+
stack: Scalars["String"]["output"];
938+
};
939+
940+
/** Represents a single database query made to a Django managed DB. */
941+
export type DjangoDebugSql = {
942+
__typename?: "DjangoDebugSQL";
943+
/** The Django database alias (e.g. 'default'). */
944+
alias: Scalars["String"]["output"];
945+
/** Duration of this database query in seconds. */
946+
duration: Scalars["Float"]["output"];
947+
/** Postgres connection encoding if available. */
948+
encoding?: Maybe<Scalars["String"]["output"]>;
949+
/** Whether this database query was a SELECT. */
950+
isSelect: Scalars["Boolean"]["output"];
951+
/** Whether this database query took more than 10 seconds. */
952+
isSlow: Scalars["Boolean"]["output"];
953+
/** Postgres isolation level if available. */
954+
isoLevel?: Maybe<Scalars["String"]["output"]>;
955+
/** JSON encoded database query parameters. */
956+
params: Scalars["String"]["output"];
957+
/** The raw SQL of this query, without params. */
958+
rawSql: Scalars["String"]["output"];
959+
/** The actual SQL sent to this database. */
960+
sql?: Maybe<Scalars["String"]["output"]>;
961+
/** Start time of this database query. */
962+
startTime: Scalars["Float"]["output"];
963+
/** Stop time of this database query. */
964+
stopTime: Scalars["Float"]["output"];
965+
/** Postgres transaction ID if available. */
966+
transId?: Maybe<Scalars["String"]["output"]>;
967+
/** Postgres transaction status if available. */
968+
transStatus?: Maybe<Scalars["String"]["output"]>;
969+
/** The type of database being used (e.g. postrgesql, mysql, sqlite). */
970+
vendor: Scalars["String"]["output"];
971+
};
972+
920973
export type EquipmentCategoryCreateMutationInput = {
921974
name: Scalars["String"]["input"];
922975
nameEn?: InputMaybe<Scalars["String"]["input"]>;
@@ -1889,6 +1942,7 @@ export enum QualifierOrderingChoices {
18891942

18901943
export type Query = {
18911944
__typename?: "Query";
1945+
_debug?: Maybe<DjangoDebug>;
18921946
/**
18931947
* Return all allocations that affect allocations for given reservation unit
18941948
* (through space hierarchy or common resource) during the given time period.

tilavaraus.graphql

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,72 @@ scalar DateTime
866866
"""The `Decimal` scalar type represents a python Decimal."""
867867
scalar Decimal
868868

869+
"""Debugging information for the current query."""
870+
type DjangoDebug {
871+
"""Executed SQL queries for this API query."""
872+
sql: [DjangoDebugSQL]
873+
874+
"""Raise exceptions for this API query."""
875+
exceptions: [DjangoDebugException]
876+
}
877+
878+
"""Represents a single exception raised."""
879+
type DjangoDebugException {
880+
"""The class of the exception"""
881+
excType: String!
882+
883+
"""The message of the exception"""
884+
message: String!
885+
886+
"""The stack trace"""
887+
stack: String!
888+
}
889+
890+
"""Represents a single database query made to a Django managed DB."""
891+
type DjangoDebugSQL {
892+
"""The type of database being used (e.g. postrgesql, mysql, sqlite)."""
893+
vendor: String!
894+
895+
"""The Django database alias (e.g. 'default')."""
896+
alias: String!
897+
898+
"""The actual SQL sent to this database."""
899+
sql: String
900+
901+
"""Duration of this database query in seconds."""
902+
duration: Float!
903+
904+
"""The raw SQL of this query, without params."""
905+
rawSql: String!
906+
907+
"""JSON encoded database query parameters."""
908+
params: String!
909+
910+
"""Start time of this database query."""
911+
startTime: Float!
912+
913+
"""Stop time of this database query."""
914+
stopTime: Float!
915+
916+
"""Whether this database query took more than 10 seconds."""
917+
isSlow: Boolean!
918+
919+
"""Whether this database query was a SELECT."""
920+
isSelect: Boolean!
921+
922+
"""Postgres transaction ID if available."""
923+
transId: String
924+
925+
"""Postgres transaction status if available."""
926+
transStatus: String
927+
928+
"""Postgres isolation level if available."""
929+
isoLevel: String
930+
931+
"""Postgres connection encoding if available."""
932+
encoding: String
933+
}
934+
869935
"""Represents a DurationField value as an integer in seconds."""
870936
scalar Duration
871937

@@ -2212,6 +2278,7 @@ type Query {
22122278
orderBy: [BannerNotificationOrderingChoices]
22132279
): BannerNotificationNodeConnection
22142280
serviceSectors(first: Int, last: Int, offset: Int, after: String, before: String): ServiceSectorNodeConnection
2281+
_debug: DjangoDebug
22152282
}
22162283

22172284
input RecurringReservationCreateMutationInput {

0 commit comments

Comments
 (0)