diff --git a/index.js b/index.js
index 33ba115..9b4910c 100644
--- a/index.js
+++ b/index.js
@@ -137,11 +137,15 @@ const template = (data, name) => {
- ${dayTime} ${name}${
+ ${data.notes ? data.notes : `${dayTime} ${name}`}${
+ data.description
+ ? `
+ ${data.description}`
+ : ''
+ }${
type
? `
- ${type}
- `.trim()
+ ${type}`
: ''
}
@@ -168,8 +172,12 @@ const template = (data, name) => {
return `
- ${gpsItem.altitude}
- ${
+ ${gpsItem.altitude}${
+ gpsItem.timestamp
+ ? `
+ `
+ : ''
+ }${
heartRate
? `
@@ -209,7 +217,7 @@ const template = (data, name) => {
};
const fileName = (data, name) => {
- const createdDate = new Date(data.created_at);
+ const createdDate = new Date(data.start_time);
const month = createdDate.getMonth() + 1;
const day = createdDate.getDate();
@@ -258,6 +266,31 @@ const start = async ([exportPath, outputPath = `${process.cwd()}/export`]) => {
.promisify(fs.readFile)(gpsPath)
.catch(console.error);
}
+ else if(item.route_id) { // if session has no GPS, check if it is attached to a route which has GPS
+ const routePath = `${exportPath}/Routes/${item.route_id}.json`;
+ const routeGpsPath = `${exportPath}/Routes/GPS-data/${item.route_id}.json`;
+
+ // get route name and description to add to session description
+ if (fs.existsSync(routePath)) {
+ routeFile = await util
+ .promisify(fs.readFile)(routePath)
+ .catch(console.error);
+ if (routeFile) {
+ route = parse(routeFile);
+ item.description = `No GPS data. Route: ${route.name} / ${route.description.replace(/\r\n/g, ' - ')}`;
+ }
+ }
+
+ // get route GPS and add start/end timestamps
+ if (fs.existsSync(routeGpsPath)) {
+ gpsFile = await util
+ .promisify(fs.readFile)(routeGpsPath)
+ .catch(console.error);
+ gpsFile = gpsFile.toString('utf8'); // convert to string to add start and end timestamps
+ gpsFile = gpsFile.replace('[{', `[{"timestamp":"${new Date(item.start_time).toISOString()}",`);
+ gpsFile = gpsFile.replace('}]', `,"timestamp":"${new Date(item.end_time).toISOString()}"}]`);
+ }
+ }
if (fs.existsSync(heartRatePath)) {
heartRateFile = await util