Permalink
Browse files

Adapt to new database format introduced by Olav

  • Loading branch information...
1 parent fc455e9 commit 2e3d6dff3b63a84efea869d9e9c431978eb8bd7d @scy committed Jul 12, 2013
Showing with 8 additions and 4 deletions.
  1. +8 −4 coco-icalres.js
View
@@ -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)) {

0 comments on commit 2e3d6df

Please sign in to comment.