dbstore

package
v0.0.0-...-45c4399 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLastHeartbeat

func GetLastHeartbeat(r models.Resource) time.Time

GetLastHeartbeat get the last heart beat

func ResourceHeartbeat

func ResourceHeartbeat(r models.Resource)

ResourceHeartbeat stores the most recent timestamp that a resource checked in

Types

type CommunicationDatabaseMethod

type CommunicationDatabaseMethod struct{}

type DatabaseStore

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

func Setup

func Setup() (*DatabaseStore, error)

func (*DatabaseStore) AddMembers

func (db *DatabaseStore) AddMembers(members []models.Member) error

AddMembers adds multiple members to the DatabaseStore

func (*DatabaseStore) AddMultipleMembersToResource

func (db *DatabaseStore) AddMultipleMembersToResource(emails []string, resourceID string) ([]models.MemberResourceRelation, error)

AddMultipleMembersToResource grant multiple members access to a resource

func (*DatabaseStore) AddNewMember

func (db *DatabaseStore) AddNewMember(newMember models.Member) (models.Member, error)

func (*DatabaseStore) AddUserToDefaultResources

func (db *DatabaseStore) AddUserToDefaultResources(email string) ([]models.MemberResourceRelation, error)

AddUserToDefaultResources - grants a user access to default resources - untested

func (*DatabaseStore) ApplyMemberCredits

func (db *DatabaseStore) ApplyMemberCredits()

ApplyMemberCredits updates members tiers for all members with credit to Credited

func (*DatabaseStore) AssignRFID

func (db *DatabaseStore) AssignRFID(email string, rfid string) (models.Member, error)

func (*DatabaseStore) DeleteResource

func (db *DatabaseStore) DeleteResource(id string) error

DeleteResource - delete a resource from the db

func (*DatabaseStore) GetAccessStats

func (db *DatabaseStore) GetAccessStats(date time.Time, resourceName string) ([]models.AccessStats, error)

func (*DatabaseStore) GetActiveMembersByResource

func (db *DatabaseStore) GetActiveMembersByResource() ([]models.MemberAccess, error)

func (*DatabaseStore) GetCommunication

func (db *DatabaseStore) GetCommunication(name string) (models.Communication, error)

GetCommunnication returns all the requested communication from the database

func (*DatabaseStore) GetCommunications

func (db *DatabaseStore) GetCommunications() []models.Communication

GetCommunnications returns all communications from the database

func (*DatabaseStore) GetInactiveMembersByResource

func (db *DatabaseStore) GetInactiveMembersByResource() ([]models.MemberAccess, error)

func (*DatabaseStore) GetMemberByEmail

func (db *DatabaseStore) GetMemberByEmail(memberEmail string) (models.Member, error)

GetMemberByEmail - lookup a member by their email address

func (*DatabaseStore) GetMemberByRFID

func (db *DatabaseStore) GetMemberByRFID(rfid string) (models.Member, error)

func (*DatabaseStore) GetMemberChurn

func (db *DatabaseStore) GetMemberChurn() (int, error)

func (*DatabaseStore) GetMemberCountByMonth

func (db *DatabaseStore) GetMemberCountByMonth(month time.Time) (models.MemberCount, error)

func (*DatabaseStore) GetMemberCounts

func (db *DatabaseStore) GetMemberCounts() ([]models.MemberCount, error)

func (*DatabaseStore) GetMemberResourceRelation

func (db *DatabaseStore) GetMemberResourceRelation(m models.Member, r models.Resource) (models.MemberResourceRelation, error)

GetMemberResourceRelation retrieves a relation of a member and a resource

func (*DatabaseStore) GetMembers

func (db *DatabaseStore) GetMembers() []models.Member

func (*DatabaseStore) GetMembersAccess

func (db *DatabaseStore) GetMembersAccess(m models.Member) ([]models.MemberAccess, error)

GetMembersAccess returns a list of a specific members access

this is used for sending a new rfid assigment to a resource

func (*DatabaseStore) GetMembersWithCredit

func (db *DatabaseStore) GetMembersWithCredit() []models.Member

GetMembersWithCredit - gets members that have been credited a membership

if a member exists in the member_credits table
they are credited a membership

func (*DatabaseStore) GetMembersWithLimit

func (db *DatabaseStore) GetMembersWithLimit(limit int, offset int, active bool) []models.Member

func (*DatabaseStore) GetMostRecentCommunicationToMember

func (db *DatabaseStore) GetMostRecentCommunicationToMember(memberId string, commId int) (time.Time, error)

func (*DatabaseStore) GetResourceACL

func (db *DatabaseStore) GetResourceACL(r models.Resource) ([]string, error)

GetResourceACL returns a list of members that have access to that Resource

func (*DatabaseStore) GetResourceACLWithMemberInfo

func (db *DatabaseStore) GetResourceACLWithMemberInfo(r models.Resource) ([]models.Member, error)

GetResourceACLWithMemberInfo returns a list of members that have access to that Resource

func (*DatabaseStore) GetResourceByID

func (db *DatabaseStore) GetResourceByID(ID string) (models.Resource, error)

GetResourceByID - lookup a resource by it's name

func (*DatabaseStore) GetResourceByName

func (db *DatabaseStore) GetResourceByName(resourceName string) (models.Resource, error)

GetResourceByName - lookup a resource by it's name

func (*DatabaseStore) GetResources

func (db *DatabaseStore) GetResources() []models.Resource

GetResources - gets the status from DB

func (*DatabaseStore) GetTiers

func (db *DatabaseStore) GetTiers() []models.Tier

GetMemberTiers - gets the member tiers from DB

func (*DatabaseStore) GetUser

func (db *DatabaseStore) GetUser(email string) (models.UserResponse, error)

GetUser returns the currently logged in user

func (*DatabaseStore) LogAccessEvent

func (db *DatabaseStore) LogAccessEvent(logMsg models.LogMessage) error

func (*DatabaseStore) LogCommunication

func (db *DatabaseStore) LogCommunication(communicationId int, memberId string) error

func (*DatabaseStore) ProcessMember

func (db *DatabaseStore) ProcessMember(newMember models.Member) error

ProcessMember - add them member if they don't already exist. Otherwise, make sure we have their name

func (*DatabaseStore) RegisterResource

func (db *DatabaseStore) RegisterResource(name string, address string, isDefault bool) (models.Resource, error)

RegisterResource - stores a new resource in the db

func (*DatabaseStore) RegisterUser

func (db *DatabaseStore) RegisterUser(creds models.Credentials) error

RegisterUser register a user in the db

func (*DatabaseStore) RemoveUserFromResource

func (db *DatabaseStore) RemoveUserFromResource(email string, resourceID string) error

RemoveUserFromResource - removes a users access to a resource

func (*DatabaseStore) SetMemberLevel

func (db *DatabaseStore) SetMemberLevel(memberId string, level models.MemberLevel) error

SetMemberLevel sets a member's membership tier

func (*DatabaseStore) UpdateMember

func (db *DatabaseStore) UpdateMember(update models.Member) error

func (*DatabaseStore) UpdateMemberBySubscriptionID

func (db *DatabaseStore) UpdateMemberBySubscriptionID(subscriptionID string, update models.Member) error

func (*DatabaseStore) UpdateMemberCounts

func (db *DatabaseStore) UpdateMemberCounts()

func (*DatabaseStore) UpdateMemberTiers

func (db *DatabaseStore) UpdateMemberTiers()

UpdateMemberTiers updates member tiers based on the most recent payment amount

func (*DatabaseStore) UpdateResource

func (db *DatabaseStore) UpdateResource(res models.Resource) (*models.Resource, error)

UpdateResource - updates a resource in the db

func (*DatabaseStore) UserSignin

func (db *DatabaseStore) UserSignin(email string, password string) error

UserSignin - user login

type MemberDatabaseMethod

type MemberDatabaseMethod struct{}

MemberDatabaseMethod -- method container that holds the extension methods to query the members, credit, and resource tables

type ReportsDatabaseMethod

type ReportsDatabaseMethod struct{}

ReportsDatabaseMethod -- method container that holds the extension methods to query the members, credit, and resource tables

type ResourceDatabaseMethod

type ResourceDatabaseMethod struct{}

ResourceDatabaseMethod -- method container that holds the extension methods to query the resources table

type TierDatabaseMethod

type TierDatabaseMethod struct{}

TierDatabaseMethod -- method container that holds the extension methods to query the tier table

type UserDatabaseMethod

type UserDatabaseMethod struct{}

UserDatabaseMethod -- method container that holds the extension methods to query the user table

Jump to

Keyboard shortcuts

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