Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
9320236b
Commit
9320236b
authored
9 years ago
by
Tom Robinson
Browse files
Options
Downloads
Patches
Plain Diff
Move timestamp parsing to reducers to fix pulse list ordering bug
parent
fba6bf08
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
frontend/src/lib/redux.js
+17
-0
17 additions, 0 deletions
frontend/src/lib/redux.js
frontend/src/pulse/actions.js
+0
-15
0 additions, 15 deletions
frontend/src/pulse/actions.js
frontend/src/pulse/reducers.js
+7
-5
7 additions, 5 deletions
frontend/src/pulse/reducers.js
with
24 additions
and
20 deletions
frontend/src/lib/redux.js
+
17
−
0
View file @
9320236b
import
moment
from
"
moment
"
;
import
_
from
"
underscore
"
;
// HACK: just use our Angular resources for now
export
function
AngularResourceProxy
(
serviceName
,
methods
)
{
...
...
@@ -25,3 +27,18 @@ export function createThunkAction(actionType, actionThunkCreator) {
}
}
}
// turns string timestamps into moment objects
export
function
momentifyTimestamps
(
object
,
keys
=
[
"
created_at
"
,
"
updated_at
"
])
{
object
=
{
...
object
};
for
(
let
timestamp
of
keys
)
{
if
(
timestamp
in
object
)
{
object
[
timestamp
]
=
moment
(
object
[
timestamp
]);
}
}
return
object
;
}
export
function
momentifyObjectsTimestamps
(
objects
,
keys
)
{
return
_
.
mapObject
(
objects
,
o
=>
momentifyTimestamps
(
o
,
keys
));
}
This diff is collapsed.
Click to expand it.
frontend/src/pulse/actions.js
+
0
−
15
View file @
9320236b
...
...
@@ -3,8 +3,6 @@ import { createAction } from "redux-actions";
import
{
AngularResourceProxy
,
createThunkAction
}
from
"
metabase/lib/redux
"
;
import
{
normalize
,
Schema
,
arrayOf
}
from
"
normalizr
"
;
import
moment
from
"
moment
"
;
const
card
=
new
Schema
(
'
card
'
);
const
pulse
=
new
Schema
(
'
pulse
'
);
const
user
=
new
Schema
(
'
user
'
);
...
...
@@ -31,10 +29,6 @@ export const FETCH_PULSE_CARD_PREVIEW = 'FETCH_PULSE_CARD_PREVIEW';
export
const
fetchPulses
=
createThunkAction
(
FETCH_PULSES
,
function
()
{
return
async
function
(
dispatch
,
getState
)
{
let
pulses
=
await
Pulse
.
list
();
for
(
var
p
of
pulses
)
{
p
.
updated_at
=
moment
(
p
.
updated_at
);
p
.
created_at
=
moment
(
p
.
created_at
);
}
return
normalize
(
pulses
,
arrayOf
(
pulse
));
};
});
...
...
@@ -84,9 +78,6 @@ export const deletePulse = createThunkAction(DELETE_PULSE, function(id) {
export
const
fetchCards
=
createThunkAction
(
FETCH_CARDS
,
function
(
filterMode
=
"
all
"
)
{
return
async
function
(
dispatch
,
getState
)
{
let
cards
=
await
Card
.
list
({
filterMode
});
for
(
var
c
of
cards
)
{
c
.
updated_at
=
moment
(
c
.
updated_at
);
}
return
normalize
(
cards
,
arrayOf
(
card
));
};
});
...
...
@@ -95,12 +86,6 @@ export const fetchCards = createThunkAction(FETCH_CARDS, function(filterMode = "
export
const
fetchUsers
=
createThunkAction
(
FETCH_USERS
,
function
()
{
return
async
function
(
dispatch
,
getState
)
{
let
users
=
await
User
.
list
();
for
(
var
u
of
users
)
{
u
.
date_joined
=
(
u
.
date_joined
)
?
moment
(
u
.
date_joined
)
:
null
;
u
.
last_login
=
(
u
.
last_login
)
?
moment
(
u
.
last_login
)
:
null
;
}
return
normalize
(
users
,
arrayOf
(
user
));
};
});
...
...
This diff is collapsed.
Click to expand it.
frontend/src/pulse/reducers.js
+
7
−
5
View file @
9320236b
import
{
handleActions
}
from
'
redux-actions
'
;
import
{
momentifyTimestamps
,
momentifyObjectsTimestamps
}
from
"
metabase/lib/redux
"
;
import
{
FETCH_PULSES
,
SET_EDITING_PULSE
,
...
...
@@ -14,9 +16,9 @@ import {
}
from
"
./actions
"
;
export
const
pulses
=
handleActions
({
[
FETCH_PULSES
]:
{
next
:
(
state
,
{
payload
})
=>
({
...
payload
.
entities
.
pulse
})
},
[
SAVE_PULSE
]:
{
next
:
(
state
,
{
payload
})
=>
({
...
state
,
[
payload
.
id
]:
payload
})
},
[
SAVE_EDITING_PULSE
]:
{
next
:
(
state
,
{
payload
})
=>
({
...
state
,
[
payload
.
id
]:
payload
})
}
[
FETCH_PULSES
]:
{
next
:
(
state
,
{
payload
})
=>
({
...
momentifyObjectsTimestamps
(
payload
.
entities
.
pulse
)
})
},
[
SAVE_PULSE
]:
{
next
:
(
state
,
{
payload
})
=>
({
...
state
,
[
payload
.
id
]:
momentifyTimestamps
(
payload
)
})
},
[
SAVE_EDITING_PULSE
]:
{
next
:
(
state
,
{
payload
})
=>
({
...
state
,
[
payload
.
id
]:
momentifyTimestamps
(
payload
)
})
}
},
{});
export
const
pulseList
=
handleActions
({
...
...
@@ -33,7 +35,7 @@ export const editingPulse = handleActions({
// NOTE: duplicated from dashboards/reducers.js
export
const
cards
=
handleActions
({
[
FETCH_CARDS
]:
{
next
:
(
state
,
{
payload
})
=>
({
...
payload
.
entities
.
card
})
}
[
FETCH_CARDS
]:
{
next
:
(
state
,
{
payload
})
=>
({
...
momentifyObjectsTimestamps
(
payload
.
entities
.
card
)
})
}
},
{});
export
const
cardList
=
handleActions
({
[
FETCH_CARDS
]:
{
next
:
(
state
,
{
payload
})
=>
payload
.
result
}
...
...
@@ -41,7 +43,7 @@ export const cardList = handleActions({
// NOTE: duplicated from admin/people/reducers.js
export
const
users
=
handleActions
({
[
FETCH_USERS
]:
{
next
:
(
state
,
{
payload
})
=>
({
...
payload
.
entities
.
user
})
}
[
FETCH_USERS
]:
{
next
:
(
state
,
{
payload
})
=>
({
...
momentifyObjectsTimestamps
(
payload
.
entities
.
user
)
})
}
},
[]);
export
const
formInput
=
handleActions
({
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment