2018-project-roaster: github.com/LuleaUniversityOfTechnology/2018-project-roaster/model Index | Files | Directories

package model

import "github.com/LuleaUniversityOfTechnology/2018-project-roaster/model"

Package model avatar implementation.

Package model feed implementation.

Package model starting point opens and initializes the PostgreSQL database.

Package model roast implementation.

Package model search implementation.

Package model feed implementation.

Package model user implementation.


Package Files

avatar.go feed.go model.go roast.go search.go statistics.go user.go

func Open Uses

func Open(source string) error

Open initializes a database connection and forward engineers a schema and tables generated by inlinesql and parsed by the forwardengineer package. go:generate go run github.com/LuleaUniversityOfTechnology/2018-project-roaster/cmd/inlinesql -in forwardengineer/schema.sql -pkg forwardengineer -out forwardengineer/schema.go

func PutAvatar Uses

func PutAvatar(avatar Avatar) (err error)

PutAvatar adds a avatar to a user in the database.

func PutFollowee Uses

func PutFollowee(username string, followee string) (err error)

PutFollowee saves a followee relation to the DB, returns error if unsuccessful.

func PutRoast Uses

func PutRoast(roast *RoastResult) (err error)

PutRoast adds a RoastResult to the database.

func PutUser Uses

func PutUser(user User, password []byte) (err error)

PutUser adds a user to the database. The password parameter is a plain-text password that will be hashed before insertion. Note that the password parameter value will be replaced with a empty slice.

Note: The username and e-mail for the user will be trimmed from whitespace.

func RemoveFollowee Uses

func RemoveFollowee(username string, followee string) (err error)

RemoveFollowee deletes a followee relation from DB, returns error if unsuccessful.

func UpdateUser Uses

func UpdateUser(user User) (err error)

UpdateUser updates fullname, password or email of a user, otherwise error.

type Avatar Uses

type Avatar struct {
    Username string
    Avatar   []byte

Avatar holds a avatar.

func GetAvatar Uses

func GetAvatar(username string) (avatar Avatar, err error)

GetAvatar return a avatar by their username. Note: Username will be trimmed for whitespace before quering the database.

func NewAvatar Uses

func NewAvatar(raw []byte, username string) (a Avatar, err error)

NewAvatar creates, converts and resizes the avatar, returns Avatar struct.

type Feed Uses

type Feed struct {
    Items []FeedItem `json:"items"`

Feed holds a list of FeedItems.

func GetFeed Uses

func GetFeed(username string, followees bool, page uint64, pageSize uint64) (feed Feed, err error)

GetFeed collects the latest N (N = pageSize) feed items for either everyone, followees or for a user.

* An empty username string returns the feed items for all users. * A set username together with the followees parameter set to true returns the

users followees feed items.

* A set username together with the followees parameter set to false returns

only the users feed items.

Pagination is supported where page = 0 is the first (latest) page.

type FeedItem Uses

type FeedItem struct {
    Category    int       `json:"category"`
    Username    string    `json:"username"`
    Title       string    `json:"title"`
    Description string    `json:"description"`
    CreateTime  time.Time `json:"createTime"`

FeedItem represents a item in a feed.

type Followee Uses

type Followee Follower

Followee represents a user that is being tracked by someone.

func GetFollowees Uses

func GetFollowees(username string) (followees []Followee, err error)

GetFollowees returns a list of followees if successful, otherwise error.

type Follower Uses

type Follower struct {
    Username   string    `json:"username"`
    CreateTime time.Time `json:"createTime"`

Follower represents a user that is tracking someone.

func GetFollowers Uses

func GetFollowers(username string) (followers []Follower, err error)

GetFollowers gets a list of followers for a specific user, returns error if unsuccsessful.

type LinesOfCode Uses

type LinesOfCode struct {
    Lines uint64 `json:"lines"`

LinesOfCode holds a named uint64 that represents the number of lines.

func GetLinesOfCode Uses

func GetLinesOfCode(username string, followees bool) (lines LinesOfCode, err error)

GetLinesOfCode returns the number of lines of code for everyone, a specific user or that user's followees. An empty string as username represents everyone.

type NumberOfRoasts Uses

type NumberOfRoasts struct {
    Count uint64 `json:"count"`

NumberOfRoasts holds a named uint64 that represents the number of Roasts.

func GetNumberOfRoasts Uses

func GetNumberOfRoasts(username string, followees bool) (numberOfRoasts NumberOfRoasts, err error)

GetNumberOfRoasts returns the number of Roasts for everyone, a specific user, or that user's followees. An empty string as username represents everyone.

type RoastDatapoint Uses

type RoastDatapoint struct {
    Timestamp        time.Time `json:"timestamp"`
    Count            uint64    `json:"count"`
    NumberOfErrors   uint64    `json:"numberOfErrors"`
    NumberOfWarnings uint64    `json:"numberOfWarnings"`
    LinesOfCode      uint64    `json:"linesOfCode"`

RoastDatapoint represents a single datapoint with a timestamp.

type RoastError Uses

type RoastError struct {

RoastError represents a Roast error message.

type RoastMessage Uses

type RoastMessage struct {
    Hash        uuid.UUID `json:"hash"`
    Row         uint      `json:"row"`
    Column      uint      `json:"column"`
    Engine      string    `json:"engine"`
    Name        string    `json:"name"`
    Description string    `json:"description"`

RoastMessage represents a general Roast message.

type RoastRatio Uses

type RoastRatio struct {
    LinesOfCode      uint64 `json:"linesOfCode"`
    NumberOfErrors   uint64 `json:"numberOfErrors"`
    NumberOfWarnings uint64 `json:"numberOfWarnings"`

RoastRatio represents a ratio between lines of code versus errors and warnings.

func GetRoastRatio Uses

func GetRoastRatio(username string) (roastRatio RoastRatio, err error)

GetRoastRatio returns the lines of code, number of errors and warnings for a specific user.

type RoastResult Uses

type RoastResult struct {
    Username   string          `json:"username"`
    Code       string          `json:"code"`
    Score      uint            `json:"score"`
    Language   string          `json:"language"`
    Errors     []RoastError    `json:"errors"`
    Warnings   []RoastWarning  `json:"warnings"`
    CreateTime time.Time       `json:"createTime"`
    Statistics RoastStatistics `json:"statistics"`

RoastResult represent a Roast result.

func GetRoast Uses

func GetRoast(id int) (roast *RoastResult, err error)

GetRoast returns the RoastResult for the specific ID.

func NewRoastResult Uses

func NewRoastResult(username, language, code string) (result *RoastResult)

NewRoastResult creates a new RoastResult with username, language and code but without warning/error messages.

func (*RoastResult) AddError Uses

func (r *RoastResult) AddError(hash uuid.UUID, row, column uint, engine, name, description string)

AddError adds an error to the RoastResult.

func (*RoastResult) AddWarning Uses

func (r *RoastResult) AddWarning(hash uuid.UUID, row, column uint, engine, name, description string)

AddWarning adds an warning to the RoastResult.

type RoastStatistics Uses

type RoastStatistics struct {
    LinesOfCode      uint64 `json:"linesOfCode"`
    NumberOfErrors   uint64 `json:"numberOfErrors"`
    NumberOfWarnings uint64 `json:"numberOfWarnings"`

RoastStatistics holds statistics for a Roast.

type RoastTimeseries Uses

type RoastTimeseries []RoastDatapoint

RoastTimeseries holds a slice of RoastDatapoints.

func GetRoastTimeseries Uses

func GetRoastTimeseries(start, end time.Time, interval time.Duration, username string, followees bool) (
    timeseries RoastTimeseries, err error)

GetRoastTimeseries returns a timeseries of number of Roasts per time unit. Username is optional, an empty string represent every user.

The minimum interval is 1 minute, anything less will be set to 1 minute per default.

type RoastWarning Uses

type RoastWarning struct {

RoastWarning represents a Roast error message.

type SearchResult Uses

type SearchResult struct {
    Category    int    `json:"category"`
    Title       string `json:"title"`
    Description string `json:"description"`
    URL         string `json:"url"`

SearchResult holds a search result.

func SearchAll Uses

func SearchAll(query string) (results []SearchResult, err error)

SearchAll returns a list of SearchResults.

func SearchUsers Uses

func SearchUsers(query string) (results []SearchResult, err error)

SearchUsers searchs for all users matching the provided query.

type User Uses

type User struct {
    Username string `json:"username"`
    Email    string `json:"email"`
    Fullname string `json:"fullname"`

User holds a user.

func AuthenticateUser Uses

func AuthenticateUser(identifier string, password []byte) (user User, ok bool)

AuthenticateUser authenticates the user with their username/e-mail and password.

The identifier parameter can be the users username or e-mail address.

If the authentication fails an empty user with the ok boolean set to false is returned. Else the user struct is filled and the ok boolean is set to true.

Note: That the password parameter will be emptied.

func GetUser Uses

func GetUser(identifier string) (user User, err error)

GetUser returns a user by their username or e-mail.

Note: The username and e-mail for the user will be trimmed from whitespace before searching in the database.

type UserScore Uses

type UserScore struct {
    Score uint64 `json:"score"`

UserScore holds a named uint64 that represents the users score.

func GetUserScore Uses

func GetUserScore(username string) (score UserScore, err error)

GetUserScore returns the score for an user.


forwardengineerPackage forwardengineer was generated automatically by inlinesql at 2019-01-08 15:12:55.830329896 +0100 CET m=+0.001842869.

Package model imports 21 packages (graph) and is imported by 5 packages. Updated 2019-01-14. Refresh now. Tools for package owners.