Skip to content

Commit

Permalink
fix: resource limits
Browse files Browse the repository at this point in the history
- increase memory limit for backend
- use snackbar for error messages in client
  • Loading branch information
cgawron committed Oct 4, 2024
1 parent 0698329 commit 4f26ed7
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 11 deletions.
2 changes: 1 addition & 1 deletion backend/k8s/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ spec:
- containerPort: 5000
resources:
limits:
memory: 100Mi
memory: 2Gi
restartPolicy: Always
automountServiceAccountToken: false

Expand Down
12 changes: 5 additions & 7 deletions client/cypress/e2e/scheduling.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ context('Error handling', () => {
describe('Error getting user', () => {
before(() => {
cy.intercept('/api/v1/users/findUserByUrl?url=christian-gawron', { statusCode: 500, body: { error: "no data" } }).as('getUser')
cy.visit('/schedule/christian-gawron/sprechstunde')
cy.visit('/users/christian-gawron/sprechstunde')
})

it('Should show error message', () => {
Expand All @@ -26,13 +26,12 @@ context('Scheduling page', () => {
describe('Visit scheduling page and schedule appointment', () => {
before(() => {
cy.intercept('POST', '/api/v1/**', { body: { error: 'not possible' } }).as('apiCheck')
cy.visit('/schedule/christian-gawron/sprechstunde')
cy.visit('/users/christian-gawron/sprechstunde')
})

it('Check simple schedule flow', () => {
cy.wait(['@getUser', '@getEvent', '@getAvailable'], { timeout: 10000 })
cy.get('h6').should('contain', 'Christian Gawron')
cy.get('.MuiPickersDay-today').should('contain', '25')
cy.get('.MuiPickersDay-today').should('contain', '25').click()
cy.contains('07:00').click()
cy.get('[name=name]').type('Max Mustermann')
cy.get('[name=email]').type('[email protected]')
Expand All @@ -47,13 +46,12 @@ context('Scheduling page', () => {
describe('Error creating appointment', () => {
before(() => {
cy.intercept('POST', '/api/v1/**', { statusCode: 400, body: { error: 'not possible' } }).as('apiCheck')
cy.visit('/schedule/christian-gawron/sprechstunde')
cy.visit('/users/christian-gawron/sprechstunde')
})

it('should show an error message', () => {
cy.wait(['@getUser', '@getEvent', '@getAvailable'], { timeout: 10000 })
cy.get('h6').should('contain', 'Christian Gawron')
cy.get('.MuiPickersDay-today').should('contain', '25')
cy.get('.MuiPickersDay-today').should('contain', '25').click()
cy.contains('07:00').click()
cy.get('[name=name]').type('Max Mustermann')
cy.get('[name=email]').type('[email protected]')
Expand Down
4 changes: 3 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@
"@types/react": "^18.2.21",
"axios": "^1.5.0",
"common": "workspace:*",
"date-fns": "^4.0.0",
"date-fns": "^4.1.0",
"date-fns-tz": "^3.2.0",
"dayjs": "^1.11.13",
"i18next": "^23.15.1",
"i18next-browser-languagedetector": "^8.0.0",
"i18next-http-backend": "^2.6.1",
"js-cookie": "^3.0.5",
"jsonwebtoken": "^9.0.2",
"moment": "^2.30.1",
"notistack": "^3.0.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-i18next": "^15.0.2",
Expand Down
7 changes: 5 additions & 2 deletions client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Finished from "./pages/Finished";

import { isAuthenticated } from "./helpers/helpers";
import { createTheme, ThemeProvider } from "@mui/material/styles";
import { SnackbarProvider } from 'notistack';

import "./i18n";
import { LocalizationProvider } from "@mui/x-date-pickers";
Expand Down Expand Up @@ -88,7 +89,8 @@ console.log("localeText: %o", deDE.components.MuiLocalizationProvider.defaultPro
root.render(
<StrictMode>
<Suspense fallback="loading">
<GoogleOAuthProvider clientId={CLIENT_ID}>
<SnackbarProvider maxSnack={3}>
<GoogleOAuthProvider clientId={CLIENT_ID}>

<LocalizationProvider dateAdapter={AdapterDateFns} adapterLocale={de} localeText={deDE.components.MuiLocalizationProvider.defaultProps.localeText}>
<ThemeProvider theme={theme}>
Expand Down Expand Up @@ -159,7 +161,8 @@ root.render(
</ThemeProvider>
</LocalizationProvider>

</GoogleOAuthProvider>
</GoogleOAuthProvider>
</SnackbarProvider>
</Suspense>
</StrictMode>
);
4 changes: 4 additions & 0 deletions client/src/pages/Booking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { EMPTY_EVENT, Event, Slot, IntervalSet } from "common";
import { UserDocument } from "../helpers/UserDocument";
import { useTranslation } from "react-i18next";
import { EventType } from "../components/EventType";
import { useSnackbar } from "notistack";

const theme = createTheme({
components: {
Expand Down Expand Up @@ -130,6 +131,7 @@ const Booking = (props: any) => {
const { t, i18n } = useTranslation();
const data = useParams<{ user_url: string; url: string }>();
const navigate = useNavigate();
const { enqueueSnackbar, closeSnackbar } = useSnackbar();

type Details = { name: string; email: string; description: string };

Expand Down Expand Up @@ -189,6 +191,8 @@ const Booking = (props: any) => {
}
})
.catch((err) => {
console.log("error getting user: %o", err);
enqueueSnackbar("Error getting user", { variant: "error", autoHideDuration: 15000, className: "error" });
return err;
});
}, [data.url, data.user_url, navigate, selectedDate]);
Expand Down
40 changes: 40 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7788,6 +7788,7 @@ __metadata:
cypress: "npm:^13.15.0"
cypress-ctrf-json-reporter: "npm:^0.0.11"
date-fns: "npm:^4.0.0"
date-fns-tz: "npm:^3.2.0"
dayjs: "npm:^1.11.13"
dotenv-cli: "npm:^7.4.2"
eslint: "npm:^9.11.1"
Expand All @@ -7801,6 +7802,7 @@ __metadata:
jsonwebtoken: "npm:^9.0.2"
moment: "npm:^2.30.1"
node-sass: "npm:^9.0.0"
notistack: "npm:^3.0.1"
react: "npm:^18.3.1"
react-dom: "npm:^18.3.1"
react-i18next: "npm:^15.0.2"
Expand Down Expand Up @@ -7866,6 +7868,13 @@ __metadata:
languageName: node
linkType: hard

"clsx@npm:^1.1.0":
version: 1.2.1
resolution: "clsx@npm:1.2.1"
checksum: 10/5ded6f61f15f1fa0350e691ccec43a28b12fb8e64c8e94715f2a937bc3722d4c3ed41d6e945c971fc4dcc2a7213a43323beaf2e1c28654af63ba70c9968a8643
languageName: node
linkType: hard

"clsx@npm:^2.1.1":
version: 2.1.1
resolution: "clsx@npm:2.1.1"
Expand Down Expand Up @@ -8554,6 +8563,15 @@ __metadata:
languageName: node
linkType: hard

"date-fns-tz@npm:^3.2.0":
version: 3.2.0
resolution: "date-fns-tz@npm:3.2.0"
peerDependencies:
date-fns: ^3.0.0 || ^4.0.0
checksum: 10/8ab4745f00b40381220f0a7a2ec16e217cb629d4018a19047264d289dd260322baa23e19b3ed63c7e553f9ad34bea9dea105391132930a3e141e9a0a53e54af2
languageName: node
linkType: hard

"date-fns@npm:^2.30.0":
version: 2.30.0
resolution: "date-fns@npm:2.30.0"
Expand Down Expand Up @@ -11513,6 +11531,15 @@ __metadata:
languageName: node
linkType: hard

"goober@npm:^2.0.33":
version: 2.1.14
resolution: "goober@npm:2.1.14"
peerDependencies:
csstype: ^3.0.10
checksum: 10/372f18333ef64c403d29be7c1175cc9cd74cb947ec52cd42fbb1cf3f9870ac1dfec9c7671192cbf47ebc0ec17d8b05b6ef9a2b92952397d5b555a692381d5eaa
languageName: node
linkType: hard

"google-auth-library@npm:9.0.0, google-auth-library@npm:^9.0.0":
version: 9.0.0
resolution: "google-auth-library@npm:9.0.0"
Expand Down Expand Up @@ -16701,6 +16728,19 @@ __metadata:
languageName: node
linkType: hard

"notistack@npm:^3.0.1":
version: 3.0.1
resolution: "notistack@npm:3.0.1"
dependencies:
clsx: "npm:^1.1.0"
goober: "npm:^2.0.33"
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
checksum: 10/be6ca9e1c2f06118fe0545eaaf91f2f260efe5b1ff3b3f6575a346d5c9f88666e7f13ef4369a56037a2c89c030c191f034f6e6b5a28be704540a23442e2d19a9
languageName: node
linkType: hard

"now-and-later@npm:^3.0.0":
version: 3.0.0
resolution: "now-and-later@npm:3.0.0"
Expand Down

0 comments on commit 4f26ed7

Please sign in to comment.