Documentation ¶
Overview ¶
Package database implements a database access layer for the school-dashboard application.
It wraps an SQL database connection, prepares statements to query the database and then provides methods to return the results of any queries.
Index ¶
- type Config
- type Database
- func (db Database) Classes(subjID, dateID string) ([]string, error)
- func (db Database) Close() error
- func (db Database) CurrentWeek() (string, error)
- func (db Database) GroupByClass(subjID, class string, f Filter) (group.Group, error)
- func (db Database) GroupByFilter(f Filter) (group.Group, error)
- func (db Database) GroupByFilteredClass(subjID, class string, f Filter) (group.Group, error)
- func (db Database) HistoricalResults(upn string, subjID int) (map[string]string, error)
- func (db Database) LookupDate(id string) (string, error)
- func (db Database) LookupNatYear(id string) (string, error)
- func (db Database) LookupResultset(id string) (string, error)
- func (db Database) News() ([]NewsItem, error)
- func (db *Database) Refresh() error
- func (db Database) Search(name string, f Filter) (group.Group, error)
- func (db Database) Student(upn string, f Filter) (student.Student, error)
- type Filter
- type Lookup
- type NewsItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Name of the school School string // URN/LEA numbers (as found on performance tables) URN string LEA string // Default filter options Options map[string]string }
A Config holds the details of the schools
func (Config) DefaultFilter ¶
DefaultFilter produces a Filter object with the default values specified in the database.
type Database ¶
type Database struct { // Config Options Config Config // Cached items Levels map[int]subject.Level Subjects map[int]*subject.Subject // National data Attainment8 map[string](map[string]student.Attainment8) // Cached items for menu lookups Dates []Lookup Resultsets []Lookup NatYears []Lookup Ethnicities []string // OtherEths tells us whether an ethnic group should be // collapsed into the 'Other' category OtherEths map[string]bool // contains filtered or unexported fields }
A Database provides a wrapper to the school database.
func (Database) Classes ¶
Classes returns a list of classes that exists for a subject, at a particular date.
func (Database) CurrentWeek ¶
CurrentWeek looks up the name of the latest week, as used for attendance.
func (Database) GroupByClass ¶
GroupByClass returns a group of students who are present in the subject/class specified at the particular date.
func (Database) GroupByFilter ¶
GroupByFilter returns a group of students who satisfy the criteria specified in the filter.
func (Database) GroupByFilteredClass ¶
GroupByFilteredClass returns a group of students who meet the filter criteria and are in the subject/class combination specified. If class="", then all students in that subject are returned.
func (Database) HistoricalResults ¶
HistoricalResults returns a map of student results for a particular subject, keyed by resultset name
func (Database) LookupDate ¶
LookupDate lookups the id number of the date, and returns its name
func (Database) LookupNatYear ¶
LookupNatYear looks up the id number of the National Dataset and returns its name
func (Database) LookupResultset ¶
LookupResultset looks up the id number of the resultset and returns its name
type Filter ¶
type Filter struct { // Effective date to use for membership of the group. // Holds the id number, but held as string for easier // parsing from query strings. Date string // Which set of assessment results to use. // Holds id number as above. Resultset string // Which year to use for national data comparisons. NatYear string // Which yeargroup to include in the group Year string // Pupil premium: "", "1", or "0" for Any/True/False PP string // EAL students: "", "1", or "0" for Any/True/False EAL string // Gender: "", "1", "0" for Any/Male/Female Gender string // SEN types to include - Empty for any SEN []string // Which Ethnic groups to include, empty for any Ethnicities []string // Which KS2 bands to include, empty for any KS2Bands []string }
A Filter holds all the fields available to select a group of students on.