updated mock sync group accordions: editing state; cancel editing
This commit is contained in:
@@ -501,7 +501,7 @@ func (db *Store) DeleteMockSyncGroup(ctx context.Context, acctID, syncGroupID in
|
||||
return nil
|
||||
}
|
||||
|
||||
func (db *Store) StartEditingMockSyncGroup(ctx context.Context, acctID, syncGroupID int64) (int64, bool, error) {
|
||||
func (db *Store) StartEditingMockSyncGroup(ctx context.Context, acctID, syncGroupID int64) (prevSyncGroupID int64, prevSyncGroupExists bool, err error) {
|
||||
rows, err := db.db.Query(
|
||||
ctx,
|
||||
`
|
||||
@@ -561,6 +561,36 @@ func (db *Store) StartEditingMockSyncGroup(ctx context.Context, acctID, syncGrou
|
||||
return v.Int64, v.Valid, nil
|
||||
}
|
||||
|
||||
func (db *Store) CancelEditingOfMockSyncGroupForAccount(ctx context.Context, acctID int64) (prevSyncGroupID int64, prevSyncGroupExists bool, err error) {
|
||||
rows, err := db.db.Query(
|
||||
ctx,
|
||||
`
|
||||
DELETE FROM
|
||||
mock.sync_group_editing
|
||||
WHERE
|
||||
account_id = @account_id
|
||||
RETURNING
|
||||
sync_group_id
|
||||
`,
|
||||
pgx.NamedArgs{
|
||||
"account_id": acctID,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return 0, false, fmt.Errorf("failed to perform query: %w", err)
|
||||
}
|
||||
|
||||
prevSyncGroupID, err = pgx.CollectExactlyOneRow(rows, pgx.RowTo[int64])
|
||||
if err != nil {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return 0, false, nil
|
||||
}
|
||||
return 0, false, fmt.Errorf("failed to scan rows: %w", err)
|
||||
}
|
||||
|
||||
return prevSyncGroupID, true, nil
|
||||
}
|
||||
|
||||
func (db *Store) MockSyncGroupIsBeingEdited(ctx context.Context, acctID, syncGroupID int64) (bool, error) {
|
||||
rows, err := db.db.Query(
|
||||
ctx,
|
||||
|
||||
Reference in New Issue
Block a user