renamed history package to version to avoid confusion with event history

This commit is contained in:
Florian Schlegel 2016-05-30 17:20:10 +02:00
parent 50da96e9ba
commit 6fd8a2751b
8 changed files with 22 additions and 22 deletions

View File

@ -5,7 +5,7 @@ import (
"strings"
"github.com/foomo/shop/crypto"
"github.com/foomo/shop/history"
"github.com/foomo/shop/version"
"gopkg.in/mgo.v2/bson"
)
@ -15,7 +15,7 @@ import (
type CustomerCredentials struct {
BsonId bson.ObjectId `bson:"_id,omitempty"`
Version *history.Version
Version *version.Version
Email string // always stored lowercase
Crypto *crypto.Crypto
}
@ -49,7 +49,7 @@ func CreateCustomerCredentials(email, password string) error {
return err
}
credentials := &CustomerCredentials{
Version: history.NewVersion(),
Version: version.NewVersion(),
Email: lc(email),
Crypto: crypto,
}

View File

@ -9,9 +9,9 @@ import (
"gopkg.in/mgo.v2/bson"
"github.com/foomo/shop/event_log"
"github.com/foomo/shop/history"
"github.com/foomo/shop/unique"
"github.com/foomo/shop/utils"
"github.com/foomo/shop/version"
)
//------------------------------------------------------------------
@ -52,7 +52,7 @@ type Customer struct {
Id string // Email is used as LoginID, but can change. This is never changes!
unlinkDB bool // if true, changes to Customer are not stored in database
Flags *Flags
Version *history.Version
Version *version.Version
CreatedAt time.Time
LastModifiedAt time.Time
Email string // unique, used as Login Credential
@ -128,7 +128,7 @@ func NewCustomer(email, password string, customProvider CustomerCustomProvider)
customer := &Customer{
Flags: &Flags{},
Version: history.NewVersion(),
Version: version.NewVersion(),
Id: unique.GetNewID(),
Email: lc(email),
CreatedAt: utils.TimeNow(),
@ -229,7 +229,7 @@ func (customer *Customer) RemoveAddress(id string) {
// ~ PUBLIC METHODS
//------------------------------------------------------------------
// DiffTwoLatestCustomerVersions compares the two latest Versions of Customer found in history.
// DiffTwoLatestCustomerVersions compares the two latest Versions of Customer found in version.
// If openInBrowser, the result is automatically displayed in the default browser.
func DiffTwoLatestCustomerVersions(customerId string, customProvider CustomerCustomProvider, openInBrowser bool) (string, error) {
version, err := GetCurrentVersionOfCustomerFromHistory(customerId)
@ -254,7 +254,7 @@ func DiffCustomerVersions(customerId string, versionA int, versionB int, customP
return "", err
}
html, err := history.DiffVersions(customerVersionA, customerVersionB)
html, err := version.DiffVersions(customerVersionA, customerVersionB)
if err != nil {
return "", err
}

View File

@ -4,8 +4,8 @@ import (
"errors"
"time"
"github.com/foomo/shop/history"
"github.com/foomo/shop/utils"
"github.com/foomo/shop/version"
)
//------------------------------------------------------------------
@ -16,7 +16,7 @@ func (customer *Customer) GetID() string {
return customer.Id
}
func (customer *Customer) GetVersion() *history.Version {
func (customer *Customer) GetVersion() *version.Version {
return customer.Version
}

View File

@ -8,8 +8,8 @@ import (
"github.com/foomo/shop/configuration"
"github.com/foomo/shop/event_log"
"github.com/foomo/shop/history"
"github.com/foomo/shop/persistence"
"github.com/foomo/shop/version"
"github.com/mitchellh/mapstructure"
"gopkg.in/mgo.v2/bson"
)
@ -238,7 +238,7 @@ func GetCustomerByEmail(email string, customProvider CustomerCustomProvider) (*C
func GetCurrentCustomerByIdFromHistory(customerId string, customProvider CustomerCustomProvider) (*Customer, error) {
return findOneCustomer(&bson.M{"id": customerId}, nil, "-version.current", customProvider, true)
}
func GetCurrentVersionOfCustomerFromHistory(customerId string) (*history.Version, error) {
func GetCurrentVersionOfCustomerFromHistory(customerId string) (*version.Version, error) {
customer, err := findOneCustomer(&bson.M{"id": customerId}, &bson.M{"version": 1}, "-version.current", nil, true)
if err != nil {
return nil, err

View File

@ -13,12 +13,12 @@ import (
"gopkg.in/mgo.v2/bson"
"github.com/foomo/shop/event_log"
"github.com/foomo/shop/history"
"github.com/foomo/shop/payment"
"github.com/foomo/shop/shipping"
"github.com/foomo/shop/state"
"github.com/foomo/shop/unique"
"github.com/foomo/shop/utils"
"github.com/foomo/shop/version"
)
//------------------------------------------------------------------
@ -53,7 +53,7 @@ type OrderStatus string
type Order struct {
BsonId bson.ObjectId `bson:"_id,omitempty"`
Id string // automatically generated unique id
Version *history.Version
Version *version.Version
unlinkDB bool // if true, changes to Customer are not stored in database
Flags *Flags
State *state.State
@ -136,7 +136,7 @@ func NewOrderWithCustomId(customProvider OrderCustomProvider, orderIdFunc func()
State: stateMachine.GetInitialState(),
Flags: &Flags{},
Id: orderId,
Version: history.NewVersion(),
Version: version.NewVersion(),
CreatedAt: utils.TimeNow(),
LastModifiedAt: utils.TimeNow(),
OrderType: OrderTypeOrder,
@ -272,7 +272,7 @@ func (p *Position) GetAmount() float64 {
// ~ PUBLIC METHODS
//------------------------------------------------------------------
// DiffTwoLatestOrderVersions compares the two latest Versions of Order found in history.
// DiffTwoLatestOrderVersions compares the two latest Versions of Order found in version.
// If openInBrowser, the result is automatically displayed in the default browser.
func DiffTwoLatestOrderVersions(orderId string, customProvider OrderCustomProvider, openInBrowser bool) (string, error) {
version, err := GetCurrentVersionOfOrderFromHistory(orderId)
@ -297,7 +297,7 @@ func DiffOrderVersions(orderId string, versionA int, versionB int, customProvide
return "", err
}
html, err := history.DiffVersions(orderVersionA, orderVersionB)
html, err := version.DiffVersions(orderVersionA, orderVersionB)
if err != nil {
return "", err
}

View File

@ -5,11 +5,11 @@ import (
"github.com/foomo/shop/customer"
"github.com/foomo/shop/event_log"
"github.com/foomo/shop/history"
"github.com/foomo/shop/payment"
"github.com/foomo/shop/shipping"
"github.com/foomo/shop/state"
"github.com/foomo/shop/utils"
"github.com/foomo/shop/version"
)
//------------------------------------------------------------------
@ -20,7 +20,7 @@ func (order *Order) GetID() string {
return order.Id
}
func (order *Order) GetVersion() *history.Version {
func (order *Order) GetVersion() *version.Version {
return order.Version
}

View File

@ -7,8 +7,8 @@ import (
"strconv"
"github.com/foomo/shop/event_log"
"github.com/foomo/shop/history"
"github.com/foomo/shop/persistence"
"github.com/foomo/shop/version"
"github.com/mitchellh/mapstructure"
"github.com/foomo/shop/configuration"
@ -199,7 +199,7 @@ func GetOrderById(id string, customProvider OrderCustomProvider) (*Order, error)
func GetCurrentOrderByIdFromHistory(orderId string, customProvider OrderCustomProvider) (*Order, error) {
return findOneOrder(&bson.M{"id": orderId}, nil, "-version.current", customProvider, true)
}
func GetCurrentVersionOfOrderFromHistory(orderId string) (*history.Version, error) {
func GetCurrentVersionOfOrderFromHistory(orderId string) (*version.Version, error) {
order, err := findOneOrder(&bson.M{"id": orderId}, &bson.M{"version": 1}, "-version.current", nil, true)
if err != nil {
return nil, err

View File

@ -1,4 +1,4 @@
package history
package version
import (
"encoding/json"