queries

package
v0.0.0-...-6003355 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeletePlaylists

func DeletePlaylists(ctx context.Context, eggsID string, playlistIDs []string) (n int64, err error)

func GenerateRandomString

func GenerateRandomString(s int) (string, error)

func GetArray

func GetArray(query url.Values, key string) []string

func GetAuthenticatedUserCount

func GetAuthenticatedUserCount(ctx context.Context) (n int64, err error)

func GetCachedUserCount

func GetCachedUserCount(ctx context.Context) (n int64, err error)

func GetEggsIDByToken

func GetEggsIDByToken(ctx context.Context, token string) (eggsID string, err error)

func GetFollowCount

func GetFollowCount(ctx context.Context) (n int64, err error)

func GetIntArray

func GetIntArray(query url.Values, key string) []int

func GetLikeCount

func GetLikeCount(ctx context.Context, target string) (n int64, err error)

func GetPlaylistCount

func GetPlaylistCount(ctx context.Context) (n int64, err error)

func GetSongCount

func GetSongCount(ctx context.Context) (n int64, err error)

func GetUserCredentials

func GetUserCredentials(ctx context.Context, user User) (eggsID string, token string, err error)

func InsertUser

func InsertUser(ctx context.Context, user User, token string) (err error)

func LikeObjects

func LikeObjects(ctx context.Context, eggsID string, targets LikeTargetsFixed) (n int64, err error)

func PostPlaylists

func PostPlaylists(ctx context.Context, eggsID string, playlistInputs []PlaylistInput) (inserted int64, updated int64, err error)

func PostSongs

func PostSongs(ctx context.Context, songData []SongData) (n int64, err error)

func PostUserStubs

func PostUserStubs(ctx context.Context, users []UserStub) (inserted int64, updated int64, err error)

func PutFollows

func PutFollows(ctx context.Context, followerID string, followeeIDs []string) (delta int64, total int64, err error)

func PutLikes

func PutLikes(ctx context.Context, eggsID string, targets LikeTargetsFixed) (delta int64, total int64, err error)

func PutPlaylists

func PutPlaylists(ctx context.Context, eggsID string, playlistInputs PlaylistInputs) (delta int64, total int64, err error)

func RollbackTransaction

func RollbackTransaction(tx pgx.Tx)

func SongExists

func SongExists(ctx context.Context, musicID string) (exists bool, err error)

func SubmitFollows

func SubmitFollows(ctx context.Context, followerID string, followeeIDs []string) (n int64, err error)

func ToggleFollow

func ToggleFollow(ctx context.Context, followerID string, followeeID string) (isFollowing bool, err error)

func ToggleLike

func ToggleLike(ctx context.Context, eggsID string, target LikeTarget) (isFollowing bool, err error)

func UNSAFEDeleteUser

func UNSAFEDeleteUser(ctx context.Context, eggsID string) (err error)

func UpdateUserDetails

func UpdateUserDetails(ctx context.Context, user User) (err error)

func UpdateUserToken

func UpdateUserToken(ctx context.Context, user User, token string) (err error)

Types

type ArtistData

type ArtistData struct {
	ArtistID       int    `json:"artistId"`
	ArtistName     string `json:"artistName"`
	DisplayName    string `json:"displayName"`
	PrefectureCode int    `json:"prefectureCode"`
	ImageDataPath  string `json:"imageDataPath"`
	Profile        string `json:"profile"`
}

type Follow

type Follow struct {
	FollowerID string    `json:"followerID" db:"follower_id"`
	FolloweeID string    `json:"followeeID" db:"followee_id"`
	Timestamp  time.Time `json:"timestamp" db:"added_time"`
}

type Follows

type Follows []Follow

func (Follows) Contains

func (arr Follows) Contains(b PartialFollow) bool

type Like

type Like struct {
	TargetID  string    `json:"targetID" db:"target_id"`
	EggsID    string    `json:"eggsID" db:"eggs_id"`
	Timestamp time.Time `json:"timestamp" db:"added_time"`
}

type LikeTarget

type LikeTarget struct {
	ID   string `json:"id" db:"target_id"`
	Type string `json:"type" db:"target_type"`
}

func (LikeTarget) IsValid

func (a LikeTarget) IsValid() bool

type LikeTargets

type LikeTargets []LikeTarget

func (LikeTargets) IDs

func (arr LikeTargets) IDs() []string

func (LikeTargets) IsValid

func (arr LikeTargets) IsValid() bool

type LikeTargetsFixed

type LikeTargetsFixed struct {
	Targets []LikeTarget `json:"targets"`
	Type    string       `json:"type"`
}

func (LikeTargetsFixed) IDs

func (arr LikeTargetsFixed) IDs() []string

func (LikeTargetsFixed) IsValid

func (arr LikeTargetsFixed) IsValid() bool

type Likes

type Likes []Like

type Paginator

type Paginator struct {
	Limit  int `json:"limit"`
	Offset int `json:"offset"`
}

func InitializePaginator

func InitializePaginator(query url.Values) Paginator

type PartialFollow

type PartialFollow struct {
	FollowerID string `json:"followerID" db:"follower_id"`
	FolloweeID string `json:"followeeID" db:"followee_id"`
}

type PartialLike

type PartialLike struct {
	TargetID string `json:"targetID" db:"target_id"`
	EggsID   string `json:"eggsID" db:"eggs_id"`
}

type PartialPlaylist

type PartialPlaylist struct {
	PlaylistID string `json:"playlistID" db:"playlist_id"`
	EggsID     string `json:"eggsID" db:"eggs_id"`
}

type PlaylistInput

type PlaylistInput struct {
	PlaylistID   string    `json:"playlistID"`
	LastModified time.Time `json:"lastModified"`
}

type PlaylistInputs

type PlaylistInputs []PlaylistInput

func (PlaylistInputs) PartialPlaylists

func (arr PlaylistInputs) PartialPlaylists(eggsID string) (o []PartialPlaylist)

func (PlaylistInputs) PlaylistIDs

func (arr PlaylistInputs) PlaylistIDs() (o []string)

type SearchSongResp

type SearchSongResp struct {
	Data       []SongData `json:"data"`
	TotalCount int        `json:"totalCount"`
}

type SongData

type SongData struct {
	MusicID     string     `json:"musicId"`
	ReleaseDate time.Time  `json:"releaseDate"`
	ArtistData  ArtistData `json:"artistData"`
}

type StructuredFollow

type StructuredFollow struct {
	Follower  UserStub  `json:"follower"`
	Followee  UserStub  `json:"followee"`
	Timestamp time.Time `json:"timestamp"`
}

type StructuredFollows

type StructuredFollows struct {
	Follows []StructuredFollow `json:"follows"`
	Total   int64              `json:"total"`
}

func GetFollows

func GetFollows(ctx context.Context, followerIDs []string, followeeIDs []string, paginator Paginator) (follows StructuredFollows, err error)

func (StructuredFollows) ContainsFollowee

func (arr StructuredFollows) ContainsFollowee(b UserStub) bool

func (StructuredFollows) ContainsFolloweeID

func (arr StructuredFollows) ContainsFolloweeID(b string) bool

func (StructuredFollows) ContainsFollower

func (arr StructuredFollows) ContainsFollower(b UserStub) bool

func (StructuredFollows) ContainsFollowerID

func (arr StructuredFollows) ContainsFollowerID(b string) bool

type StructuredLike

type StructuredLike struct {
	ID        string    `json:"id"`
	Type      string    `json:"type"`
	User      UserStub  `json:"user"`
	Timestamp time.Time `json:"timestamp"`
}

type StructuredLikes

type StructuredLikes struct {
	Likes []StructuredLike `json:"likes"`
	Total int64            `json:"total"`
}

func GetLikedObjects

func GetLikedObjects(ctx context.Context, eggsIDs []string, targetIDs []string, targetType string, paginator Paginator) (likes StructuredLikes, err error)

func (StructuredLikes) Contains

func (arr StructuredLikes) Contains(b PartialLike) bool

type StructuredPlaylist

type StructuredPlaylist struct {
	PlaylistID string    `json:"playlistID"`
	User       UserStub  `json:"user"`
	Timestamp  time.Time `json:"timestamp"`
}

type StructuredPlaylists

type StructuredPlaylists struct {
	Playlists []StructuredPlaylist `json:"playlists"`
	Total     int64                `json:"total"`
}

func GetPlaylists

func GetPlaylists(ctx context.Context, eggsIDs []string, playlistIDs []string, paginator Paginator) (playlists StructuredPlaylists, err error)

func (StructuredPlaylists) Contains

func (arr StructuredPlaylists) Contains(b PartialPlaylist) bool

type TimelineItem

type TimelineItem struct {
	ID        string    `json:"id" db:"id"`
	Type      string    `json:"type" db:"type"`
	Target    string    `json:"target" db:"target"`
	Timestamp time.Time `json:"timestamp" db:"timestamp"`
}

func GetTimeline

func GetTimeline(ctx context.Context, eggsID string, offset int, limit int) (timeline []TimelineItem, err error)

type User

type User struct {
	UserID         int    `json:"userId" db:"user_id"`
	EggsID         string `json:"userName" db:"eggs_id"`
	DisplayName    string `json:"displayName" db:"display_name"`
	IsArtist       bool   `json:"isArtist" db:"is_artist"`
	ImageDataPath  string `json:"imageDataPath" db:"image_data_path"`
	PrefectureCode int    `json:"prefectureCode" db:"prefecture_code"`
	ProfileText    string `json:"profile" db:"profile_text"`
}

func (User) IsValid

func (u User) IsValid() bool

type UserRaw

type UserRaw struct {
	Data struct {
		UserName       string `json:"userName"`
		ArtistName     string `json:"artistName"`
		DisplayName    string `json:"displayName"`
		ArtistID       int    `json:"artistId"`
		UserID         int    `json:"userId"`
		ImageDataPath  string `json:"imageDataPath"`
		PrefectureCode int    `json:"prefectureCode"`
		ProfileText    string `json:"profile"`
	} `json:"data"`
}

func (UserRaw) User

func (u UserRaw) User() User

type UserStub

type UserStub struct {
	UserID         int    `json:"userId" db:"user_id"`
	EggsID         string `json:"userName" db:"eggs_id"`
	DisplayName    string `json:"displayName" db:"display_name"`
	IsArtist       bool   `json:"isArtist" db:"is_artist"`
	ImageDataPath  string `json:"imageDataPath" db:"image_data_path"`
	PrefectureCode int    `json:"prefectureCode" db:"prefecture_code"`
	ProfileText    string `json:"profile" db:"profile_text"`
}

func GetUserStubFromToken

func GetUserStubFromToken(ctx context.Context, token string) (output []UserStub, err error)

func GetUsers

func GetUsers(ctx context.Context, eggsids []string, userids []int) (output []UserStub, err error)

func (UserStub) IsValid

func (u UserStub) IsValid() bool

type UserStubs

type UserStubs []UserStub

func (UserStubs) Contains

func (arr UserStubs) Contains(b UserStub) bool

func (UserStubs) ContainsID

func (arr UserStubs) ContainsID(b string) bool

func (UserStubs) IsValid

func (arr UserStubs) IsValid() bool

func (UserStubs) StringSlice

func (arr UserStubs) StringSlice() (output []string)

Jump to

Keyboard shortcuts

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