trips

package
v0.0.0-...-e6b71c9 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddItem

func AddItem(userID uuid.UUID, args map[string]interface{}) (addedItem *models.Item, err error)

AddItem adds an item to a trip and handles things like permission checks

func AddItemsToStore

func AddItemsToStore(userID uuid.UUID, args map[string]interface{}) (addedItems []*models.Item, err error)

AddItemsToStore adds an array of items to a store for a user. It creates the store for the user if it doesn't already exist.

func AddStapleItemsToNewTrip

func AddStapleItemsToNewTrip(trip models.GroceryTrip) (err error)

AddStapleItemsToNewTrip adds items set as staple items for this store to the new trip

func CompileItemSettingsMap

func CompileItemSettingsMap(itemSettings datatypes.JSON) (settings map[string]interface{}, err error)

CompileItemSettingsMap unmarshals the existing item settings json map, or makes a new map if one does not exist yet

func CopyRemainingItemsToNewTrip

func CopyRemainingItemsToNewTrip(
	trip models.GroceryTrip,
	newTrip *models.GroceryTrip,
	tx *gorm.DB,
) (err error)

func DeleteItem

func DeleteItem(itemID interface{}) (deletedItem models.Item, err error)

DeleteItem deletes an item from a trip and handles trip category cleanup (i.e. if this is the last item in a trip category, it deletes the trip category)

func FindDefaultStore

func FindDefaultStore(userID uuid.UUID) (store models.Store, err error)

FindDefaultStore retrieves the ID of the store that is set as the default for the userID provided

func FindOrCreateStore

func FindOrCreateStore(userID uuid.UUID, name string) (storeRecord models.Store, err error)

FindOrCreateStore finds or creates a store for a userID by name

func GetNewPosition

func GetNewPosition(tripID uuid.UUID, completed bool) int

GetNewPosition gets the new position of an updated item

func MarkItemAsCompleted

func MarkItemAsCompleted(name string, userID uuid.UUID) (updatedItems []*models.Item, err error)

MarkItemAsCompleted item as completed by name for user (in any store)

func MarkItemsInOldTripAsCompleted

func MarkItemsInOldTripAsCompleted(trip models.GroceryTrip, tx *gorm.DB) (err error)

MarkItemsInOldTripAsCompleted marks each item in the old trip as completed

This uses UpdateColumn to avoid hooks (https://gorm.io/docs/update.html#Without-Hooks-Time-Tracking)

func ReorderItem

func ReorderItem(itemID interface{}, position int) (*models.GroceryTrip, error)

ReorderItem handles the reordering of an item by taking the item ID and the new position. It returns the reordered trip object.

func RetrieveCurrentStoreTrip

func RetrieveCurrentStoreTrip(storeID uuid.UUID) (groceryTrip models.GroceryTrip, err error)

RetrieveCurrentStoreTrip retrieves the currently active grocery trip in a store

func RetrieveCurrentStoreTripForUser

func RetrieveCurrentStoreTripForUser(storeID uuid.UUID, user models.User) (groceryTrip models.GroceryTrip, err error)

RetrieveCurrentStoreTripForUser retrieves the currently active grocery trip in a store by storeID if the userID has access to to the store

func RetrieveItems

func RetrieveItems(tripID uuid.UUID) (interface{}, error)

RetrieveItems finds all items in a grocery trip by tripID

func RetrieveItemsInCategory

func RetrieveItemsInCategory(tripID uuid.UUID, categoryID uuid.UUID) (interface{}, error)

RetrieveItemsInCategory finds all items in a grocery trip by category

func RetrieveTrip

func RetrieveTrip(tripID interface{}) (models.GroceryTrip, error)

RetrieveTrip retrieves a specific grocery trip by ID

func RetrieveTrips

func RetrieveTrips(storeID interface{}, userID uuid.UUID, completed bool) (tripsList []models.GroceryTrip, err error)

RetrieveTrips retrieves grocery trips within a store

func SaveStoreCategorySelection

func SaveStoreCategorySelection(item *models.Item, storeCategoryID uuid.UUID) (err error)

SaveStoreCategorySelection updates the store item category settings for a given item in a store, so that the item will be added to this category going forwards

func SearchForItemByName

func SearchForItemByName(name string, userID uuid.UUID) (item *models.Item, err error)

SearchForItemByName finds an item within the stores the user belongs to

func UpdateItem

func UpdateItem(args map[string]interface{}) (interface{}, error)

UpdateItem updates an item by itemID

func UpdateStoreItemCategorySettings

func UpdateStoreItemCategorySettings(
	itemName string,
	storeCategoryID uuid.UUID,
	storeItemCategorySetting models.StoreItemCategorySettings,
) (err error)

UpdateStoreItemCategorySettings unpacks the item settings, adds/updates the key by item name, repacks the updated item settings into JSON, and saves it

func UpdateTrip

func UpdateTrip(args map[string]interface{}) (interface{}, error)

UpdateTrip updates a grocery trip with the given args by tripID

Types

This section is empty.

Jump to

Keyboard shortcuts

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