shitfuck
This commit is contained in:
parent
1a97c35e22
commit
704d0e8750
4 changed files with 49 additions and 1 deletions
|
@ -2,6 +2,8 @@ package storage
|
|||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Auto-generate string names for the various constants
|
||||
|
@ -34,3 +36,25 @@ type InboundJob struct {
|
|||
// If from an inbox, include the owner id here
|
||||
InboxOwner *string `gorm:"->;<-create"`
|
||||
}
|
||||
|
||||
func (s *Storage) AddNewInboundJob(data []byte, source InboundJobSource, inboxOwner *string) {
|
||||
newJob := InboundJob{
|
||||
RawData: data,
|
||||
Source: source,
|
||||
InboxOwner: inboxOwner,
|
||||
}
|
||||
s.db.Create(&newJob)
|
||||
}
|
||||
|
||||
// Get the specified amount of jobs, sorted by age (oldest first)
|
||||
func (s *Storage) GetOldestInboundJobs(amount int) ([]InboundJob, error) {
|
||||
jobs := []InboundJob{}
|
||||
switch err := s.db.Order("id asc, created_at asc").Limit(amount).Find(jobs).Error; err {
|
||||
case gorm.ErrRecordNotFound:
|
||||
return nil, ErrEntryNotFound
|
||||
case nil:
|
||||
return jobs, nil
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue