This repository was archived by the owner on Mar 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +49
-5
lines changed Expand file tree Collapse file tree 4 files changed +49
-5
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,11 @@ export const POSITION_CANDIDATES_PER_PAGE = 5;
27
27
*/
28
28
export const INPUT_DEBOUNCE_DELAY = 200 ;
29
29
30
+ /**
31
+ * The delay in milliseconds we are giving to ElasticSearch of re-index changes
32
+ */
33
+ export const ES_REINDEX_DELAY = 3000 ;
34
+
30
35
/**
31
36
* Position statuses
32
37
*/
Original file line number Diff line number Diff line change 3
3
*/
4
4
import { axiosInstance as axios } from "./requestInterceptor" ;
5
5
import config from "../../config" ;
6
+ import { ES_REINDEX_DELAY } from "../constants" ;
7
+ import { delay } from "utils/helpers" ;
6
8
7
9
/**
8
10
* Get job by id.
@@ -40,7 +42,14 @@ export const getEmptyJob = (teamId) => {
40
42
* @returns {Promise<{}> } job object
41
43
*/
42
44
export const createJob = ( data ) => {
43
- return axios . post ( `${ config . API . V5 } /jobs` , data ) ;
45
+ return (
46
+ axios
47
+ . post ( `${ config . API . V5 } /jobs` , data )
48
+ // temporary fix:
49
+ // after creating a job we are reloading the list of jobs
50
+ // so we have to wait a bit to make sure job is indexed in the ES
51
+ . then ( ( response ) => delay ( ES_REINDEX_DELAY ) . then ( ( ) => response ) )
52
+ ) ;
44
53
} ;
45
54
46
55
/**
@@ -51,5 +60,12 @@ export const createJob = (data) => {
51
60
* @returns {Promise<{}> } job object
52
61
*/
53
62
export const updateJob = ( data , jobId ) => {
54
- return axios . put ( `${ config . API . V5 } /jobs/${ jobId } ` , data ) ;
63
+ return (
64
+ axios
65
+ . put ( `${ config . API . V5 } /jobs/${ jobId } ` , data )
66
+ // temporary fix:
67
+ // after updating a job we are reloading the list of jobs
68
+ // so we have to wait a bit to make sure job is indexed in the ES
69
+ . then ( ( response ) => delay ( ES_REINDEX_DELAY ) . then ( ( ) => response ) )
70
+ ) ;
55
71
} ;
Original file line number Diff line number Diff line change 3
3
*/
4
4
import { axiosInstance as axios } from "./requestInterceptor" ;
5
5
import config from "../../config" ;
6
+ import { delay } from "utils/helpers" ;
7
+ import { ES_REINDEX_DELAY } from "constants" ;
6
8
7
9
/**
8
10
* Get resource booking by id.
@@ -21,8 +23,11 @@ export const getReourceBookingById = (resourceBookingId) => {
21
23
* @returns {Promise<{}> } resource booking object
22
24
*/
23
25
export const updateReourceBooking = ( data , resourceBookingId ) => {
24
- return axios . put (
25
- `${ config . API . V5 } /resourceBookings/${ resourceBookingId } ` ,
26
- data
26
+ return (
27
+ axios
28
+ . put ( `${ config . API . V5 } /resourceBookings/${ resourceBookingId } ` , data ) // temporary fix:
29
+ // after updating a resource booking we are reloading the list of resource bookings
30
+ // so we have to wait a bit to make sure job is indexed in the ES
31
+ . then ( ( response ) => delay ( ES_REINDEX_DELAY ) . then ( ( ) => response ) )
27
32
) ;
28
33
} ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Helper utilities
3
+ *
4
+ * This file should contain helper methods which cannot be grouped into a separate file like we did for "format.js".
5
+ * If there are multiple methods which could be grouped into a separate file by their meaning they should be extracted from here to not make this file too big.
6
+ */
7
+
8
+ /**
9
+ * Delay code for some milliseconds using promise.
10
+ *
11
+ * @param {Number } duration duration in milliseconds
12
+ *
13
+ * @returns {Promise<void> } promise
14
+ */
15
+ export const delay = ( duration ) =>
16
+ new Promise ( ( resolve ) => {
17
+ setTimeout ( resolve , duration ) ;
18
+ } ) ;
You can’t perform that action at this time.
0 commit comments