Compare commits

..

No commits in common. "a31d2b446e0d145f07dc0c042b27b77545868d91" and "3a4d69bae0283ee6c3c768fa9b95042191f924b8" have entirely different histories.

1 changed files with 11 additions and 13 deletions

View File

@ -57,7 +57,6 @@ type Bid struct {
URL string
Bid int
Placed int64
Processed int64
}
func (b Bid) PlacedParsed() time.Time {
@ -97,7 +96,6 @@ func (w *Webshit) setup() {
url string,
bid integer,
placed integer
processed integer
)`)
w.db.MustExec(`create table if not exists webshit_balances (
user string primary key,
@ -113,7 +111,7 @@ func (w *Webshit) Check() ([]WeeklyResult, error) {
}
var bids []Bid
if err = w.db.Select(&bids, `select user,title,url,bid from webshit_bids where placed < ? and processed=0`,
if err = w.db.Select(&bids, `select user,title,url,bid from webshit_bids where placed < ?`,
published.Unix()); err != nil {
return nil, err
}
@ -142,8 +140,8 @@ func (w *Webshit) Check() ([]WeeklyResult, error) {
}
// Delete all those bids
if _, err = w.db.Exec(`update webshit_bids set processed=? where placed < ?`,
time.Now().Unix(), published.Unix()); err != nil {
if _, err = w.db.Exec(`delete from webshit_bids where placed < ?`,
published.Unix()); err != nil {
return nil, err
}
@ -281,7 +279,7 @@ func (w *Webshit) GetScore(user string) int {
func (w *Webshit) GetAllBids() ([]Bid, error) {
var bids []Bid
err := w.db.Select(&bids, `select * from webshit_bids where processed=0`)
err := w.db.Select(&bids, `select * from webshit_bids`)
if err != nil {
return nil, err
}
@ -314,7 +312,7 @@ func (w *Webshit) Bid(user string, amount int, URL string) (Bid, error) {
ts := time.Now().Unix()
tx := w.db.MustBegin()
_, err = tx.Exec(`insert into webshit_bids (user,title,url,bid,placed,processed) values (?,?,?,?,?,0)`,
_, err = tx.Exec(`insert into webshit_bids (user,title,url,bid,placed) values (?,?,?,?,?)`,
user, story.Title, story.URL, amount, ts)
if err != nil {
tx.Rollback()