summaryrefslogtreecommitdiff
path: root/model
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2013-09-15 12:53:11 +0200
committerKevin Chabowski <kevin@kch42.de>2013-09-15 12:53:11 +0200
commit819a2e2c9b15e5167f8af3736905569949306c94 (patch)
treec359490b71fd090c9a3033905e6f32640f67ced3 /model
parentc0a06609919d09fbcb6326ff69cc455dd13506ef (diff)
downloadmailremind-819a2e2c9b15e5167f8af3736905569949306c94.tar.gz
mailremind-819a2e2c9b15e5167f8af3736905569949306c94.tar.bz2
mailremind-819a2e2c9b15e5167f8af3736905569949306c94.zip
Changed weird internal terminology
Diffstat (limited to 'model')
-rw-r--r--model/dbmodel.go8
-rw-r--r--model/mysql/jobs.go34
-rw-r--r--model/mysql/queries.go8
3 files changed, 25 insertions, 25 deletions
diff --git a/model/dbmodel.go b/model/dbmodel.go
index 2889908..d4036d1 100644
--- a/model/dbmodel.go
+++ b/model/dbmodel.go
@@ -3,7 +3,7 @@ package model
import (
"errors"
"fmt"
- "kch42.de/gostuff/mailremind/chronos"
+ "kch42.de/gostuff/mailremind/schedule"
"sync"
"time"
)
@@ -23,7 +23,7 @@ type User interface {
PWHash() []byte
SetPWHash([]byte) error
- AddJob(subject string, content []byte, chron chronos.MultiChronos, next time.Time) (Job, error)
+ AddJob(subject string, content []byte, sched schedule.MultiSchedule, next time.Time) (Job, error)
Jobs() []Job
JobByID(DBID) (Job, error)
CountJobs() int
@@ -50,8 +50,8 @@ type Job interface {
Content() []byte
SetContent([]byte) error
- Chronos() chronos.MultiChronos
- SetChronos(chronos.MultiChronos) error
+ Schedule() schedule.MultiSchedule
+ SetSchedule(schedule.MultiSchedule) error
Next() time.Time
SetNext(time.Time) error
diff --git a/model/mysql/jobs.go b/model/mysql/jobs.go
index 1b9598b..eef5667 100644
--- a/model/mysql/jobs.go
+++ b/model/mysql/jobs.go
@@ -3,8 +3,8 @@ package mysql
import (
"database/sql"
"fmt"
- "kch42.de/gostuff/mailremind/chronos"
"kch42.de/gostuff/mailremind/model"
+ "kch42.de/gostuff/mailremind/schedule"
"log"
"time"
)
@@ -17,7 +17,7 @@ type Job struct {
subject string
content []byte
next time.Time
- chron []chronos.Chronos
+ sched schedule.MultiSchedule
}
func jobFromSQL(con *MySQLDBCon, s scanner) (*Job, error) {
@@ -25,13 +25,13 @@ func jobFromSQL(con *MySQLDBCon, s scanner) (*Job, error) {
var subject string
var content []byte
var _next int64
- var _mchron string
+ var _msched string
- if err := s.Scan(&_id, &_user, &subject, &content, &_next, &_mchron); err != nil {
+ if err := s.Scan(&_id, &_user, &subject, &content, &_next, &_msched); err != nil {
return nil, err
}
- chron, err := chronos.ParseMultiChronos(_mchron)
+ sched, err := schedule.ParseMultiSchedule(_msched)
if err != nil {
return nil, err
}
@@ -43,7 +43,7 @@ func jobFromSQL(con *MySQLDBCon, s scanner) (*Job, error) {
subject: subject,
content: content,
next: time.Unix(_next, 0),
- chron: chron,
+ sched: sched,
}, nil
}
@@ -90,7 +90,7 @@ func (u *User) JobByID(_id model.DBID) (model.Job, error) {
}
}
-func (u *User) AddJob(subject string, content []byte, chron chronos.MultiChronos, next time.Time) (model.Job, error) {
+func (u *User) AddJob(subject string, content []byte, sched schedule.MultiSchedule, next time.Time) (model.Job, error) {
tx, err := u.con.con.Begin()
if err != nil {
return nil, err
@@ -98,7 +98,7 @@ func (u *User) AddJob(subject string, content []byte, chron chronos.MultiChronos
insjob := tx.Stmt(u.con.stmt[qInsertJob])
- res, err := insjob.Exec(uint64(u.id), subject, content, next.Unix(), chron.String())
+ res, err := insjob.Exec(uint64(u.id), subject, content, next.Unix(), sched.String())
if err != nil {
tx.Rollback()
return nil, err
@@ -121,15 +121,15 @@ func (u *User) AddJob(subject string, content []byte, chron chronos.MultiChronos
subject: subject,
content: content,
next: next,
- chron: chron,
+ sched: sched,
}, nil
}
-func (j *Job) ID() model.DBID { return j.id }
-func (j *Job) Subject() string { return j.subject }
-func (j *Job) Content() []byte { return j.content }
-func (j *Job) Chronos() chronos.MultiChronos { return j.chron }
-func (j *Job) Next() time.Time { return j.next }
+func (j *Job) ID() model.DBID { return j.id }
+func (j *Job) Subject() string { return j.subject }
+func (j *Job) Content() []byte { return j.content }
+func (j *Job) Schedule() schedule.MultiSchedule { return j.sched }
+func (j *Job) Next() time.Time { return j.next }
func (j *Job) User() model.User {
u, err := j.con.UserByID(j.user)
@@ -160,12 +160,12 @@ func (j *Job) SetContent(cont []byte) error {
return nil
}
-func (j *Job) SetChronos(chron chronos.MultiChronos) error {
- if _, err := j.con.stmt[qSetChronos].Exec(chron.String(), uint64(j.id)); err != nil {
+func (j *Job) SetSchedule(sched schedule.MultiSchedule) error {
+ if _, err := j.con.stmt[qSetSchedule].Exec(sched.String(), uint64(j.id)); err != nil {
return err
}
- j.chron = chron
+ j.sched = sched
return nil
}
diff --git a/model/mysql/queries.go b/model/mysql/queries.go
index e579df7..1aa6853 100644
--- a/model/mysql/queries.go
+++ b/model/mysql/queries.go
@@ -19,14 +19,14 @@ const (
qJobsBefore
qInsertJob
qInsertUser
- qSetChronos
+ qSetSchedule
qSetLocation
qEnd
)
const (
qfragSelUser = "SELECT `id`, `email`, `passwd`, `location`, `active`, `activationcode`, `added` FROM `users` "
- qfragSelJob = "SELECT `id`, `user`, `subject`, `content`, `next`, `chronos` FROM `jobs` "
+ qfragSelJob = "SELECT `id`, `user`, `subject`, `content`, `next`, `schedule` FROM `jobs` "
)
var queries = map[int]string{
@@ -46,8 +46,8 @@ var queries = map[int]string{
qSetNext: "UPDATE `jobs` SET `next` = ? WHERE `id` = ?",
qDelJob: "DELETE FROM `jobs` WHERE `id` = ?",
qJobsBefore: qfragSelJob + "WHERE `next` <= ?",
- qInsertJob: "INSERT INTO `jobs` (`user`, `subject`, `content`, `next`, `chronos`) VALUES (?, ?, ?, ?, ?)",
+ qInsertJob: "INSERT INTO `jobs` (`user`, `subject`, `content`, `next`, `schedule`) VALUES (?, ?, ?, ?, ?)",
qInsertUser: "INSERT INTO `users` (`email`, `passwd`, `location`, `active`, `activationcode`, `added`) VALUES (?, ?, ?, ?, ?, ?)",
- qSetChronos: "UPDATE `jobs` SET `chronos` = ? WHERE `id` = ?",
+ qSetSchedule: "UPDATE `jobs` SET `schedule` = ? WHERE `id` = ?",
qSetLocation: "UPDATE `users` SET `location` = ? WHERE `id` = ?",
}