Skip to content

Commit 3ca5117

Browse files
authored
Merge pull request #2 from Hiyorimi/main
adds useAttributes option and closes #1
2 parents 0a74ea6 + c5b086f commit 3ca5117

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

src/index.ts

+32-23
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ export default runExtension({
2525
"Your Oura Ring personal access token, accessible from https://cloud.ouraring.com/personal-access-tokens.",
2626
action: { type: "input", placeholder: "xxxxxx" },
2727
},
28+
{
29+
id: "use-attributes",
30+
name: "Use plain text",
31+
description:
32+
"Toggles the usage of attributes on import.",
33+
action: { type: "switch" },
34+
},
2835
],
2936
});
3037

@@ -45,6 +52,7 @@ export default runExtension({
4552
const pageTitle = getPageTitleByBlockUid(blockUid);
4653
const dateFromPage = window.roamAlphaAPI.util.pageTitleToDate(pageTitle);
4754
const token = args.extensionAPI.settings.get("token");
55+
const useAttributes = args.extensionAPI.settings.get("use-attributes");
4856
if (!token) {
4957
window.roamAlphaAPI.updateBlock({
5058
block: {
@@ -131,6 +139,7 @@ export default runExtension({
131139
])
132140
.then(([sleepData, activityData, readinessData]) => {
133141
const sleep = sleepData.sleep[0];
142+
const attributeColon = useAttributes ? ':' : '::';
134143
if (!sleep) {
135144
bullets.push(
136145
`There is no sleep data available for ${formattedDate}`
@@ -140,20 +149,20 @@ export default runExtension({
140149
const formattedStart = format(new Date(bedtime_start), "hh:mm:ss");
141150
const formattedEnd = format(new Date(bedtime_end), "hh:mm:ss");
142151
bullets.push(
143-
`Bedtime Start:: ${formattedStart}`,
144-
`Bedtime End:: ${formattedEnd}`,
145-
`Sleep Score:: ${sleep.score}`,
146-
`Sleep Efficiency:: ${sleep.efficiency}`,
147-
`Sleep Duration:: ${secondsToTimeString(sleep.duration)}`,
148-
`Total Sleep:: ${secondsToTimeString(sleep.total)}`,
149-
`Total Awake:: ${secondsToTimeString(sleep.awake)}`,
150-
`Sleep Latency:: ${secondsToTimeString(sleep.onset_latency)}`,
151-
`Light Sleep:: ${secondsToTimeString(sleep.light)}`,
152-
`Rem Sleep:: ${secondsToTimeString(sleep.rem)}`,
153-
`Deep Sleep:: ${secondsToTimeString(sleep.deep)}`,
154-
`Resting Heart Rate:: ${sleep.hr_lowest}`,
155-
`Average Heart Rate:: ${sleep.hr_average}`,
156-
`Heart Rate Variability:: ${sleep.rmssd}`
152+
`Bedtime Start${attributeColon} ${formattedStart}`,
153+
`Bedtime End${attributeColon} ${formattedEnd}`,
154+
`Sleep Score${attributeColon} ${sleep.score}`,
155+
`Sleep Efficiency${attributeColon} ${sleep.efficiency}`,
156+
`Sleep Duration${attributeColon} ${secondsToTimeString(sleep.duration)}`,
157+
`Total Sleep${attributeColon} ${secondsToTimeString(sleep.total)}`,
158+
`Total Awake${attributeColon} ${secondsToTimeString(sleep.awake)}`,
159+
`Sleep Latency${attributeColon} ${secondsToTimeString(sleep.onset_latency)}`,
160+
`Light Sleep${attributeColon} ${secondsToTimeString(sleep.light)}`,
161+
`Rem Sleep${attributeColon} ${secondsToTimeString(sleep.rem)}`,
162+
`Deep Sleep${attributeColon} ${secondsToTimeString(sleep.deep)}`,
163+
`Resting Heart Rate${attributeColon} ${sleep.hr_lowest}`,
164+
`Average Heart Rate${attributeColon} ${sleep.hr_average}`,
165+
`Heart Rate Variability${attributeColon} ${sleep.rmssd}`
157166
);
158167
}
159168

@@ -167,14 +176,14 @@ export default runExtension({
167176
const formattedStart = format(new Date(day_start), "hh:mm:ss");
168177
const formattedEnd = format(new Date(day_end), "hh:mm:ss");
169178
bullets.push(
170-
`Day Start:: ${formattedStart}`,
171-
`Day End:: ${formattedEnd}`,
172-
`Activity Score:: ${activity.score}`,
173-
`Low Activity:: ${secondsToTimeString(activity.low * 60)}`,
174-
`Medium Activity:: ${secondsToTimeString(activity.medium * 60)}`,
175-
`High Activity:: ${secondsToTimeString(activity.high * 60)}`,
176-
`Rest Activity:: ${secondsToTimeString(activity.rest * 60)}`,
177-
`Steps:: ${activity.steps}`
179+
`Day Start${attributeColon} ${formattedStart}`,
180+
`Day End${attributeColon} ${formattedEnd}`,
181+
`Activity Score${attributeColon} ${activity.score}`,
182+
`Low Activity${attributeColon} ${secondsToTimeString(activity.low * 60)}`,
183+
`Medium Activity${attributeColon} ${secondsToTimeString(activity.medium * 60)}`,
184+
`High Activity${attributeColon} ${secondsToTimeString(activity.high * 60)}`,
185+
`Rest Activity${attributeColon} ${secondsToTimeString(activity.rest * 60)}`,
186+
`Steps${attributeColon} ${activity.steps}`
178187
);
179188
}
180189

@@ -184,7 +193,7 @@ export default runExtension({
184193
`There is no activity data available for ${formattedDate}`
185194
);
186195
} else {
187-
bullets.push(`Readiness Score:: ${readiness.score}`);
196+
bullets.push(`Readiness Score${attributeColon} ${readiness.score}`);
188197
}
189198

190199
const base = getOrderByBlockUid(blockUid);

0 commit comments

Comments
 (0)