From efebe3c3dc95eb0007e8705991efc3ee45dd7998 Mon Sep 17 00:00:00 2001 From: elraphty Date: Fri, 15 Nov 2024 15:51:30 +0100 Subject: [PATCH 1/2] Updated Process Bountys bounty updates --- db/db.go | 15 + db/interface.go | 1 + db/workspaces.go | 11 +- handlers/bounty.go | 6 +- handlers/v2_payments_cron.go | 5 +- mocks/Database.go | 1405 ++++++++++++++++++++++------------ 6 files changed, 954 insertions(+), 489 deletions(-) diff --git a/db/db.go b/db/db.go index e79f60c21..a31db4315 100644 --- a/db/db.go +++ b/db/db.go @@ -1337,6 +1337,21 @@ func (db database) GetBounty(id uint) NewBounty { return b } +func (db database) UpdateBountyPaymentStatuses(bounty NewBounty) (NewBounty, error) { + + bountyUpdates := map[string]interface{}{ + "paid": bounty.Paid, + "payment_pending": bounty.PaymentPending, + "payment_failed": bounty.PaymentFailed, + "completed": bounty.Completed, + "paid_date": bounty.PaidDate, + "completion_date": bounty.CompletionDate, + } + + db.db.Where("created", bounty.Created).Updates(bountyUpdates) + return bounty, nil +} + func (db database) UpdateBounty(b NewBounty) (NewBounty, error) { db.db.Where("created", b.Created).Updates(&b) return b, nil diff --git a/db/interface.go b/db/interface.go index 372813840..5858ad734 100644 --- a/db/interface.go +++ b/db/interface.go @@ -51,6 +51,7 @@ type Database interface { GetBountyByCreated(created uint) (NewBounty, error) GetBounty(id uint) NewBounty UpdateBounty(b NewBounty) (NewBounty, error) + UpdateBountyPaymentStatuses(bounty NewBounty) (NewBounty, error) UpdateBountyPayment(b NewBounty) (NewBounty, error) GetListedOffers(r *http.Request) ([]PeopleExtra, error) UpdateBot(uuid string, u map[string]interface{}) bool diff --git a/db/workspaces.go b/db/workspaces.go index 18e1e42c1..382bff574 100644 --- a/db/workspaces.go +++ b/db/workspaces.go @@ -477,8 +477,17 @@ func (db database) ProcessBountyPayment(payment NewPaymentHistory, bounty NewBou return err } + bountyUpdates := map[string]interface{}{ + "paid": bounty.Paid, + "payment_pending": bounty.PaymentPending, + "payment_failed": bounty.PaymentFailed, + "completed": bounty.Completed, + "paid_date": bounty.PaidDate, + "completion_date": bounty.CompletionDate, + } + // updatge bounty status - if err = tx.Where("created", bounty.Created).Updates(&bounty).Error; err != nil { + if err = tx.Model(&NewBounty{}).Where("created", bounty.Created).Updates(bountyUpdates).Error; err != nil { tx.Rollback() return err } diff --git a/handlers/bounty.go b/handlers/bounty.go index b41e4687a..3b4794a3c 100644 --- a/handlers/bounty.go +++ b/handlers/bounty.go @@ -691,12 +691,13 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request // if the payment has a completed status if v2KeysendRes.Status == db.PaymentComplete { - bounty.Paid = true bounty.PaymentFailed = false bounty.PaymentPending = false + bounty.Paid = true bounty.PaidDate = &now bounty.Completed = true bounty.CompletionDate = &now + paymentHistory.Status = true paymentHistory.PaymentStatus = db.PaymentComplete paymentHistory.Tag = v2KeysendRes.Tag @@ -725,6 +726,7 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request bounty.PaidDate = &now bounty.Completed = true bounty.CompletionDate = &now + paymentHistory.Status = true paymentHistory.PaymentStatus = db.PaymentPending paymentHistory.Tag = v2KeysendRes.Tag @@ -1002,7 +1004,7 @@ func (h *bountyHandler) UpdateBountyPaymentStatus(w http.ResponseWriter, r *http bounty.Completed = true bounty.CompletionDate = &now - h.db.UpdateBounty(bounty) + h.db.UpdateBountyPaymentStatuses(bounty) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(msg) diff --git a/handlers/v2_payments_cron.go b/handlers/v2_payments_cron.go index 3bd88a7b9..66f830a70 100644 --- a/handlers/v2_payments_cron.go +++ b/handlers/v2_payments_cron.go @@ -26,14 +26,15 @@ func InitV2PaymentsCron() { if bounty.ID > 0 { now := time.Now() - bounty.Paid = true bounty.PaymentPending = false bounty.PaymentFailed = false + bounty.Paid = true + bounty.PaidDate = &now bounty.Completed = true bounty.CompletionDate = &now - db.DB.UpdateBounty(bounty) + db.DB.UpdateBountyPaymentStatuses(bounty) } } else if tagResult.Status == db.PaymentFailed { // Handle failed payments diff --git a/mocks/Database.go b/mocks/Database.go index 1a5d8a95c..5a1057b7b 100644 --- a/mocks/Database.go +++ b/mocks/Database.go @@ -1322,6 +1322,52 @@ func (_c *Database_CreateOrEditWorkspaceRepository_Call) RunAndReturn(run func(d return _c } +// CreateProcessingMap provides a mock function with given fields: pm +func (_m *Database) CreateProcessingMap(pm *db.WfProcessingMap) error { + ret := _m.Called(pm) + + if len(ret) == 0 { + panic("no return value specified for CreateProcessingMap") + } + + var r0 error + if rf, ok := ret.Get(0).(func(*db.WfProcessingMap) error); ok { + r0 = rf(pm) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Database_CreateProcessingMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateProcessingMap' +type Database_CreateProcessingMap_Call struct { + *mock.Call +} + +// CreateProcessingMap is a helper method to define mock.On call +// - pm *db.WfProcessingMap +func (_e *Database_Expecter) CreateProcessingMap(pm interface{}) *Database_CreateProcessingMap_Call { + return &Database_CreateProcessingMap_Call{Call: _e.mock.On("CreateProcessingMap", pm)} +} + +func (_c *Database_CreateProcessingMap_Call) Run(run func(pm *db.WfProcessingMap)) *Database_CreateProcessingMap_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*db.WfProcessingMap)) + }) + return _c +} + +func (_c *Database_CreateProcessingMap_Call) Return(_a0 error) *Database_CreateProcessingMap_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_CreateProcessingMap_Call) RunAndReturn(run func(*db.WfProcessingMap) error) *Database_CreateProcessingMap_Call { + _c.Call.Return(run) + return _c +} + // CreateUserRoles provides a mock function with given fields: roles, uuid, pubkey func (_m *Database) CreateUserRoles(roles []db.WorkspaceUserRoles, uuid string, pubkey string) []db.WorkspaceUserRoles { ret := _m.Called(roles, uuid, pubkey) @@ -1372,6 +1418,52 @@ func (_c *Database_CreateUserRoles_Call) RunAndReturn(run func([]db.WorkspaceUse return _c } +// CreateWorkflowRequest provides a mock function with given fields: req +func (_m *Database) CreateWorkflowRequest(req *db.WfRequest) error { + ret := _m.Called(req) + + if len(ret) == 0 { + panic("no return value specified for CreateWorkflowRequest") + } + + var r0 error + if rf, ok := ret.Get(0).(func(*db.WfRequest) error); ok { + r0 = rf(req) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Database_CreateWorkflowRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateWorkflowRequest' +type Database_CreateWorkflowRequest_Call struct { + *mock.Call +} + +// CreateWorkflowRequest is a helper method to define mock.On call +// - req *db.WfRequest +func (_e *Database_Expecter) CreateWorkflowRequest(req interface{}) *Database_CreateWorkflowRequest_Call { + return &Database_CreateWorkflowRequest_Call{Call: _e.mock.On("CreateWorkflowRequest", req)} +} + +func (_c *Database_CreateWorkflowRequest_Call) Run(run func(req *db.WfRequest)) *Database_CreateWorkflowRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*db.WfRequest)) + }) + return _c +} + +func (_c *Database_CreateWorkflowRequest_Call) Return(_a0 error) *Database_CreateWorkflowRequest_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_CreateWorkflowRequest_Call) RunAndReturn(run func(*db.WfRequest) error) *Database_CreateWorkflowRequest_Call { + _c.Call.Return(run) + return _c +} + // CreateWorkspaceBudget provides a mock function with given fields: budget func (_m *Database) CreateWorkspaceBudget(budget db.NewBountyBudget) db.NewBountyBudget { ret := _m.Called(budget) @@ -1753,6 +1845,52 @@ func (_c *Database_DeleteInvoice_Call) RunAndReturn(run func(string) db.NewInvoi return _c } +// DeleteProcessingMap provides a mock function with given fields: id +func (_m *Database) DeleteProcessingMap(id uint) error { + ret := _m.Called(id) + + if len(ret) == 0 { + panic("no return value specified for DeleteProcessingMap") + } + + var r0 error + if rf, ok := ret.Get(0).(func(uint) error); ok { + r0 = rf(id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Database_DeleteProcessingMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteProcessingMap' +type Database_DeleteProcessingMap_Call struct { + *mock.Call +} + +// DeleteProcessingMap is a helper method to define mock.On call +// - id uint +func (_e *Database_Expecter) DeleteProcessingMap(id interface{}) *Database_DeleteProcessingMap_Call { + return &Database_DeleteProcessingMap_Call{Call: _e.mock.On("DeleteProcessingMap", id)} +} + +func (_c *Database_DeleteProcessingMap_Call) Run(run func(id uint)) *Database_DeleteProcessingMap_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint)) + }) + return _c +} + +func (_c *Database_DeleteProcessingMap_Call) Return(_a0 error) *Database_DeleteProcessingMap_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_DeleteProcessingMap_Call) RunAndReturn(run func(uint) error) *Database_DeleteProcessingMap_Call { + _c.Call.Return(run) + return _c +} + // DeleteUserInvoiceData provides a mock function with given fields: payment_request func (_m *Database) DeleteUserInvoiceData(payment_request string) db.UserInvoiceData { ret := _m.Called(payment_request) @@ -1799,6 +1937,52 @@ func (_c *Database_DeleteUserInvoiceData_Call) RunAndReturn(run func(string) db. return _c } +// DeleteWorkflowRequest provides a mock function with given fields: requestID +func (_m *Database) DeleteWorkflowRequest(requestID string) error { + ret := _m.Called(requestID) + + if len(ret) == 0 { + panic("no return value specified for DeleteWorkflowRequest") + } + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(requestID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Database_DeleteWorkflowRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteWorkflowRequest' +type Database_DeleteWorkflowRequest_Call struct { + *mock.Call +} + +// DeleteWorkflowRequest is a helper method to define mock.On call +// - requestID string +func (_e *Database_Expecter) DeleteWorkflowRequest(requestID interface{}) *Database_DeleteWorkflowRequest_Call { + return &Database_DeleteWorkflowRequest_Call{Call: _e.mock.On("DeleteWorkflowRequest", requestID)} +} + +func (_c *Database_DeleteWorkflowRequest_Call) Run(run func(requestID string)) *Database_DeleteWorkflowRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *Database_DeleteWorkflowRequest_Call) Return(_a0 error) *Database_DeleteWorkflowRequest_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_DeleteWorkflowRequest_Call) RunAndReturn(run func(string) error) *Database_DeleteWorkflowRequest_Call { + _c.Call.Return(run) + return _c +} + // DeleteWorkspaceRepository provides a mock function with given fields: workspace_uuid, uuid func (_m *Database) DeleteWorkspaceRepository(workspace_uuid string, uuid string) bool { ret := _m.Called(workspace_uuid, uuid) @@ -4391,6 +4575,64 @@ func (_c *Database_GetPendingPaymentHistory_Call) RunAndReturn(run func() []db.N return _c } +// GetPendingWorkflowRequests provides a mock function with given fields: limit +func (_m *Database) GetPendingWorkflowRequests(limit int) ([]db.WfRequest, error) { + ret := _m.Called(limit) + + if len(ret) == 0 { + panic("no return value specified for GetPendingWorkflowRequests") + } + + var r0 []db.WfRequest + var r1 error + if rf, ok := ret.Get(0).(func(int) ([]db.WfRequest, error)); ok { + return rf(limit) + } + if rf, ok := ret.Get(0).(func(int) []db.WfRequest); ok { + r0 = rf(limit) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]db.WfRequest) + } + } + + if rf, ok := ret.Get(1).(func(int) error); ok { + r1 = rf(limit) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Database_GetPendingWorkflowRequests_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPendingWorkflowRequests' +type Database_GetPendingWorkflowRequests_Call struct { + *mock.Call +} + +// GetPendingWorkflowRequests is a helper method to define mock.On call +// - limit int +func (_e *Database_Expecter) GetPendingWorkflowRequests(limit interface{}) *Database_GetPendingWorkflowRequests_Call { + return &Database_GetPendingWorkflowRequests_Call{Call: _e.mock.On("GetPendingWorkflowRequests", limit)} +} + +func (_c *Database_GetPendingWorkflowRequests_Call) Run(run func(limit int)) *Database_GetPendingWorkflowRequests_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(int)) + }) + return _c +} + +func (_c *Database_GetPendingWorkflowRequests_Call) Return(_a0 []db.WfRequest, _a1 error) *Database_GetPendingWorkflowRequests_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Database_GetPendingWorkflowRequests_Call) RunAndReturn(run func(int) ([]db.WfRequest, error)) *Database_GetPendingWorkflowRequests_Call { + _c.Call.Return(run) + return _c +} + // GetPeopleBySearch provides a mock function with given fields: r func (_m *Database) GetPeopleBySearch(r *http.Request) []db.Person { ret := _m.Called(r) @@ -4933,71 +5175,188 @@ func (_c *Database_GetPreviousWorkspaceBountyByCreated_Call) RunAndReturn(run fu return _c } -// GetSumOfDeposits provides a mock function with given fields: workspace_uuid -func (_m *Database) GetSumOfDeposits(workspace_uuid string) uint { - ret := _m.Called(workspace_uuid) +// GetProcessingMapByKey provides a mock function with given fields: processType, processKey +func (_m *Database) GetProcessingMapByKey(processType string, processKey string) (*db.WfProcessingMap, error) { + ret := _m.Called(processType, processKey) if len(ret) == 0 { - panic("no return value specified for GetSumOfDeposits") + panic("no return value specified for GetProcessingMapByKey") } - var r0 uint - if rf, ok := ret.Get(0).(func(string) uint); ok { - r0 = rf(workspace_uuid) + var r0 *db.WfProcessingMap + var r1 error + if rf, ok := ret.Get(0).(func(string, string) (*db.WfProcessingMap, error)); ok { + return rf(processType, processKey) + } + if rf, ok := ret.Get(0).(func(string, string) *db.WfProcessingMap); ok { + r0 = rf(processType, processKey) } else { - r0 = ret.Get(0).(uint) + if ret.Get(0) != nil { + r0 = ret.Get(0).(*db.WfProcessingMap) + } } - return r0 + if rf, ok := ret.Get(1).(func(string, string) error); ok { + r1 = rf(processType, processKey) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -// Database_GetSumOfDeposits_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSumOfDeposits' -type Database_GetSumOfDeposits_Call struct { +// Database_GetProcessingMapByKey_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetProcessingMapByKey' +type Database_GetProcessingMapByKey_Call struct { *mock.Call } -// GetSumOfDeposits is a helper method to define mock.On call -// - workspace_uuid string -func (_e *Database_Expecter) GetSumOfDeposits(workspace_uuid interface{}) *Database_GetSumOfDeposits_Call { - return &Database_GetSumOfDeposits_Call{Call: _e.mock.On("GetSumOfDeposits", workspace_uuid)} +// GetProcessingMapByKey is a helper method to define mock.On call +// - processType string +// - processKey string +func (_e *Database_Expecter) GetProcessingMapByKey(processType interface{}, processKey interface{}) *Database_GetProcessingMapByKey_Call { + return &Database_GetProcessingMapByKey_Call{Call: _e.mock.On("GetProcessingMapByKey", processType, processKey)} } -func (_c *Database_GetSumOfDeposits_Call) Run(run func(workspace_uuid string)) *Database_GetSumOfDeposits_Call { +func (_c *Database_GetProcessingMapByKey_Call) Run(run func(processType string, processKey string)) *Database_GetProcessingMapByKey_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + run(args[0].(string), args[1].(string)) }) return _c } -func (_c *Database_GetSumOfDeposits_Call) Return(_a0 uint) *Database_GetSumOfDeposits_Call { - _c.Call.Return(_a0) +func (_c *Database_GetProcessingMapByKey_Call) Return(_a0 *db.WfProcessingMap, _a1 error) *Database_GetProcessingMapByKey_Call { + _c.Call.Return(_a0, _a1) return _c } -func (_c *Database_GetSumOfDeposits_Call) RunAndReturn(run func(string) uint) *Database_GetSumOfDeposits_Call { +func (_c *Database_GetProcessingMapByKey_Call) RunAndReturn(run func(string, string) (*db.WfProcessingMap, error)) *Database_GetProcessingMapByKey_Call { _c.Call.Return(run) return _c } -// GetSumOfWithdrawal provides a mock function with given fields: workspace_uuid -func (_m *Database) GetSumOfWithdrawal(workspace_uuid string) uint { - ret := _m.Called(workspace_uuid) +// GetProcessingMapsByType provides a mock function with given fields: processType +func (_m *Database) GetProcessingMapsByType(processType string) ([]db.WfProcessingMap, error) { + ret := _m.Called(processType) if len(ret) == 0 { - panic("no return value specified for GetSumOfWithdrawal") + panic("no return value specified for GetProcessingMapsByType") } - var r0 uint - if rf, ok := ret.Get(0).(func(string) uint); ok { - r0 = rf(workspace_uuid) + var r0 []db.WfProcessingMap + var r1 error + if rf, ok := ret.Get(0).(func(string) ([]db.WfProcessingMap, error)); ok { + return rf(processType) + } + if rf, ok := ret.Get(0).(func(string) []db.WfProcessingMap); ok { + r0 = rf(processType) } else { - r0 = ret.Get(0).(uint) + if ret.Get(0) != nil { + r0 = ret.Get(0).([]db.WfProcessingMap) + } } - return r0 -} - -// Database_GetSumOfWithdrawal_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSumOfWithdrawal' + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(processType) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Database_GetProcessingMapsByType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetProcessingMapsByType' +type Database_GetProcessingMapsByType_Call struct { + *mock.Call +} + +// GetProcessingMapsByType is a helper method to define mock.On call +// - processType string +func (_e *Database_Expecter) GetProcessingMapsByType(processType interface{}) *Database_GetProcessingMapsByType_Call { + return &Database_GetProcessingMapsByType_Call{Call: _e.mock.On("GetProcessingMapsByType", processType)} +} + +func (_c *Database_GetProcessingMapsByType_Call) Run(run func(processType string)) *Database_GetProcessingMapsByType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *Database_GetProcessingMapsByType_Call) Return(_a0 []db.WfProcessingMap, _a1 error) *Database_GetProcessingMapsByType_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Database_GetProcessingMapsByType_Call) RunAndReturn(run func(string) ([]db.WfProcessingMap, error)) *Database_GetProcessingMapsByType_Call { + _c.Call.Return(run) + return _c +} + +// GetSumOfDeposits provides a mock function with given fields: workspace_uuid +func (_m *Database) GetSumOfDeposits(workspace_uuid string) uint { + ret := _m.Called(workspace_uuid) + + if len(ret) == 0 { + panic("no return value specified for GetSumOfDeposits") + } + + var r0 uint + if rf, ok := ret.Get(0).(func(string) uint); ok { + r0 = rf(workspace_uuid) + } else { + r0 = ret.Get(0).(uint) + } + + return r0 +} + +// Database_GetSumOfDeposits_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSumOfDeposits' +type Database_GetSumOfDeposits_Call struct { + *mock.Call +} + +// GetSumOfDeposits is a helper method to define mock.On call +// - workspace_uuid string +func (_e *Database_Expecter) GetSumOfDeposits(workspace_uuid interface{}) *Database_GetSumOfDeposits_Call { + return &Database_GetSumOfDeposits_Call{Call: _e.mock.On("GetSumOfDeposits", workspace_uuid)} +} + +func (_c *Database_GetSumOfDeposits_Call) Run(run func(workspace_uuid string)) *Database_GetSumOfDeposits_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *Database_GetSumOfDeposits_Call) Return(_a0 uint) *Database_GetSumOfDeposits_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_GetSumOfDeposits_Call) RunAndReturn(run func(string) uint) *Database_GetSumOfDeposits_Call { + _c.Call.Return(run) + return _c +} + +// GetSumOfWithdrawal provides a mock function with given fields: workspace_uuid +func (_m *Database) GetSumOfWithdrawal(workspace_uuid string) uint { + ret := _m.Called(workspace_uuid) + + if len(ret) == 0 { + panic("no return value specified for GetSumOfWithdrawal") + } + + var r0 uint + if rf, ok := ret.Get(0).(func(string) uint); ok { + r0 = rf(workspace_uuid) + } else { + r0 = ret.Get(0).(uint) + } + + return r0 +} + +// Database_GetSumOfWithdrawal_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSumOfWithdrawal' type Database_GetSumOfWithdrawal_Call struct { *mock.Call } @@ -5637,204 +5996,436 @@ func (_c *Database_GetUserRoles_Call) RunAndReturn(run func(string, string) []db return _c } -// GetWorkspaceBounties provides a mock function with given fields: r, workspace_uuid -func (_m *Database) GetWorkspaceBounties(r *http.Request, workspace_uuid string) []db.NewBounty { - ret := _m.Called(r, workspace_uuid) +// GetWorkflowRequest provides a mock function with given fields: requestID +func (_m *Database) GetWorkflowRequest(requestID string) (*db.WfRequest, error) { + ret := _m.Called(requestID) if len(ret) == 0 { - panic("no return value specified for GetWorkspaceBounties") + panic("no return value specified for GetWorkflowRequest") } - var r0 []db.NewBounty - if rf, ok := ret.Get(0).(func(*http.Request, string) []db.NewBounty); ok { - r0 = rf(r, workspace_uuid) + var r0 *db.WfRequest + var r1 error + if rf, ok := ret.Get(0).(func(string) (*db.WfRequest, error)); ok { + return rf(requestID) + } + if rf, ok := ret.Get(0).(func(string) *db.WfRequest); ok { + r0 = rf(requestID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.NewBounty) + r0 = ret.Get(0).(*db.WfRequest) } } - return r0 + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(requestID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -// Database_GetWorkspaceBounties_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceBounties' -type Database_GetWorkspaceBounties_Call struct { +// Database_GetWorkflowRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkflowRequest' +type Database_GetWorkflowRequest_Call struct { *mock.Call } -// GetWorkspaceBounties is a helper method to define mock.On call -// - r *http.Request -// - workspace_uuid string -func (_e *Database_Expecter) GetWorkspaceBounties(r interface{}, workspace_uuid interface{}) *Database_GetWorkspaceBounties_Call { - return &Database_GetWorkspaceBounties_Call{Call: _e.mock.On("GetWorkspaceBounties", r, workspace_uuid)} +// GetWorkflowRequest is a helper method to define mock.On call +// - requestID string +func (_e *Database_Expecter) GetWorkflowRequest(requestID interface{}) *Database_GetWorkflowRequest_Call { + return &Database_GetWorkflowRequest_Call{Call: _e.mock.On("GetWorkflowRequest", requestID)} } -func (_c *Database_GetWorkspaceBounties_Call) Run(run func(r *http.Request, workspace_uuid string)) *Database_GetWorkspaceBounties_Call { +func (_c *Database_GetWorkflowRequest_Call) Run(run func(requestID string)) *Database_GetWorkflowRequest_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*http.Request), args[1].(string)) + run(args[0].(string)) }) return _c } -func (_c *Database_GetWorkspaceBounties_Call) Return(_a0 []db.NewBounty) *Database_GetWorkspaceBounties_Call { - _c.Call.Return(_a0) +func (_c *Database_GetWorkflowRequest_Call) Return(_a0 *db.WfRequest, _a1 error) *Database_GetWorkflowRequest_Call { + _c.Call.Return(_a0, _a1) return _c } -func (_c *Database_GetWorkspaceBounties_Call) RunAndReturn(run func(*http.Request, string) []db.NewBounty) *Database_GetWorkspaceBounties_Call { +func (_c *Database_GetWorkflowRequest_Call) RunAndReturn(run func(string) (*db.WfRequest, error)) *Database_GetWorkflowRequest_Call { _c.Call.Return(run) return _c } -// GetWorkspaceBountiesCount provides a mock function with given fields: r, workspace_uuid -func (_m *Database) GetWorkspaceBountiesCount(r *http.Request, workspace_uuid string) int64 { - ret := _m.Called(r, workspace_uuid) +// GetWorkflowRequestByID provides a mock function with given fields: requestID +func (_m *Database) GetWorkflowRequestByID(requestID string) (*db.WfRequest, error) { + ret := _m.Called(requestID) if len(ret) == 0 { - panic("no return value specified for GetWorkspaceBountiesCount") + panic("no return value specified for GetWorkflowRequestByID") } - var r0 int64 - if rf, ok := ret.Get(0).(func(*http.Request, string) int64); ok { - r0 = rf(r, workspace_uuid) + var r0 *db.WfRequest + var r1 error + if rf, ok := ret.Get(0).(func(string) (*db.WfRequest, error)); ok { + return rf(requestID) + } + if rf, ok := ret.Get(0).(func(string) *db.WfRequest); ok { + r0 = rf(requestID) } else { - r0 = ret.Get(0).(int64) + if ret.Get(0) != nil { + r0 = ret.Get(0).(*db.WfRequest) + } } - return r0 + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(requestID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -// Database_GetWorkspaceBountiesCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceBountiesCount' -type Database_GetWorkspaceBountiesCount_Call struct { +// Database_GetWorkflowRequestByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkflowRequestByID' +type Database_GetWorkflowRequestByID_Call struct { *mock.Call } -// GetWorkspaceBountiesCount is a helper method to define mock.On call -// - r *http.Request -// - workspace_uuid string -func (_e *Database_Expecter) GetWorkspaceBountiesCount(r interface{}, workspace_uuid interface{}) *Database_GetWorkspaceBountiesCount_Call { - return &Database_GetWorkspaceBountiesCount_Call{Call: _e.mock.On("GetWorkspaceBountiesCount", r, workspace_uuid)} +// GetWorkflowRequestByID is a helper method to define mock.On call +// - requestID string +func (_e *Database_Expecter) GetWorkflowRequestByID(requestID interface{}) *Database_GetWorkflowRequestByID_Call { + return &Database_GetWorkflowRequestByID_Call{Call: _e.mock.On("GetWorkflowRequestByID", requestID)} } -func (_c *Database_GetWorkspaceBountiesCount_Call) Run(run func(r *http.Request, workspace_uuid string)) *Database_GetWorkspaceBountiesCount_Call { +func (_c *Database_GetWorkflowRequestByID_Call) Run(run func(requestID string)) *Database_GetWorkflowRequestByID_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*http.Request), args[1].(string)) + run(args[0].(string)) }) return _c } -func (_c *Database_GetWorkspaceBountiesCount_Call) Return(_a0 int64) *Database_GetWorkspaceBountiesCount_Call { - _c.Call.Return(_a0) +func (_c *Database_GetWorkflowRequestByID_Call) Return(_a0 *db.WfRequest, _a1 error) *Database_GetWorkflowRequestByID_Call { + _c.Call.Return(_a0, _a1) return _c } -func (_c *Database_GetWorkspaceBountiesCount_Call) RunAndReturn(run func(*http.Request, string) int64) *Database_GetWorkspaceBountiesCount_Call { +func (_c *Database_GetWorkflowRequestByID_Call) RunAndReturn(run func(string) (*db.WfRequest, error)) *Database_GetWorkflowRequestByID_Call { _c.Call.Return(run) return _c } -// GetWorkspaceBountyCount provides a mock function with given fields: uuid -func (_m *Database) GetWorkspaceBountyCount(uuid string) int64 { - ret := _m.Called(uuid) +// GetWorkflowRequestsByStatus provides a mock function with given fields: status +func (_m *Database) GetWorkflowRequestsByStatus(status db.WfRequestStatus) ([]db.WfRequest, error) { + ret := _m.Called(status) if len(ret) == 0 { - panic("no return value specified for GetWorkspaceBountyCount") + panic("no return value specified for GetWorkflowRequestsByStatus") } - var r0 int64 - if rf, ok := ret.Get(0).(func(string) int64); ok { - r0 = rf(uuid) + var r0 []db.WfRequest + var r1 error + if rf, ok := ret.Get(0).(func(db.WfRequestStatus) ([]db.WfRequest, error)); ok { + return rf(status) + } + if rf, ok := ret.Get(0).(func(db.WfRequestStatus) []db.WfRequest); ok { + r0 = rf(status) } else { - r0 = ret.Get(0).(int64) + if ret.Get(0) != nil { + r0 = ret.Get(0).([]db.WfRequest) + } } - return r0 + if rf, ok := ret.Get(1).(func(db.WfRequestStatus) error); ok { + r1 = rf(status) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -// Database_GetWorkspaceBountyCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceBountyCount' -type Database_GetWorkspaceBountyCount_Call struct { +// Database_GetWorkflowRequestsByStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkflowRequestsByStatus' +type Database_GetWorkflowRequestsByStatus_Call struct { *mock.Call } -// GetWorkspaceBountyCount is a helper method to define mock.On call -// - uuid string -func (_e *Database_Expecter) GetWorkspaceBountyCount(uuid interface{}) *Database_GetWorkspaceBountyCount_Call { - return &Database_GetWorkspaceBountyCount_Call{Call: _e.mock.On("GetWorkspaceBountyCount", uuid)} +// GetWorkflowRequestsByStatus is a helper method to define mock.On call +// - status db.WfRequestStatus +func (_e *Database_Expecter) GetWorkflowRequestsByStatus(status interface{}) *Database_GetWorkflowRequestsByStatus_Call { + return &Database_GetWorkflowRequestsByStatus_Call{Call: _e.mock.On("GetWorkflowRequestsByStatus", status)} } -func (_c *Database_GetWorkspaceBountyCount_Call) Run(run func(uuid string)) *Database_GetWorkspaceBountyCount_Call { +func (_c *Database_GetWorkflowRequestsByStatus_Call) Run(run func(status db.WfRequestStatus)) *Database_GetWorkflowRequestsByStatus_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + run(args[0].(db.WfRequestStatus)) }) return _c } -func (_c *Database_GetWorkspaceBountyCount_Call) Return(_a0 int64) *Database_GetWorkspaceBountyCount_Call { - _c.Call.Return(_a0) +func (_c *Database_GetWorkflowRequestsByStatus_Call) Return(_a0 []db.WfRequest, _a1 error) *Database_GetWorkflowRequestsByStatus_Call { + _c.Call.Return(_a0, _a1) return _c } -func (_c *Database_GetWorkspaceBountyCount_Call) RunAndReturn(run func(string) int64) *Database_GetWorkspaceBountyCount_Call { +func (_c *Database_GetWorkflowRequestsByStatus_Call) RunAndReturn(run func(db.WfRequestStatus) ([]db.WfRequest, error)) *Database_GetWorkflowRequestsByStatus_Call { _c.Call.Return(run) return _c } -// GetWorkspaceBudget provides a mock function with given fields: workspace_uuid -func (_m *Database) GetWorkspaceBudget(workspace_uuid string) db.NewBountyBudget { - ret := _m.Called(workspace_uuid) +// GetWorkflowRequestsByWorkflowID provides a mock function with given fields: workflowID +func (_m *Database) GetWorkflowRequestsByWorkflowID(workflowID string) ([]db.WfRequest, error) { + ret := _m.Called(workflowID) if len(ret) == 0 { - panic("no return value specified for GetWorkspaceBudget") + panic("no return value specified for GetWorkflowRequestsByWorkflowID") } - var r0 db.NewBountyBudget - if rf, ok := ret.Get(0).(func(string) db.NewBountyBudget); ok { - r0 = rf(workspace_uuid) + var r0 []db.WfRequest + var r1 error + if rf, ok := ret.Get(0).(func(string) ([]db.WfRequest, error)); ok { + return rf(workflowID) + } + if rf, ok := ret.Get(0).(func(string) []db.WfRequest); ok { + r0 = rf(workflowID) } else { - r0 = ret.Get(0).(db.NewBountyBudget) + if ret.Get(0) != nil { + r0 = ret.Get(0).([]db.WfRequest) + } } - return r0 + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(workflowID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -// Database_GetWorkspaceBudget_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceBudget' -type Database_GetWorkspaceBudget_Call struct { +// Database_GetWorkflowRequestsByWorkflowID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkflowRequestsByWorkflowID' +type Database_GetWorkflowRequestsByWorkflowID_Call struct { *mock.Call } -// GetWorkspaceBudget is a helper method to define mock.On call -// - workspace_uuid string -func (_e *Database_Expecter) GetWorkspaceBudget(workspace_uuid interface{}) *Database_GetWorkspaceBudget_Call { - return &Database_GetWorkspaceBudget_Call{Call: _e.mock.On("GetWorkspaceBudget", workspace_uuid)} +// GetWorkflowRequestsByWorkflowID is a helper method to define mock.On call +// - workflowID string +func (_e *Database_Expecter) GetWorkflowRequestsByWorkflowID(workflowID interface{}) *Database_GetWorkflowRequestsByWorkflowID_Call { + return &Database_GetWorkflowRequestsByWorkflowID_Call{Call: _e.mock.On("GetWorkflowRequestsByWorkflowID", workflowID)} } -func (_c *Database_GetWorkspaceBudget_Call) Run(run func(workspace_uuid string)) *Database_GetWorkspaceBudget_Call { +func (_c *Database_GetWorkflowRequestsByWorkflowID_Call) Run(run func(workflowID string)) *Database_GetWorkflowRequestsByWorkflowID_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string)) }) return _c } -func (_c *Database_GetWorkspaceBudget_Call) Return(_a0 db.NewBountyBudget) *Database_GetWorkspaceBudget_Call { - _c.Call.Return(_a0) +func (_c *Database_GetWorkflowRequestsByWorkflowID_Call) Return(_a0 []db.WfRequest, _a1 error) *Database_GetWorkflowRequestsByWorkflowID_Call { + _c.Call.Return(_a0, _a1) return _c } -func (_c *Database_GetWorkspaceBudget_Call) RunAndReturn(run func(string) db.NewBountyBudget) *Database_GetWorkspaceBudget_Call { +func (_c *Database_GetWorkflowRequestsByWorkflowID_Call) RunAndReturn(run func(string) ([]db.WfRequest, error)) *Database_GetWorkflowRequestsByWorkflowID_Call { _c.Call.Return(run) return _c } -// GetWorkspaceBudgetHistory provides a mock function with given fields: workspace_uuid -func (_m *Database) GetWorkspaceBudgetHistory(workspace_uuid string) []db.BudgetHistoryData { - ret := _m.Called(workspace_uuid) +// GetWorkspaceBounties provides a mock function with given fields: r, workspace_uuid +func (_m *Database) GetWorkspaceBounties(r *http.Request, workspace_uuid string) []db.NewBounty { + ret := _m.Called(r, workspace_uuid) if len(ret) == 0 { - panic("no return value specified for GetWorkspaceBudgetHistory") + panic("no return value specified for GetWorkspaceBounties") } - var r0 []db.BudgetHistoryData - if rf, ok := ret.Get(0).(func(string) []db.BudgetHistoryData); ok { + var r0 []db.NewBounty + if rf, ok := ret.Get(0).(func(*http.Request, string) []db.NewBounty); ok { + r0 = rf(r, workspace_uuid) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]db.NewBounty) + } + } + + return r0 +} + +// Database_GetWorkspaceBounties_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceBounties' +type Database_GetWorkspaceBounties_Call struct { + *mock.Call +} + +// GetWorkspaceBounties is a helper method to define mock.On call +// - r *http.Request +// - workspace_uuid string +func (_e *Database_Expecter) GetWorkspaceBounties(r interface{}, workspace_uuid interface{}) *Database_GetWorkspaceBounties_Call { + return &Database_GetWorkspaceBounties_Call{Call: _e.mock.On("GetWorkspaceBounties", r, workspace_uuid)} +} + +func (_c *Database_GetWorkspaceBounties_Call) Run(run func(r *http.Request, workspace_uuid string)) *Database_GetWorkspaceBounties_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*http.Request), args[1].(string)) + }) + return _c +} + +func (_c *Database_GetWorkspaceBounties_Call) Return(_a0 []db.NewBounty) *Database_GetWorkspaceBounties_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_GetWorkspaceBounties_Call) RunAndReturn(run func(*http.Request, string) []db.NewBounty) *Database_GetWorkspaceBounties_Call { + _c.Call.Return(run) + return _c +} + +// GetWorkspaceBountiesCount provides a mock function with given fields: r, workspace_uuid +func (_m *Database) GetWorkspaceBountiesCount(r *http.Request, workspace_uuid string) int64 { + ret := _m.Called(r, workspace_uuid) + + if len(ret) == 0 { + panic("no return value specified for GetWorkspaceBountiesCount") + } + + var r0 int64 + if rf, ok := ret.Get(0).(func(*http.Request, string) int64); ok { + r0 = rf(r, workspace_uuid) + } else { + r0 = ret.Get(0).(int64) + } + + return r0 +} + +// Database_GetWorkspaceBountiesCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceBountiesCount' +type Database_GetWorkspaceBountiesCount_Call struct { + *mock.Call +} + +// GetWorkspaceBountiesCount is a helper method to define mock.On call +// - r *http.Request +// - workspace_uuid string +func (_e *Database_Expecter) GetWorkspaceBountiesCount(r interface{}, workspace_uuid interface{}) *Database_GetWorkspaceBountiesCount_Call { + return &Database_GetWorkspaceBountiesCount_Call{Call: _e.mock.On("GetWorkspaceBountiesCount", r, workspace_uuid)} +} + +func (_c *Database_GetWorkspaceBountiesCount_Call) Run(run func(r *http.Request, workspace_uuid string)) *Database_GetWorkspaceBountiesCount_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*http.Request), args[1].(string)) + }) + return _c +} + +func (_c *Database_GetWorkspaceBountiesCount_Call) Return(_a0 int64) *Database_GetWorkspaceBountiesCount_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_GetWorkspaceBountiesCount_Call) RunAndReturn(run func(*http.Request, string) int64) *Database_GetWorkspaceBountiesCount_Call { + _c.Call.Return(run) + return _c +} + +// GetWorkspaceBountyCount provides a mock function with given fields: uuid +func (_m *Database) GetWorkspaceBountyCount(uuid string) int64 { + ret := _m.Called(uuid) + + if len(ret) == 0 { + panic("no return value specified for GetWorkspaceBountyCount") + } + + var r0 int64 + if rf, ok := ret.Get(0).(func(string) int64); ok { + r0 = rf(uuid) + } else { + r0 = ret.Get(0).(int64) + } + + return r0 +} + +// Database_GetWorkspaceBountyCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceBountyCount' +type Database_GetWorkspaceBountyCount_Call struct { + *mock.Call +} + +// GetWorkspaceBountyCount is a helper method to define mock.On call +// - uuid string +func (_e *Database_Expecter) GetWorkspaceBountyCount(uuid interface{}) *Database_GetWorkspaceBountyCount_Call { + return &Database_GetWorkspaceBountyCount_Call{Call: _e.mock.On("GetWorkspaceBountyCount", uuid)} +} + +func (_c *Database_GetWorkspaceBountyCount_Call) Run(run func(uuid string)) *Database_GetWorkspaceBountyCount_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *Database_GetWorkspaceBountyCount_Call) Return(_a0 int64) *Database_GetWorkspaceBountyCount_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_GetWorkspaceBountyCount_Call) RunAndReturn(run func(string) int64) *Database_GetWorkspaceBountyCount_Call { + _c.Call.Return(run) + return _c +} + +// GetWorkspaceBudget provides a mock function with given fields: workspace_uuid +func (_m *Database) GetWorkspaceBudget(workspace_uuid string) db.NewBountyBudget { + ret := _m.Called(workspace_uuid) + + if len(ret) == 0 { + panic("no return value specified for GetWorkspaceBudget") + } + + var r0 db.NewBountyBudget + if rf, ok := ret.Get(0).(func(string) db.NewBountyBudget); ok { + r0 = rf(workspace_uuid) + } else { + r0 = ret.Get(0).(db.NewBountyBudget) + } + + return r0 +} + +// Database_GetWorkspaceBudget_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceBudget' +type Database_GetWorkspaceBudget_Call struct { + *mock.Call +} + +// GetWorkspaceBudget is a helper method to define mock.On call +// - workspace_uuid string +func (_e *Database_Expecter) GetWorkspaceBudget(workspace_uuid interface{}) *Database_GetWorkspaceBudget_Call { + return &Database_GetWorkspaceBudget_Call{Call: _e.mock.On("GetWorkspaceBudget", workspace_uuid)} +} + +func (_c *Database_GetWorkspaceBudget_Call) Run(run func(workspace_uuid string)) *Database_GetWorkspaceBudget_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *Database_GetWorkspaceBudget_Call) Return(_a0 db.NewBountyBudget) *Database_GetWorkspaceBudget_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_GetWorkspaceBudget_Call) RunAndReturn(run func(string) db.NewBountyBudget) *Database_GetWorkspaceBudget_Call { + _c.Call.Return(run) + return _c +} + +// GetWorkspaceBudgetHistory provides a mock function with given fields: workspace_uuid +func (_m *Database) GetWorkspaceBudgetHistory(workspace_uuid string) []db.BudgetHistoryData { + ret := _m.Called(workspace_uuid) + + if len(ret) == 0 { + panic("no return value specified for GetWorkspaceBudgetHistory") + } + + var r0 []db.BudgetHistoryData + if rf, ok := ret.Get(0).(func(string) []db.BudgetHistoryData); ok { r0 = rf(workspace_uuid) } else { if ret.Get(0) != nil { @@ -7786,6 +8377,62 @@ func (_c *Database_UpdateBountyPayment_Call) RunAndReturn(run func(db.NewBounty) return _c } +// UpdateBountyPaymentStatuses provides a mock function with given fields: bounty +func (_m *Database) UpdateBountyPaymentStatuses(bounty db.NewBounty) (db.NewBounty, error) { + ret := _m.Called(bounty) + + if len(ret) == 0 { + panic("no return value specified for UpdateBountyPaymentStatuses") + } + + var r0 db.NewBounty + var r1 error + if rf, ok := ret.Get(0).(func(db.NewBounty) (db.NewBounty, error)); ok { + return rf(bounty) + } + if rf, ok := ret.Get(0).(func(db.NewBounty) db.NewBounty); ok { + r0 = rf(bounty) + } else { + r0 = ret.Get(0).(db.NewBounty) + } + + if rf, ok := ret.Get(1).(func(db.NewBounty) error); ok { + r1 = rf(bounty) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Database_UpdateBountyPaymentStatuses_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateBountyPaymentStatuses' +type Database_UpdateBountyPaymentStatuses_Call struct { + *mock.Call +} + +// UpdateBountyPaymentStatuses is a helper method to define mock.On call +// - bounty db.NewBounty +func (_e *Database_Expecter) UpdateBountyPaymentStatuses(bounty interface{}) *Database_UpdateBountyPaymentStatuses_Call { + return &Database_UpdateBountyPaymentStatuses_Call{Call: _e.mock.On("UpdateBountyPaymentStatuses", bounty)} +} + +func (_c *Database_UpdateBountyPaymentStatuses_Call) Run(run func(bounty db.NewBounty)) *Database_UpdateBountyPaymentStatuses_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(db.NewBounty)) + }) + return _c +} + +func (_c *Database_UpdateBountyPaymentStatuses_Call) Return(_a0 db.NewBounty, _a1 error) *Database_UpdateBountyPaymentStatuses_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Database_UpdateBountyPaymentStatuses_Call) RunAndReturn(run func(db.NewBounty) (db.NewBounty, error)) *Database_UpdateBountyPaymentStatuses_Call { + _c.Call.Return(run) + return _c +} + // UpdateChannel provides a mock function with given fields: id, u func (_m *Database) UpdateChannel(id uint, u map[string]interface{}) bool { ret := _m.Called(id, u) @@ -8042,34 +8689,80 @@ func (_c *Database_UpdatePerson_Call) RunAndReturn(run func(uint, map[string]int return _c } -// UpdateTribe provides a mock function with given fields: uuid, u -func (_m *Database) UpdateTribe(uuid string, u map[string]interface{}) bool { - ret := _m.Called(uuid, u) +// UpdateProcessingMap provides a mock function with given fields: pm +func (_m *Database) UpdateProcessingMap(pm *db.WfProcessingMap) error { + ret := _m.Called(pm) if len(ret) == 0 { - panic("no return value specified for UpdateTribe") + panic("no return value specified for UpdateProcessingMap") } - var r0 bool - if rf, ok := ret.Get(0).(func(string, map[string]interface{}) bool); ok { - r0 = rf(uuid, u) + var r0 error + if rf, ok := ret.Get(0).(func(*db.WfProcessingMap) error); ok { + r0 = rf(pm) } else { - r0 = ret.Get(0).(bool) + r0 = ret.Error(0) } return r0 } -// Database_UpdateTribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateTribe' -type Database_UpdateTribe_Call struct { +// Database_UpdateProcessingMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateProcessingMap' +type Database_UpdateProcessingMap_Call struct { *mock.Call } -// UpdateTribe is a helper method to define mock.On call -// - uuid string -// - u map[string]interface{} -func (_e *Database_Expecter) UpdateTribe(uuid interface{}, u interface{}) *Database_UpdateTribe_Call { - return &Database_UpdateTribe_Call{Call: _e.mock.On("UpdateTribe", uuid, u)} +// UpdateProcessingMap is a helper method to define mock.On call +// - pm *db.WfProcessingMap +func (_e *Database_Expecter) UpdateProcessingMap(pm interface{}) *Database_UpdateProcessingMap_Call { + return &Database_UpdateProcessingMap_Call{Call: _e.mock.On("UpdateProcessingMap", pm)} +} + +func (_c *Database_UpdateProcessingMap_Call) Run(run func(pm *db.WfProcessingMap)) *Database_UpdateProcessingMap_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*db.WfProcessingMap)) + }) + return _c +} + +func (_c *Database_UpdateProcessingMap_Call) Return(_a0 error) *Database_UpdateProcessingMap_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_UpdateProcessingMap_Call) RunAndReturn(run func(*db.WfProcessingMap) error) *Database_UpdateProcessingMap_Call { + _c.Call.Return(run) + return _c +} + +// UpdateTribe provides a mock function with given fields: uuid, u +func (_m *Database) UpdateTribe(uuid string, u map[string]interface{}) bool { + ret := _m.Called(uuid, u) + + if len(ret) == 0 { + panic("no return value specified for UpdateTribe") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(string, map[string]interface{}) bool); ok { + r0 = rf(uuid, u) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// Database_UpdateTribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateTribe' +type Database_UpdateTribe_Call struct { + *mock.Call +} + +// UpdateTribe is a helper method to define mock.On call +// - uuid string +// - u map[string]interface{} +func (_e *Database_Expecter) UpdateTribe(uuid interface{}, u interface{}) *Database_UpdateTribe_Call { + return &Database_UpdateTribe_Call{Call: _e.mock.On("UpdateTribe", uuid, u)} } func (_c *Database_UpdateTribe_Call) Run(run func(uuid string, u map[string]interface{})) *Database_UpdateTribe_Call { @@ -8157,6 +8850,100 @@ func (_c *Database_UpdateTwitterConfirmed_Call) RunAndReturn(run func(uint, bool return _c } +// UpdateWorkflowRequest provides a mock function with given fields: req +func (_m *Database) UpdateWorkflowRequest(req *db.WfRequest) error { + ret := _m.Called(req) + + if len(ret) == 0 { + panic("no return value specified for UpdateWorkflowRequest") + } + + var r0 error + if rf, ok := ret.Get(0).(func(*db.WfRequest) error); ok { + r0 = rf(req) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Database_UpdateWorkflowRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateWorkflowRequest' +type Database_UpdateWorkflowRequest_Call struct { + *mock.Call +} + +// UpdateWorkflowRequest is a helper method to define mock.On call +// - req *db.WfRequest +func (_e *Database_Expecter) UpdateWorkflowRequest(req interface{}) *Database_UpdateWorkflowRequest_Call { + return &Database_UpdateWorkflowRequest_Call{Call: _e.mock.On("UpdateWorkflowRequest", req)} +} + +func (_c *Database_UpdateWorkflowRequest_Call) Run(run func(req *db.WfRequest)) *Database_UpdateWorkflowRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*db.WfRequest)) + }) + return _c +} + +func (_c *Database_UpdateWorkflowRequest_Call) Return(_a0 error) *Database_UpdateWorkflowRequest_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_UpdateWorkflowRequest_Call) RunAndReturn(run func(*db.WfRequest) error) *Database_UpdateWorkflowRequest_Call { + _c.Call.Return(run) + return _c +} + +// UpdateWorkflowRequestStatusAndResponse provides a mock function with given fields: requestID, status, responseData +func (_m *Database) UpdateWorkflowRequestStatusAndResponse(requestID string, status db.WfRequestStatus, responseData db.JSONB) error { + ret := _m.Called(requestID, status, responseData) + + if len(ret) == 0 { + panic("no return value specified for UpdateWorkflowRequestStatusAndResponse") + } + + var r0 error + if rf, ok := ret.Get(0).(func(string, db.WfRequestStatus, db.JSONB) error); ok { + r0 = rf(requestID, status, responseData) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Database_UpdateWorkflowRequestStatusAndResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateWorkflowRequestStatusAndResponse' +type Database_UpdateWorkflowRequestStatusAndResponse_Call struct { + *mock.Call +} + +// UpdateWorkflowRequestStatusAndResponse is a helper method to define mock.On call +// - requestID string +// - status db.WfRequestStatus +// - responseData db.JSONB +func (_e *Database_Expecter) UpdateWorkflowRequestStatusAndResponse(requestID interface{}, status interface{}, responseData interface{}) *Database_UpdateWorkflowRequestStatusAndResponse_Call { + return &Database_UpdateWorkflowRequestStatusAndResponse_Call{Call: _e.mock.On("UpdateWorkflowRequestStatusAndResponse", requestID, status, responseData)} +} + +func (_c *Database_UpdateWorkflowRequestStatusAndResponse_Call) Run(run func(requestID string, status db.WfRequestStatus, responseData db.JSONB)) *Database_UpdateWorkflowRequestStatusAndResponse_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(db.WfRequestStatus), args[2].(db.JSONB)) + }) + return _c +} + +func (_c *Database_UpdateWorkflowRequestStatusAndResponse_Call) Return(_a0 error) *Database_UpdateWorkflowRequestStatusAndResponse_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_UpdateWorkflowRequestStatusAndResponse_Call) RunAndReturn(run func(string, db.WfRequestStatus, db.JSONB) error) *Database_UpdateWorkflowRequestStatusAndResponse_Call { + _c.Call.Return(run) + return _c +} + // UpdateWorkspaceBudget provides a mock function with given fields: budget func (_m *Database) UpdateWorkspaceBudget(budget db.NewBountyBudget) db.NewBountyBudget { ret := _m.Called(budget) @@ -8392,353 +9179,3 @@ func NewDatabase(t interface { return mock } - - -// CreateWorkflowRequest provides a mock function with given fields: req -func (_m *Database) CreateWorkflowRequest(req *db.WfRequest) error { - ret := _m.Called(req) - var r0 error - if rf, ok := ret.Get(0).(func(*db.WfRequest) error); ok { - r0 = rf(req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -type Database_CreateWorkflowRequest_Call struct { - *mock.Call -} - -func (_e *Database_Expecter) CreateWorkflowRequest(req interface{}) *Database_CreateWorkflowRequest_Call { - return &Database_CreateWorkflowRequest_Call{Call: _e.mock.On("CreateWorkflowRequest", req)} -} - -func (_c *Database_CreateWorkflowRequest_Call) Run(run func(req *db.WfRequest)) *Database_CreateWorkflowRequest_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*db.WfRequest)) - }) - return _c -} - -func (_c *Database_CreateWorkflowRequest_Call) Return(err error) *Database_CreateWorkflowRequest_Call { - _c.Call.Return(err) - return _c -} - -// UpdateWorkflowRequest provides a mock function with given fields: req -func (_m *Database) UpdateWorkflowRequest(req *db.WfRequest) error { - ret := _m.Called(req) - var r0 error - if rf, ok := ret.Get(0).(func(*db.WfRequest) error); ok { - r0 = rf(req) - } else { - r0 = ret.Error(0) - } - return r0 -} - -type Database_UpdateWorkflowRequest_Call struct { - *mock.Call -} - -func (_e *Database_Expecter) UpdateWorkflowRequest(req interface{}) *Database_UpdateWorkflowRequest_Call { - return &Database_UpdateWorkflowRequest_Call{Call: _e.mock.On("UpdateWorkflowRequest", req)} -} - -func (_c *Database_UpdateWorkflowRequest_Call) Run(run func(req *db.WfRequest)) *Database_UpdateWorkflowRequest_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*db.WfRequest)) - }) - return _c -} - -func (_c *Database_UpdateWorkflowRequest_Call) Return(err error) *Database_UpdateWorkflowRequest_Call { - _c.Call.Return(err) - return _c -} - -// GetWorkflowRequestByID provides a mock function with given fields: requestID -func (_m *Database) GetWorkflowRequestByID(requestID string) (*db.WfRequest, error) { - ret := _m.Called(requestID) - var r0 *db.WfRequest - var r1 error - if rf, ok := ret.Get(0).(func(string) (*db.WfRequest, error)); ok { - return rf(requestID) - } - if ret.Get(0) != nil { - r0 = ret.Get(0).(*db.WfRequest) - } - r1 = ret.Error(1) - return r0, r1 -} - -type Database_GetWorkflowRequestByID_Call struct { - *mock.Call -} - -func (_e *Database_Expecter) GetWorkflowRequestByID(requestID interface{}) *Database_GetWorkflowRequestByID_Call { - return &Database_GetWorkflowRequestByID_Call{Call: _e.mock.On("GetWorkflowRequestByID", requestID)} -} - -func (_c *Database_GetWorkflowRequestByID_Call) Run(run func(requestID string)) *Database_GetWorkflowRequestByID_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *Database_GetWorkflowRequestByID_Call) Return(result *db.WfRequest, err error) *Database_GetWorkflowRequestByID_Call { - _c.Call.Return(result, err) - return _c -} - -// GetWorkflowRequestsByStatus provides a mock function with given fields: status -func (_m *Database) GetWorkflowRequestsByStatus(status db.WfRequestStatus) ([]db.WfRequest, error) { - ret := _m.Called(status) - var r0 []db.WfRequest - var r1 error - if rf, ok := ret.Get(0).(func(db.WfRequestStatus) ([]db.WfRequest, error)); ok { - return rf(status) - } - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.WfRequest) - } - r1 = ret.Error(1) - return r0, r1 -} - -type Database_GetWorkflowRequestsByStatus_Call struct { - *mock.Call -} - -func (_e *Database_Expecter) GetWorkflowRequestsByStatus(status interface{}) *Database_GetWorkflowRequestsByStatus_Call { - return &Database_GetWorkflowRequestsByStatus_Call{Call: _e.mock.On("GetWorkflowRequestsByStatus", status)} -} - -func (_c *Database_GetWorkflowRequestsByStatus_Call) Run(run func(status db.WfRequestStatus)) *Database_GetWorkflowRequestsByStatus_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(db.WfRequestStatus)) - }) - return _c -} - -func (_c *Database_GetWorkflowRequestsByStatus_Call) Return(result []db.WfRequest, err error) *Database_GetWorkflowRequestsByStatus_Call { - _c.Call.Return(result, err) - return _c -} - -// CreateProcessingMap provides a mock function with given fields: pm -func (_m *Database) CreateProcessingMap(pm *db.WfProcessingMap) error { - ret := _m.Called(pm) - var r0 error - if rf, ok := ret.Get(0).(func(*db.WfProcessingMap) error); ok { - r0 = rf(pm) - } else { - r0 = ret.Error(0) - } - return r0 -} - -type Database_CreateProcessingMap_Call struct { - *mock.Call -} - -func (_e *Database_Expecter) CreateProcessingMap(pm interface{}) *Database_CreateProcessingMap_Call { - return &Database_CreateProcessingMap_Call{Call: _e.mock.On("CreateProcessingMap", pm)} -} - -func (_c *Database_CreateProcessingMap_Call) Run(run func(pm *db.WfProcessingMap)) *Database_CreateProcessingMap_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*db.WfProcessingMap)) - }) - return _c -} - -func (_c *Database_CreateProcessingMap_Call) Return(err error) *Database_CreateProcessingMap_Call { - _c.Call.Return(err) - return _c -} - -// UpdateProcessingMap provides a mock function with given fields: pm -func (_m *Database) UpdateProcessingMap(pm *db.WfProcessingMap) error { - ret := _m.Called(pm) - var r0 error - if rf, ok := ret.Get(0).(func(*db.WfProcessingMap) error); ok { - r0 = rf(pm) - } else { - r0 = ret.Error(0) - } - return r0 -} - -type Database_UpdateProcessingMap_Call struct { - *mock.Call -} - -func (_e *Database_Expecter) UpdateProcessingMap(pm interface{}) *Database_UpdateProcessingMap_Call { - return &Database_UpdateProcessingMap_Call{Call: _e.mock.On("UpdateProcessingMap", pm)} -} - -func (_c *Database_UpdateProcessingMap_Call) Run(run func(pm *db.WfProcessingMap)) *Database_UpdateProcessingMap_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*db.WfProcessingMap)) - }) - return _c -} - -func (_c *Database_UpdateProcessingMap_Call) Return(err error) *Database_UpdateProcessingMap_Call { - _c.Call.Return(err) - return _c -} - -// GetProcessingMapByKey provides a mock function with given fields: processType, processKey -func (_m *Database) GetProcessingMapByKey(processType string, processKey string) (*db.WfProcessingMap, error) { - ret := _m.Called(processType, processKey) - var r0 *db.WfProcessingMap - var r1 error - if rf, ok := ret.Get(0).(func(string, string) (*db.WfProcessingMap, error)); ok { - return rf(processType, processKey) - } - if ret.Get(0) != nil { - r0 = ret.Get(0).(*db.WfProcessingMap) - } - r1 = ret.Error(1) - return r0, r1 -} - -type Database_GetProcessingMapByKey_Call struct { - *mock.Call -} - -func (_e *Database_Expecter) GetProcessingMapByKey(processType interface{}, processKey interface{}) *Database_GetProcessingMapByKey_Call { - return &Database_GetProcessingMapByKey_Call{Call: _e.mock.On("GetProcessingMapByKey", processType, processKey)} -} - -func (_c *Database_GetProcessingMapByKey_Call) Run(run func(processType string, processKey string)) *Database_GetProcessingMapByKey_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(string)) - }) - return _c -} - -func (_c *Database_GetProcessingMapByKey_Call) Return(result *db.WfProcessingMap, err error) *Database_GetProcessingMapByKey_Call { - _c.Call.Return(result, err) - return _c -} - -// DeleteProcessingMap provides a mock function with given fields: id -func (_m *Database) DeleteProcessingMap(id uint) error { - ret := _m.Called(id) - var r0 error - if rf, ok := ret.Get(0).(func(uint) error); ok { - r0 = rf(id) - } else { - r0 = ret.Error(0) - } - return r0 -} - -type Database_DeleteProcessingMap_Call struct { - *mock.Call -} - -func (_e *Database_Expecter) DeleteProcessingMap(id interface{}) *Database_DeleteProcessingMap_Call { - return &Database_DeleteProcessingMap_Call{Call: _e.mock.On("DeleteProcessingMap", id)} -} - -func (_c *Database_DeleteProcessingMap_Call) Run(run func(id uint)) *Database_DeleteProcessingMap_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(uint)) - }) - return _c -} - -func (_c *Database_DeleteProcessingMap_Call) Return(err error) *Database_DeleteProcessingMap_Call { - _c.Call.Return(err) - return _c -} - -// GetWorkflowRequest provides a mock function with given fields: requestID -func (_m *Database) GetWorkflowRequest(requestID string) (*db.WfRequest, error) { - ret := _m.Called(requestID) - var r0 *db.WfRequest - var r1 error - if rf, ok := ret.Get(0).(func(string) (*db.WfRequest, error)); ok { - return rf(requestID) - } - if ret.Get(0) != nil { - r0 = ret.Get(0).(*db.WfRequest) - } - r1 = ret.Error(1) - return r0, r1 -} - -// UpdateWorkflowRequestStatus provides a mock function with given fields: requestID, status, responseData -func (_m *Database) UpdateWorkflowRequestStatusAndResponse(requestID string, status db.WfRequestStatus, responseData db.JSONB) error { - ret := _m.Called(requestID, status, responseData) - var r0 error - if rf, ok := ret.Get(0).(func(string, db.WfRequestStatus, db.JSONB) error); ok { - r0 = rf(requestID, status, responseData) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// GetWorkflowRequestsByWorkflowID provides a mock function with given fields: workflowID -func (_m *Database) GetWorkflowRequestsByWorkflowID(workflowID string) ([]db.WfRequest, error) { - ret := _m.Called(workflowID) - var r0 []db.WfRequest - var r1 error - if rf, ok := ret.Get(0).(func(string) ([]db.WfRequest, error)); ok { - return rf(workflowID) - } - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.WfRequest) - } - r1 = ret.Error(1) - return r0, r1 -} - -// GetPendingWorkflowRequests provides a mock function with given fields: limit -func (_m *Database) GetPendingWorkflowRequests(limit int) ([]db.WfRequest, error) { - ret := _m.Called(limit) - var r0 []db.WfRequest - var r1 error - if rf, ok := ret.Get(0).(func(int) ([]db.WfRequest, error)); ok { - return rf(limit) - } - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.WfRequest) - } - r1 = ret.Error(1) - return r0, r1 -} - -// DeleteWorkflowRequest provides a mock function with given fields: requestID -func (_m *Database) DeleteWorkflowRequest(requestID string) error { - ret := _m.Called(requestID) - var r0 error - if rf, ok := ret.Get(0).(func(string) error); ok { - r0 = rf(requestID) - } else { - r0 = ret.Error(0) - } - return r0 -} - -// GetProcessingMapsByType provides a mock function with given fields: processType -func (_m *Database) GetProcessingMapsByType(processType string) ([]db.WfProcessingMap, error) { - ret := _m.Called(processType) - var r0 []db.WfProcessingMap - var r1 error - if rf, ok := ret.Get(0).(func(string) ([]db.WfProcessingMap, error)); ok { - return rf(processType) - } - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.WfProcessingMap) - } - r1 = ret.Error(1) - return r0, r1 -} \ No newline at end of file From 3aedcb4218e6b63dfa90eaef4ac43901a0a6c450 Mon Sep 17 00:00:00 2001 From: elraphty Date: Fri, 15 Nov 2024 16:14:06 +0100 Subject: [PATCH 2/2] updated function --- db/db.go | 2 +- handlers/bounty.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/db/db.go b/db/db.go index a31db4315..1eb8689ef 100644 --- a/db/db.go +++ b/db/db.go @@ -1348,7 +1348,7 @@ func (db database) UpdateBountyPaymentStatuses(bounty NewBounty) (NewBounty, err "completion_date": bounty.CompletionDate, } - db.db.Where("created", bounty.Created).Updates(bountyUpdates) + db.db.Model(&NewBounty{}).Where("created", bounty.Created).Updates(bountyUpdates) return bounty, nil } diff --git a/handlers/bounty.go b/handlers/bounty.go index 3b4794a3c..4d3b6d028 100644 --- a/handlers/bounty.go +++ b/handlers/bounty.go @@ -1000,6 +1000,7 @@ func (h *bountyHandler) UpdateBountyPaymentStatus(w http.ResponseWriter, r *http bounty.PaymentPending = false bounty.PaymentFailed = false bounty.Paid = true + bounty.PaidDate = &now bounty.Completed = true bounty.CompletionDate = &now