2020-04-05 01:16:37 +00:00
|
|
|
package database
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (m *Manager) TootCountForHostname(hostname string) (uint, error) {
|
|
|
|
var c uint
|
|
|
|
e := m.db.Model(&StoredToot{}).Where("hostname = ?", hostname).Count(&c)
|
|
|
|
if e.Error != nil {
|
|
|
|
return 0, e.Error
|
|
|
|
} else {
|
|
|
|
return c, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-09 10:06:30 +00:00
|
|
|
func (m *Manager) TotalTootCount() (uint, error) {
|
|
|
|
var c uint
|
|
|
|
e := m.db.Model(&StoredToot{}).Count(&c)
|
|
|
|
if e.Error != nil {
|
|
|
|
return 0, e.Error
|
|
|
|
} else {
|
|
|
|
return c, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-05 01:16:37 +00:00
|
|
|
func (m *Manager) GetAPInstanceFromUUID(uuid *uuid.UUID) (*APInstance, error) {
|
|
|
|
var i APInstance
|
|
|
|
e := m.db.Model(&APInstance{}).Where("uuid = ?", uuid).First(&i)
|
|
|
|
if e.Error != nil {
|
|
|
|
return nil, e.Error
|
|
|
|
}
|
|
|
|
return &i, nil
|
|
|
|
}
|