Documentation
¶
Index ¶
- Constants
- func CheckUserPassword(db *gorm.DB, email string, password string) (uint, bool, error)
- func DeleteSession(db *gorm.DB, UUID string) error
- func DeleteUser(db *gorm.DB, user *User) error
- func HkDirName(folder string) string
- func InitDb(db *gorm.DB, config *Configuration) error
- func RawDirName(folder string) string
- func RefreshDbContents(db *gorm.DB, repositoryPath string) error
- func SumDirName(folder string) string
- func TimeToCanonicalStr(t time.Time) string
- func UpdateUserPassword(db *gorm.DB, user *User, newPassword string) error
- type Acquisition
- type App
- type Configuration
- type Error
- type HomeData
- type RawDataFile
- type Session
- type SumDataFile
- type User
Constants ¶
const QuteDBVersion = "0.5.3"
QuteDBVersion is a string containing the version number of QuteDB
Variables ¶
This section is empty.
Functions ¶
func CheckUserPassword ¶
CheckUserPassword checks that an user with the specified email and password is in the database. If found, return the tuple (userID, true, nil). If the user does not exist, or if the passwords don't match, return (0, false, nil). In the event of an error, the last element in the returned tuple identifies the error.
func DeleteSession ¶
DeleteSession finds a session with a matching UUID in the database and deletes it. If no session is found, returns silently without signaling any error.
func DeleteUser ¶
DeleteUser removes an user from the database
func InitDb ¶
func InitDb(db *gorm.DB, config *Configuration) error
InitDb creates all the tables in the database. It takes care of not raising errors if the tables are already present. You should call this function only once during the lifetime of the program, as it resets all open sessions.
func RawDirName ¶
RawDirName returns the name of the test directory containing raw files
func RefreshDbContents ¶
RefreshDbContents scans the repository for any file that is missing from the database, and create an entry for each of them.
func SumDirName ¶
SumDirName returns the name of the test directory containing raw files
func TimeToCanonicalStr ¶
TimeToCanonicalStr converts a standard date/time into a string which is formatted according to the template "YYYYMMSShhmmss". This is the format used in Acquisition.AcquisitionTime
Types ¶
type Acquisition ¶
type Acquisition struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"created_at"` Name string `json:"name"` Directoryname string `json:"directory_name" gorm:"unique_index"` // We encode the acquisition time as a string in order to have // full control on the formatting, which is always "YYYY-MM-DDThh:mm:ss" AcquisitionTime string `json:"acquisition_time"` RawFiles []RawDataFile `json:"-"` SumFiles []SumDataFile `json:"-"` AsicHkFileName string `json:"-"` InternHkFileName string `json:"-"` ExternHkFileName string `json:"-"` MmrHkFileName string `json:"-"` MgcHkFileName string `json:"-"` CalConfFileName string `json:"-"` CalDataFileName string `json:"-"` }
An Acquisition represents a set of files within a folder in the repository
func QueryAcquisition ¶ added in v0.2.1
func QueryAcquisition(db *gorm.DB, acqtime string) (*Acquisition, error)
QueryAcquisition returns an Aquisition object with all its fields properly filled
type App ¶
type App struct {
// contains filtered or unexported fields
}
An App is a structure which encapsulate the whole state of the application
func NewApp ¶
func NewApp() *App
NewApp creates a new application and performs a number of initializations.
func (*App) CreateDefaultUser ¶
CreateDefaultUser creates a superuser with a standard password, if no user exists.
type Configuration ¶
type Configuration struct { // Full path of the file containing the configuration ConfigurationFileName string `json:"-"` DatabaseFile string `json:"database_file"` LogFormat string `json:"log_format"` LogLevel string `json:"log_level"` LogOutput string `json:"log_output"` PortNumber int `json:"port_number"` ServerName string `json:"server_name"` ReadTimeout int64 `json:"read_timeout"` WriteTimeout int64 `json:"write_timeout"` StaticPath string `json:"static_path"` RepositoryPath string `json:"repository_path"` CookieHashKey []byte `json:"cookie_hash_key"` CookieBlockKey []byte `json:"cookie_block_key"` }
A Configuration type contains all the settings loaded from environment variables and configuration files. It is initialized using the Viper library.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error contains information about an HTTP error
type HomeData ¶
type HomeData struct { User User AcquisitionList []Acquisition }
HomeData contains the data passed to the "index.html" template
type RawDataFile ¶
type RawDataFile struct { ID int `json:"id" gorm:"primary_key"` FileName string `json:"file_name"` AsicNumber int `json:"asic_number"` AcquisitionID int `json:"-"` }
A RawDataFile represents the file containing raw data acquired with one ASIC
type Session ¶
A Session records who is currently allowed to access the site. This only happens if a user has successfully logged in.
func CreateSession ¶
CreateSession inserts a new "Session" object in the database. The object is uniquely identified by its UUID.
type SumDataFile ¶
type SumDataFile struct { ID int `json:"id" gorm:"primary_key"` FileName string `json:"file_name"` AsicNumber int `json:"asic_number"` AcquisitionID int `json:"-"` }
A SumDataFile represents the file containing science data acquired with one ASIC
type User ¶
type User struct { gorm.Model Email string `gorm:"unique_index"` HashedPassword []byte Superuser bool }
An User is somebody which can have (read-only) access to the data
func CreateUser ¶
CreateUser creates a new "User" object and initializes it with the hash of the password and the other parameters as well. The new object is saved in the database.
func QueryAllUsers ¶
QueryAllUsers returns a list of all the users defined in the database
func QueryUserByEmail ¶
QueryUserByEmail searches in the database for an user with the matching email and returns a poitner to a User structure. If the user is not found, the pointer is nil. The "error" variable is set to something else than nil only if a real error is occurred.
func QueryUserByID ¶
QueryUserByID searches in the database for an user with the matching user ID and returns a pointer to a User structure. If the user is not found, the pointer is nil. The "error" variable is set to something else than nil only if a real error is occurred.