sqlstore

package
v0.0.0-...-1b8d80d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2022 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store allows to communicate with a database

func NewStore

func NewStore(d *sql.DB, config config.Internships) (*Store, error)

NewStore initiate the storage servive

func (*Store) AddJuryToDefenseSession

func (s *Store) AddJuryToDefenseSession(room, id, jury string) error

func (*Store) Convention

func (s *Store) Convention(student string) (schema.Convention, error)

Convention returns the convention of a given student

func (*Store) Defense

func (s *Store) Defense(student string) (schema.Defense, error)

Defense get the defense of a student

func (*Store) DefenseSession

func (s *Store) DefenseSession(room, id string) (schema.DefenseSession, error)

func (*Store) DefenseSessions

func (s *Store) DefenseSessions() ([]schema.DefenseSession, error)

DefenseSessions get all the defense sessions

func (*Store) DelJuryToDefenseSession

func (s *Store) DelJuryToDefenseSession(room, id, jury string) error

func (*Store) Install

func (s *Store) Install() error

Install the tables on the database

func (*Store) Internship

func (s *Store) Internship(student string) (schema.Internship, error)

Internship returns the internship for a given student

func (*Store) Internships

func (s *Store) Internships() (schema.Internships, error)

Internships returns all the internships. Not necessarily validated

func (*Store) NewDefenseSession

func (s *Store) NewDefenseSession(room string, id string) (schema.DefenseSession, error)

func (*Store) NewInternship

func (s *Store) NewInternship(c schema.Convention) (schema.Internship, []byte, error)

NewInternship turns a convention into an internship. Returns the internship, the student token and an error

func (*Store) NewPassword

func (s *Store) NewPassword(token, newP []byte) (string, error)

NewPassword commits a password renewall request. From a request token and a new password, it returns upon success the target user email

func (*Store) NewSession

func (s *Store) NewSession(email string, password []byte, expire time.Duration) (schema.Session, error)

NewSession creates a new session if the email and the password matches a user

func (*Store) NewStudent

func (s *Store) NewStudent(p schema.Person, major, promotion string, male bool) error

NewStudent create a new student using a given person, major, promotion and gender The major and the promotion must be valid against the supported values in config.Internships The underlying user account is created

func (*Store) NewUser

func (s *Store) NewUser(p schema.Person, role schema.Role) ([]byte, error)

NewUser add a user Basically, calls addUser

func (*Store) ReplaceUserWith

func (s *Store) ReplaceUserWith(src, dst string) error

ReplaceUserWith the account referred by src by the account referred by dst

func (*Store) Report

func (s *Store) Report(k, email string) (schema.ReportHeader, error)

Report returns the given report

func (*Store) ReportContent

func (s *Store) ReportContent(kind, email string) ([]byte, error)

ReportContent returns the content of a given report

func (*Store) Reports

func (s *Store) Reports(email string) ([]schema.ReportHeader, error)

Reports returns all the reports for a given student

func (*Store) ResetPassword

func (s *Store) ResetPassword(email string) ([]byte, error)

ResetPassword starts a reset procedure

func (*Store) ResetSurveyContent

func (s *Store) ResetSurveyContent(student, kind string) error

ResetSurveyContent delete an uploaded survey

func (*Store) RmDefenseSession

func (s *Store) RmDefenseSession(room, id string) error

func (*Store) RmSession

func (s *Store) RmSession(email string) error

RmSession destroy the current user session if exists

func (*Store) RmStudentDefense

func (s *Store) RmStudentDefense(student string) error

func (*Store) RmUser

func (s *Store) RmUser(email string) error

RmUser removes a user from the database

func (*Store) Session

func (s *Store) Session(token []byte) (schema.Session, error)

Session get the token related session

func (*Store) SetAlumni

func (s *Store) SetAlumni(student string, a schema.Alumni) error

SetAlumni update a student alumni status

func (*Store) SetCompany

func (s *Store) SetCompany(stu string, c schema.Company) error

SetCompany updates the student company

func (*Store) SetDefenseGrade

func (s *Store) SetDefenseGrade(student string, g int) error

SetDefenseGrade set the defense grade

func (*Store) SetEmail

func (s *Store) SetEmail(old, now string) error

SetEmail change a user email to another

func (*Store) SetMajor

func (s *Store) SetMajor(stu, m string) error

SetMajor updates the student major

func (*Store) SetMale

func (s *Store) SetMale(stu string, m bool) error

SetMale stores the student gender

func (*Store) SetPromotion

func (s *Store) SetPromotion(stu, p string) error

SetPromotion updates the student promotion

func (*Store) SetReportContent

func (s *Store) SetReportContent(kind, email string, cnt []byte) (time.Time, error)

SetReportContent saves the content of a given report if the report has not been already graded If the deadline passed, it is however possible to store the report once.

func (*Store) SetReportDeadline

func (s *Store) SetReportDeadline(kind, email string, t time.Time) error

SetReportDeadline change a report deadline

func (*Store) SetReportGrade

func (s *Store) SetReportGrade(kind, email string, g int, comment string) (time.Time, error)

SetReportGrade stores the given report grade

func (*Store) SetReportPrivacy

func (s *Store) SetReportPrivacy(kind, email string, p bool) error

SetReportPrivacy changes the privacy level of a report

func (*Store) SetStudentDefense

func (s *Store) SetStudentDefense(session, room, student string, t time.Time, public, local bool) error

func (*Store) SetStudentSkippable

func (s *Store) SetStudentSkippable(em string, st bool) error

SetStudentSkippable indicates if it is not required for the student to get an internship (an abandom typically)

func (*Store) SetSupervisor

func (s *Store) SetSupervisor(stu string, t schema.Person) error

SetSupervisor updates the student supervisor

func (*Store) SetSurveyContent

func (s *Store) SetSurveyContent(token string, cnt interface{}) (time.Time, error)

SetSurveyContent stores the survey answers

func (*Store) SetSurveyInvitation

func (s *Store) SetSurveyInvitation(student, kind string) (time.Time, error)

SetSurveyInvitation stores the invitation date for a survey to fullfil

func (*Store) SetTutor

func (s *Store) SetTutor(stu string, t string) error

SetTutor updates the student tutor

func (*Store) SetUserPerson

func (s *Store) SetUserPerson(p schema.Person) error

SetUserPerson changes the user profile if exists

func (*Store) SetUserRole

func (s *Store) SetUserRole(email string, priv schema.Role) error

SetUserRole updates the user privilege

func (*Store) Student

func (s *Store) Student(email string) (schema.Student, error)

Student returns a given student

func (*Store) Students

func (s *Store) Students() (schema.Students, error)

Students list all the registered students

func (*Store) Survey

func (s *Store) Survey(student, kind string) (schema.SurveyHeader, error)

Survey returns the required survey

func (*Store) SurveyFromToken

func (s *Store) SurveyFromToken(token string) (string, schema.SurveyHeader, error)

SurveyFromToken returns a given survey identifier

func (*Store) Surveys

func (s *Store) Surveys(student string) ([]schema.SurveyHeader, error)

Surveys returns all the survey related to a student

func (*Store) UpdateStudentDefense

func (s *Store) UpdateStudentDefense(student string, t time.Time, public, local bool) error

func (*Store) User

func (s *Store) User(email string) (schema.User, error)

User returns the given user account

func (*Store) Users

func (s *Store) Users() ([]schema.User, error)

Users list all the registered users

func (*Store) Visit

func (s *Store) Visit(u string) error

Visit writes the current time for the given user

type TxErr

type TxErr struct {
	// contains filtered or unexported fields
}

TxErr is a structure to manage transactions more confortablely. It maintains the ongoing error to state if the transaction must be committed or rollbacked

func (*TxErr) Done

func (r *TxErr) Done() error

Done terminates the transaction. It is committed if err == nil. Rollbacked otherwise.

func (*TxErr) Exec

func (r *TxErr) Exec(query string, args ...interface{})

Exec executes the query and store the resulting error variable

func (*TxErr) QueryRow

func (r *TxErr) QueryRow(query string, args ...interface{}) *rowErr

QueryRow execute the query that must returns one row if the transaction is not in a failed state

func (*TxErr) Update

func (r *TxErr) Update(query string, args ...interface{}) int64

Update executes the update query, store the resulting error variable and returns the number of updated rows

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL