Skip to content

Commit

Permalink
Merge pull request #140 from johannes-martin/main
Browse files Browse the repository at this point in the history
Added ALL_DATA configuration option to allow uploading all available historic data to Nightscout.
  • Loading branch information
timoschlueter authored May 27, 2024
2 parents 851356e + 672ce88 commit 58b3978
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The script takes the following environment variables
| NIGHTSCOUT_DEVICE_NAME | Sets the device name used in Nightscout | nightscout-librelink-up | |
| LOG_LEVEL | The setting of verbosity for logging, should be one of info or debug | info | |
| SINGLE_SHOT | Disables the scheduler and runs the script just once | true | |
| ALL_DATA | Upload all available data from LibreLink Up instead of just data newer than last upload. LibreLinkUp sometimes lags behind in reporting recent historical data, so it is advised to run the script with ALL_DATA set to true at least once a day. | true | |

## Usage

Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function readConfig()

logLevel: process.env.LOG_LEVEL || 'info',
singleShot: process.env.SINGLE_SHOT === 'true',
allData: process.env.ALL_DATA === 'true',

nightscoutApiV3: process.env.NIGHTSCOUT_API_V3 === 'true',
nightscoutDisableHttps: process.env.NIGHTSCOUT_DISABLE_HTTPS === 'true',
Expand Down
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,7 @@ export async function createFormattedMeasurements(measurementData: GraphData): P
const formattedMeasurements: Entry[] = [];
const glucoseMeasurement = measurementData.connection.glucoseMeasurement;
const measurementDate = getUtcDateFromString(glucoseMeasurement.FactoryTimestamp);
const lastEntry = await nightscoutClient.lastEntry();

const lastEntry = config.allData ? null : await nightscoutClient.lastEntry();
// Add the most recent measurement first
if (lastEntry === null || measurementDate > lastEntry.date)
{
Expand Down

0 comments on commit 58b3978

Please sign in to comment.