Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
AURA
dashboard
Commits
fe3ea9da
Commit
fe3ea9da
authored
Nov 17, 2020
by
Richard Blechinger
Browse files
Fix issues with calculation of nanoseconds
parent
5ed0887b
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/Pages/AddOrEditPlaylist.vue
View file @
fe3ea9da
...
...
@@ -327,8 +327,8 @@
const
totalDuration
=
this
.
playlistEditor
.
entries
.
reduce
((
acc
,
entry
)
=>
{
const
newDuration
=
entry
.
file
?
acc
+
this
.
getFileById
(
entry
.
file
.
id
).
duration
:
acc
+
entry
.
duration
?
acc
+
this
.
durationInSeconds
(
this
.
getFileById
(
entry
.
file
.
id
).
duration
)
:
acc
+
this
.
durationInSeconds
(
entry
.
duration
)
if
(
Number
.
isNaN
(
newDuration
))
{
return
acc
...
...
@@ -337,7 +337,8 @@
return
newDuration
},
0
)
return
this
.
prettyNanoseconds
(
totalDuration
)
const
durationInNanoseconds
=
totalDuration
*
1000
*
1000
*
1000
;
return
this
.
prettyNanoseconds
(
durationInNanoseconds
)
},
...
mapGetters
({
...
...
src/components/filemanager/Playlists.vue
View file @
fe3ea9da
<
template
>
<div>
<edit-playlists-modal
ref=
"editPlaylistsModal"
/>
<!-- Only display a spinner if the playlists are not loaded yet -->
<div
v-if=
"!loaded.playlists"
>
<b-row>
...
...
@@ -182,7 +180,7 @@ export default {
}
const
totalDuration
=
item
.
entries
.
reduce
((
acc
,
entry
)
=>
{
const
newDuration
=
acc
+
entry
.
duration
;
const
newDuration
=
acc
+
this
.
durationInSeconds
(
entry
.
duration
)
;
if
(
Number
.
isNaN
(
newDuration
))
{
return
acc
;
...
...
@@ -191,7 +189,8 @@ export default {
return
newDuration
},
0
)
return
this
.
prettyNanoseconds
(
totalDuration
)
const
totalDurationInNanoseconds
=
totalDuration
*
1000
*
1000
*
1000
;
return
this
.
prettyNanoseconds
(
totalDurationInNanoseconds
)
},
},
}
...
...
src/components/shows/PlaylistSelector.vue
View file @
fe3ea9da
...
...
@@ -46,7 +46,7 @@
<span
:class=
"
{'is-mismatched': isMismatchedLength(data) }"
>
{{
prettyNanoseconds
(
playlistDuration
(
data
)
)
}}
{{
playlistDuration
(
data
)
}}
<abbr
v-if=
"isMismatchedLength(data)"
...
...
@@ -212,21 +212,22 @@ export default {
let
delta
=
0
;
const
totalDuration
=
item
.
entries
.
reduce
((
acc
,
entry
)
=>
{
const
newDuration
=
acc
+
entry
.
duration
;
const
newDuration
=
acc
+
this
.
durationInSeconds
(
entry
.
duration
)
;
if
(
Number
.
isNaN
(
newDuration
))
{
return
acc
;
}
return
newDuration
},
0
)
;
},
0
)
const
unknowns
=
item
.
entries
.
filter
(
entry
=>
!
entry
.
duration
);
if
(
unknowns
.
length
===
1
)
{
delta
=
this
.
timeslotDurationInNs
-
totalDuration
;
delta
=
this
.
durationInSeconds
(
this
.
timeslotDurationInNs
)
-
totalDuration
;
}
return
totalDuration
+
delta
const
totalDurationInNanoseconds
=
(
totalDuration
+
delta
)
*
1000
*
1000
*
1000
return
this
.
prettyNanoseconds
(
totalDurationInNanoseconds
)
},
isMismatchedLength
(
playlist
)
{
...
...
src/mixins/prettyDate.js
View file @
fe3ea9da
...
...
@@ -79,12 +79,20 @@ export default {
}
return
duration
},
durationInSeconds
:
function
(
ns
)
{
const
durationInMilliseconds
=
Math
.
floor
(
ns
/
1000
/
1000
);
return
Math
.
floor
(
durationInMilliseconds
/
1000
);
},
prettyNanoseconds
:
function
(
ns
)
{
var
sec_total
=
ns
/
1000
/
1000
/
1000
var
hours
=
Math
.
floor
(
sec_total
/
3600
)
var
minutes
=
Math
.
floor
((
sec_total
-
(
hours
*
3600
))
/
60
)
var
seconds
=
Math
.
floor
((
sec_total
-
(
hours
*
3600
)
-
(
minutes
*
60
))
*
10
)
/
10
return
this
.
leadingZero
(
hours
)
+
'
:
'
+
this
.
leadingZero
(
minutes
)
+
'
:
'
+
this
.
leadingZero
(
seconds
.
toFixed
(
0
))
const
durationInMilliseconds
=
Math
.
floor
(
ns
/
1000
/
1000
);
const
seconds
=
parseInt
((
durationInMilliseconds
/
1000
)
%
60
),
minutes
=
parseInt
((
durationInMilliseconds
/
(
1000
*
60
))
%
60
),
hours
=
parseInt
((
durationInMilliseconds
/
(
1000
*
60
*
60
))
%
24
);
return
this
.
leadingZero
(
hours
)
+
'
:
'
+
this
.
leadingZero
(
minutes
)
+
'
:
'
+
this
.
leadingZero
(
seconds
)
},
nanosecondsToMinutes
:
function
(
ns
)
{
return
ns
/
1000
/
1000
/
1000
/
60
;
...
...
Richard Blechinger
@pretzelhands
mentioned in issue
#70 (closed)
·
Nov 17, 2020
mentioned in issue
#70 (closed)
mentioned in issue #70
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment