Skip to content

Commit

Permalink
Release 12-11-2024 (#132)
Browse files Browse the repository at this point in the history
* fix: wrong conceal or trim marker (#126)

* fix: aggregate session from laps (#130)

* fix: aggregate fill session

* feat: enable distance and speed removal (#131)
  • Loading branch information
muktihari authored Nov 12, 2024
1 parent b4f4463 commit 11f8b47
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 58 deletions.
71 changes: 15 additions & 56 deletions src/components/ToolFieldsRemover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. -->

<script setup lang="ts">
import type { Session } from '@/spec/activity'
import type { Record, Session } from '@/spec/activity'
import { ToolMode } from '@/spec/activity-service'
import type { PropType } from 'vue'
</script>
Expand Down Expand Up @@ -43,15 +43,15 @@ import type { PropType } from 'vue'
type="checkbox"
:id="item.value"
:value="item.value"
:disabled="toolMode == ToolMode.Unknown || !show(item.value)"
:disabled="toolMode == ToolMode.Unknown || !hasField(item.value as keyof Record)"
v-model="selectedFields"
/>
<label class="form-check-label" style="color: var(--color-text)" :for="item.value">
{{ item.label }}
</label>
</div>
</div>
<div v-if="isNoFieldsData"><p>(No available fields to be removed.)</p></div>
<div v-if="noAvailableFields"><p>(No available fields to be removed.)</p></div>
</div>
</template>
<script lang="ts">
Expand All @@ -63,6 +63,8 @@ export default {
data() {
return {
dataSource: [
{ value: 'distance', label: 'Distance' },
{ value: 'speed', label: 'Speed' },
{ value: 'cadence', label: 'Cadence' },
{ value: 'heartRate', label: 'Heart Rate' },
{ value: 'power', label: 'Power' },
Expand All @@ -72,48 +74,11 @@ export default {
}
},
computed: {
isNoFieldsData(): boolean {
return !(this.hasCadence || this.hasHeartRate || this.hasPower || this.hasTemperature)
},
hasCadence(): boolean {
for (let i = 0; i < this.sessions.length; i++) {
const ses = this.sessions[i]
for (let j = 0; j < ses.records.length; j++) {
const rec = ses.records[j]
if (rec.cadence != null) return true
}
noAvailableFields(): boolean {
for (const val of this.dataSource) {
if (this.hasField(val.value as keyof Record)) return false
}
return false
},
hasHeartRate(): boolean {
for (let i = 0; i < this.sessions.length; i++) {
const ses = this.sessions[i]
for (let j = 0; j < ses.records.length; j++) {
const rec = ses.records[j]
if (rec.heartRate != null) return true
}
}
return false
},
hasPower(): boolean {
for (let i = 0; i < this.sessions.length; i++) {
const ses = this.sessions[i]
for (let j = 0; j < ses.records.length; j++) {
const rec = ses.records[j]
if (rec.power != null) return true
}
}
return false
},
hasTemperature(): boolean {
for (let i = 0; i < this.sessions.length; i++) {
const ses = this.sessions[i]
for (let j = 0; j < ses.records.length; j++) {
const rec = ses.records[j]
if (rec.temperature != null) return true
}
}
return false
return true
}
},
watch: {
Expand All @@ -129,19 +94,13 @@ export default {
}
},
methods: {
show(value: string): boolean {
switch (value) {
case 'cadence':
return this.hasCadence
case 'heartRate':
return this.hasHeartRate
case 'power':
return this.hasPower
case 'temperature':
return this.hasTemperature
default:
return false
hasField<T extends keyof Record>(field: T): boolean {
for (const ses of this.sessions) {
for (const rec of ses.records) {
if (rec[field] != null) return true
}
}
return false
},
isSelectable(option: any) {
return option.heading != true
Expand Down
2 changes: 1 addition & 1 deletion src/wasm/activity-service/activity/fit/fit.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func (s *DecodeEncoder) recalculateSummary(ses *activity.Session) {
records = records[pos:]
}
sesFromLaps := activity.NewSessionFromLaps(ses.Laps)
aggregator.Fill(ses, sesFromLaps.Session)
aggregator.Fill(ses.Session, sesFromLaps.Session)
ses.Summarize()
}

Expand Down
2 changes: 1 addition & 1 deletion src/wasm/activity-service/activity/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func NewSessionFromLaps(laps []Lap) Session {
)

for i := range laps {
aggregator.Aggregate(ses, laps[i].Lap)
aggregator.Aggregate(ses.Session, laps[i].Lap)
}

return ses
Expand Down

0 comments on commit 11f8b47

Please sign in to comment.