Skip to content

Commit

Permalink
1.1.1 (#2)
Browse files Browse the repository at this point in the history
Update: Caching handling
  • Loading branch information
sergejmueller committed Feb 17, 2019
1 parent 5b7960c commit 0d8c95d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# oppy / CHANGELOG


### 1.1.1 (2019-02-17)

* Update: Caching handling


### 1.1.0 (2019-02-17)

* Feature: Cache reported absences
Expand Down
24 changes: 13 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (! argv['personio-ics'] || ! argv['slack-webhook']) {
// Cache init
const cache = new CachemanFile({tmpDir: './cache'});
const cacheKey = new Date().toISOString().split('T')[0];
const cacheTTL = 60 * 60 * 10;
const cacheTTL = 60 * 60 * 24;

// Absences pool
let absences = [];
Expand Down Expand Up @@ -54,23 +54,25 @@ ical.fromURL(argv['personio-ics'], {}, (error, data) => {
cache.get(cacheKey, async (error, value) => {

if (error) {
console.log('Caching error');
console.log('Cacheman error');

return;
process.exit(1);
}

const diff = difference(absences, value);

if (! diff.length) {
return;
}

await cache.set(cacheKey, absences, cacheTTL);

if (diff.length) {
got(argv['slack-webhook'], {
method: 'POST',
body: JSON.stringify({
'text': 'Today absent:\n`' + diff.join('`\n`') + '`'
})
});
}
got(argv['slack-webhook'], {
method: 'POST',
body: JSON.stringify({
'text': 'Today absent:\n`' + diff.join('`\n`') + '`'
})
});

})

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deptagency/oppy",
"version": "1.1.0",
"version": "1.1.1",
"main": "index.js",
"license": "MIT",
"description": "Slack Bot for Personio daily absences",
Expand Down

0 comments on commit 0d8c95d

Please sign in to comment.