setting up fixed decimal values for mins left, get ahead, practiced

practiced-songs
Matthew Huntington 1 year ago
parent 25c21f3cca
commit bd02cc79c7

@ -10,24 +10,19 @@
} }
}, },
methods: { methods: {
refresh(){ setTimes(response){
axios.get(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'mins-left-to-practice-today').then((response)=>{
this.time_left= response.data.time_left;
this.mins_practiced_today = response.data.mins_practiced_today;
const today = new Date()
this.to_get_ahead = this.time_left + (today.getMonth()+1)*150 + today.getDate()*5
})
}
},
mounted() {
axios.get(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'mins-left-to-practice-today').then((response)=>{
this.time_left= response.data.time_left; this.time_left= response.data.time_left;
this.mins_practiced_today = response.data.mins_practiced_today; this.mins_practiced_today = response.data.mins_practiced_today;
const today = new Date() const today = new Date()
this.to_get_ahead = this.time_left + (today.getMonth()+1)*150 + today.getDate()*5 this.to_get_ahead = this.time_left + (today.getMonth()+1)*150 + today.getDate()*5
}) },
refresh(){
axios.get(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'mins-left-to-practice-today').then(this.setTimes)
}
},
mounted() {
axios.get(import.meta.env.VITE_PRACTICE_TRACKER_API_URL+'mins-left-to-practice-today').then(this.setTimes)
} }
} }
</script> </script>
@ -35,11 +30,11 @@
<template> <template>
<h2 @click="refresh">Time Summary</h2> <h2 @click="refresh">Time Summary</h2>
<h3>Mins Left to Practice Today</h3> <h3>Mins Left to Practice Today</h3>
{{time_left}} {{time_left.toFixed(4)}}
<h3>To Get Ahead</h3> <h3>To Get Ahead</h3>
{{to_get_ahead}} {{to_get_ahead.toFixed(4)}}
<h3>Mins Practiced Today</h3> <h3>Mins Practiced Today</h3>
{{mins_practiced_today}} {{mins_practiced_today.toFixed(4)}}
</template> </template>
<style scoped> <style scoped>

@ -1,14 +1,6 @@
<script lang="ts"> <script lang="ts">
import axios from 'axios'; import axios from 'axios';
const padDigits = (value) => {
if(value < 10){
return '0'+value;
} else {
return value;
}
}
const getHours = (seconds) => { const getHours = (seconds) => {
return Math.floor( seconds / 60 / 60 ); return Math.floor( seconds / 60 / 60 );
} }
@ -31,7 +23,7 @@
const formatSeconds = (total) => { const formatSeconds = (total) => {
const timeObj = createTimeObj(total) const timeObj = createTimeObj(total)
return `${timeObj.hours*60 + timeObj.minutes}:${padDigits(timeObj.seconds)}`; return `${timeObj.hours*60 + timeObj.minutes}:${timeObj.seconds.toString().padStart(2,'0')}`;
} }
export default { export default {

Loading…
Cancel
Save