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

Commit 7355b3e

Browse files
vincit-matujoonatank
authored andcommitted
fix: use active reservations in reservation quota check
1 parent bd87005 commit 7355b3e

4 files changed

Lines changed: 8 additions & 124 deletions

File tree

apps/ui/modules/queries/reservationUnit.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const RESERVATION_UNIT_PAGE_FRAGMENT = gql`
5353
minReservationDuration
5454
maxReservationDuration
5555
maxReservationsPerUser
56+
numActiveUserReservations
5657
reservationsMinDaysBefore
5758
reservationsMaxDaysBefore
5859
requireReservationHandling

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

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

618622
const shouldDisplayApplicationRoundTimeSlots =
619623
!!activeApplicationRounds?.length;

packages/common/types/gql-types.ts

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -917,59 +917,6 @@ 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-
973920
export type EquipmentCategoryCreateMutationInput = {
974921
name: Scalars["String"]["input"];
975922
nameEn?: InputMaybe<Scalars["String"]["input"]>;
@@ -1942,7 +1889,6 @@ export enum QualifierOrderingChoices {
19421889

19431890
export type Query = {
19441891
__typename?: "Query";
1945-
_debug?: Maybe<DjangoDebug>;
19461892
/**
19471893
* Return all allocations that affect allocations for given reservation unit
19481894
* (through space hierarchy or common resource) during the given time period.

tilavaraus.graphql

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -866,72 +866,6 @@ 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-
935869
"""Represents a DurationField value as an integer in seconds."""
936870
scalar Duration
937871

@@ -2278,7 +2212,6 @@ type Query {
22782212
orderBy: [BannerNotificationOrderingChoices]
22792213
): BannerNotificationNodeConnection
22802214
serviceSectors(first: Int, last: Int, offset: Int, after: String, before: String): ServiceSectorNodeConnection
2281-
_debug: DjangoDebug
22822215
}
22832216

22842217
input RecurringReservationCreateMutationInput {

0 commit comments

Comments
 (0)