Skip to content

Commit

Permalink
Retries på stillingsannonser fra arbeidsplassen
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbb committed Oct 23, 2023
1 parent 4b68d6c commit b5ad752
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Dockerfile
.prettierignore
nais/*.yaml
*.svg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { arbeidsplassenURL } from '../../../../lenker';
import PamboksIkon from './arbeidsplassen-ikon.svg';
import './Arbeidsplassen.css';
Expand Down Expand Up @@ -56,6 +56,7 @@ const PamStatusAnnonser = z.object({
const useAntallannonser = () => {
const { valgtOrganisasjon } = useContext(OrganisasjonsDetaljerContext);
const orgnr = valgtOrganisasjon?.organisasjon?.OrganizationNumber;
const [retries, setRetries] = useState(0);

const { data } = useSWR(
orgnr === undefined
Expand All @@ -67,12 +68,21 @@ const useAntallannonser = () => {
fetcher,
{
onError: (error) => {
Sentry.captureMessage(
`hent AntallAnnonser fra stillingsregistrering-api feilet med ${
error.status !== undefined ? `${error.status} ${error.statusText}` : error
}`
);
if (retries === 5) {
Sentry.captureMessage(
`hent AntallAnnonser fra stillingsregistrering-api feilet med ${
error.status !== undefined
? `${error.status} ${error.statusText}`
: error
}`
);
}
setRetries((x) => x + 1);
},
onSuccess: () => {
setRetries(0);
},
errorRetryInterval: 300,
}
);
return data ?? 0;
Expand Down

0 comments on commit b5ad752

Please sign in to comment.