db

package
v0.0.0-...-4aad6dd Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SQLDB *sql.DB

SQLDB database

View Source
var SQLPath string

SQLPath path do db

Functions

func AddCharge

func AddCharge(key string) error

AddCharge adds a charge to the database and errors if charge exists

func AddExpoClient

func AddExpoClient(UUID string, expoID string) error

AddExpoClient - adds a new Expo Client to the list

func AddQuery

func AddQuery(q Query) (int64, error)

AddQuery add a new query to the db

func AnswerDuplicates

func AnswerDuplicates()

AnswerDuplicates looks for duplicate queries

func AnswerQuery

func AnswerQuery(key int64, answer string, list string) error

AnswerQuery move a query to the resolved table with jimmy's answer

func CreateTables

func CreateTables()

CreateTables create the user and posts tables

func FastForward

func FastForward()

FastForward auto answer questions that are old

func Init

func Init()

Init init sql

func MoveToFront

func MoveToFront(key int64) error

MoveToFront moves a query to the front of the queue

func RandomLinks() []string

func RemoveExpoClient

func RemoveExpoClient(UUID string) error

RemoveExpoClient - removes the Expo Client associated with the device UUID

func ResetDB

func ResetDB()

ResetDB remove existing database and recreate tables

Types

type Charge

type Charge struct {
	ID    string `json:"charge"`
	Query int64  `json:"query"`
}

Charge type

type Expo

type Expo struct {
	UUID   string `json:"UUID"`
	ExpoID string `json:"expoID"`
}

func GetExpoClients

func GetExpoClients() ([]Expo, error)

GetExpoClients - gets all of the ExpoIDs to send push notifications to

type Query

type Query struct {
	Key      int64     `json:"key"`
	Text     string    `json:"text"`
	Type     string    `json:"type"`
	Answer   string    `json:"answer"`
	List     []string  `json:"list"`
	ListJ    string    `json:"-"`
	Position int64     `json:"-"`
	Token    string    `json:"token"`
	Priority time.Time `json:"-"`
	Paid     bool      `json:"paid"`
}

Query type

func CheckQuery

func CheckQuery(key int64) (Query, error)

CheckQuery see if a query is resolved and return the answer

func GetQuestion

func GetQuestion(key int64) (Query, error)

GetQuestion get a question by query id

func GetQueue

func GetQueue(num int) ([]Query, error)

GetQueue get the n top queries in the queue

func GetRecent

func GetRecent(num int) ([]Query, error)

GetRecent get the recently resolved posts

func IsDuplicate

func IsDuplicate(text string) (bool, Query)

IsDuplicate check if a text string has been answered

Jump to

Keyboard shortcuts

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