Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adapt to new database format introduced by Olav

  • Loading branch information...
commit 2e3d6dff3b63a84efea869d9e9c431978eb8bd7d 1 parent fc455e9
@scy authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 coco-icalres.js
View
12 coco-icalres.js
@@ -12,15 +12,19 @@ var uidUser = user.replace(/[^a-zA-Z]/g, '');
var days = {};
var events = [];
-db.each('SELECT * FROM slots WHERE username = (?)', user, function (err, row) {
+db.each('SELECT * FROM days WHERE username = (?)', user, function (err, row) {
if (err) {
console.log(err);
return;
}
- if (!days[row.day]) {
- days[row.day] = [];
+ var slotsArray = [], slots = JSON.parse(row.slots);
+ for (var slot in slots) {
+ if (!row.slots.hasOwnProperty(slot)) {
+ continue;
+ }
+ slotsArray[parseInt(slot, 10)] = slots[slot];
}
- days[row.day][row.slot] = row.assignment;
+ days[row.day] = slotsArray;
}, function (err, count) {
for (var date in days) {
if (!days.hasOwnProperty(date)) {
Please sign in to comment.
Something went wrong with that request. Please try again.