From 3a696b971fa67062a07d6a248fec7ba361516408 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Mon, 14 Feb 2022 11:17:33 +0100 Subject: [PATCH 1/4] fix(ui) - saved search on save and update --- .../shared/SessionSearch/SessionSearch.tsx | 4 +-- frontend/app/duck/search.js | 31 +++++++++++++------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/frontend/app/components/shared/SessionSearch/SessionSearch.tsx b/frontend/app/components/shared/SessionSearch/SessionSearch.tsx index 46bdd845e..a3f799ed7 100644 --- a/frontend/app/components/shared/SessionSearch/SessionSearch.tsx +++ b/frontend/app/components/shared/SessionSearch/SessionSearch.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import { List } from 'immutable'; import FilterList from 'Shared/Filters/FilterList'; import FilterSelection from 'Shared/Filters/FilterSelection'; import SaveFilterButton from 'Shared/SaveFilterButton'; @@ -13,7 +12,7 @@ interface Props { edit: typeof edit; addFilter: typeof addFilter; } -function SessionSearch(props) { +function SessionSearch(props: Props) { const { appliedFilter } = props; const hasEvents = appliedFilter.filters.filter(i => i.isEvent).size > 0; const hasFilters = appliedFilter.filters.filter(i => !i.isEvent).size > 0; @@ -82,7 +81,6 @@ function SessionSearch(props) {
- {/* */}
diff --git a/frontend/app/duck/search.js b/frontend/app/duck/search.js index 4bce0e618..8b4ab8e12 100644 --- a/frontend/app/duck/search.js +++ b/frontend/app/duck/search.js @@ -38,7 +38,7 @@ function chartWrapper(chart = []) { const savedSearchIdKey = 'searchId' const updateItemInList = createListUpdater(savedSearchIdKey); const updateInstance = (state, instance) => state.getIn([ "savedSearch", savedSearchIdKey ]) === instance[savedSearchIdKey] - ? state.mergeIn([ "savedSearch" ], instance) + ? state.mergeIn([ "savedSearch" ], SavedFilter(instance)) : state; const initialState = Map({ @@ -63,10 +63,6 @@ function reducer(state = initialState, action = {}) { return action.fromUrl ? state.set('instance', Filter(action.filter)) : state.mergeIn(['instance'], action.filter); - case success(SAVE): - return updateItemInList(updateInstance(state, action.data), action.data); - case success(REMOVE): - return state.update('list', list => list.filter(item => item.searchId !== action.id)); case success(FETCH): return state.set("instance", action.data); case success(FETCH_LIST): @@ -136,7 +132,18 @@ export const edit = reduceThenFetchResource((instance) => ({ instance, })); -export const remove = createRemove(name, (id) => `/saved_search/${id}`); +export const remove = (id) => (dispatch, getState) => { + return dispatch({ + types: REMOVE.array, + call: client => client.delete(`/saved_search/${id}`), + id, + }).then(() => { + dispatch(applySavedSearch(new SavedFilter({}))); + dispatch(fetchList()); + }); +}; + +// export const remove = createRemove(name, (id) => `/saved_search/${id}`); export const applyFilter = reduceThenFetchResource((filter, fromUrl=false) => ({ type: APPLY, @@ -172,15 +179,21 @@ export function fetch(id) { } export const save = (id) => (dispatch, getState) => { -// export function save(id) { const filter = getState().getIn([ 'search', 'instance']).toData(); filter.filters = filter.filters.map(filterMap); + const isNew = !id; const instance = getState().getIn([ 'search', 'savedSearch']).toData(); - // instance = instance instanceof SavedFilter ? instance : new SavedFilter(instance); return dispatch({ types: SAVE.array, - call: client => client.post(!id ? '/saved_search' : `/saved_search/${id}`, { ...instance, filter }) + call: client => client.post(isNew ? '/saved_search' : `/saved_search/${id}`, { ...instance, filter }) + }).then(() => { + dispatch(fetchList()).then(() => { + if (isNew) { + const lastSavedSearch = getState().getIn([ 'search', 'list']).last(); + dispatch(applySavedSearch(lastSavedSearch)); + } + }); }); } From 64fd23a35b931afea7d03aebb23949f70d08f1d5 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Mon, 14 Feb 2022 14:14:49 +0100 Subject: [PATCH 2/4] fix(ui) - timestamp to utc --- frontend/app/components/shared/SessionItem/Counter.tsx | 4 ++-- frontend/app/date.js | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/app/components/shared/SessionItem/Counter.tsx b/frontend/app/components/shared/SessionItem/Counter.tsx index 5303974ae..9656ae753 100644 --- a/frontend/app/components/shared/SessionItem/Counter.tsx +++ b/frontend/app/components/shared/SessionItem/Counter.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react' import { Duration } from 'luxon'; -import { durationFormatted, formatTimeOrDate } from 'App/date'; +import { durationFormatted, convertTimestampToUtcTimestamp } from 'App/date'; interface Props { startTime: any, @@ -9,7 +9,7 @@ interface Props { function Counter({ startTime, className }: Props) { let intervalId; - const [duration, setDuration] = useState(new Date().getTime() - startTime) + const [duration, setDuration] = useState(new Date().getTime() - convertTimestampToUtcTimestamp(startTime)); const formattedDuration = durationFormatted(Duration.fromMillis(duration)); useEffect(() => { diff --git a/frontend/app/date.js b/frontend/app/date.js index 783da4428..089c48362 100644 --- a/frontend/app/date.js +++ b/frontend/app/date.js @@ -111,3 +111,6 @@ export const checkRecentTime = (date, format) => { export const formatMs = (ms: number): string => ms < 1000 ? `${ Math.trunc(ms) }ms` : `${ Math.trunc(ms/100) / 10 }s`; +export const convertTimestampToUtcTimestamp = (timestamp: number): number => { + return DateTime.fromMillis(timestamp).toUTC().toMillis(); +} \ No newline at end of file From 0dc4d8af1eb5174aeb6d84336644d917f9c92117 Mon Sep 17 00:00:00 2001 From: Rajesh Rajendran Date: Mon, 14 Feb 2022 14:37:51 +0000 Subject: [PATCH 3/4] Enabling debug message in script --- scripts/helmcharts/openreplay/files/dbops.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/helmcharts/openreplay/files/dbops.sh b/scripts/helmcharts/openreplay/files/dbops.sh index f856ae40b..f5cbb949f 100644 --- a/scripts/helmcharts/openreplay/files/dbops.sh +++ b/scripts/helmcharts/openreplay/files/dbops.sh @@ -1,5 +1,6 @@ #!/bin/bash +set -x cd $(dirname $0) is_migrate=$1 From 2ea64da188616002cd66f94042c1bf91c225e31c Mon Sep 17 00:00:00 2001 From: --global <--global> Date: Mon, 14 Feb 2022 15:44:05 +0100 Subject: [PATCH 4/4] fix(migration): validating migration version Signed-off-by: --global <--global> --- scripts/helmcharts/openreplay/files/dbops.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/helmcharts/openreplay/files/dbops.sh b/scripts/helmcharts/openreplay/files/dbops.sh index f5cbb949f..b77fd61ff 100644 --- a/scripts/helmcharts/openreplay/files/dbops.sh +++ b/scripts/helmcharts/openreplay/files/dbops.sh @@ -7,6 +7,7 @@ is_migrate=$1 # Converting alphaneumeric to number. PREVIOUS_APP_VERSION=`echo $PREVIOUS_APP_VERSION | cut -d "v" -f2` +CHART_APP_VERSION=`echo $CHART_APP_VERSION | cut -d "v" -f2` function migration() { ls -la /opt/openreplay/openreplay