-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix tests and add swipe management files
- Loading branch information
1 parent
f8724f3
commit ef60a7c
Showing
16 changed files
with
386 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package swipe_manager | ||
|
||
import ( | ||
repository "backend/graph/db" | ||
"golang.org/x/net/context" | ||
) | ||
|
||
type Def1StateStrategy struct{} | ||
|
||
func (d Def1StateStrategy) ChangeState(ctx context.Context, s *SwipeManagerUsecase, swipeRecords []repository.SwipeRecord) error { | ||
return s.changeState(ctx, userID, DEF1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package swipe_manager | ||
|
||
import ( | ||
repository "backend/graph/db" | ||
"golang.org/x/net/context" | ||
) | ||
|
||
type Def2StateStrategy struct{} | ||
|
||
func (d Def2StateStrategy) ChangeState(ctx context.Context, s *SwipeManagerUsecase, swipeRecords []repository.SwipeRecord) error { | ||
return s.changeState(ctx, userID, DEF2) | ||
} |
12 changes: 12 additions & 0 deletions
12
backend/pkg/usecases/swipe_manager/difficult_state_strategy.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package swipe_manager | ||
|
||
import ( | ||
repository "backend/graph/db" | ||
"golang.org/x/net/context" | ||
) | ||
|
||
type DifficultStateStrategy struct{} | ||
|
||
func (d DifficultStateStrategy) ChangeState(ctx context.Context, s *SwipeManagerUsecase, swipeRecords []repository.SwipeRecord) error { | ||
return s.changeState(ctx, userID, DIFFICULT) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package swipe_manager | ||
|
||
import ( | ||
repository "backend/graph/db" | ||
"golang.org/x/net/context" | ||
) | ||
|
||
type EasyStateStrategy struct{} | ||
|
||
func (e EasyStateStrategy) ChangeState(ctx context.Context, s *SwipeManagerUsecase, swipeRecords []repository.SwipeRecord) error { | ||
return s.changeState(ctx, userID, EASY) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package swipe_manager | ||
|
||
import ( | ||
repository "backend/graph/db" | ||
"golang.org/x/net/context" | ||
) | ||
|
||
type GoodStateStrategy struct{} | ||
|
||
func (g GoodStateStrategy) ChangeState(ctx context.Context, s *SwipeManagerUsecase, swipeRecords []repository.SwipeRecord) error { | ||
return s.changeState(ctx, userID, GOOD) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package swipe_manager | ||
|
||
import ( | ||
repository "backend/graph/db" | ||
"golang.org/x/net/context" | ||
) | ||
|
||
type StateStrategy interface { | ||
ChangeState(ctx context.Context, s *SwipeManagerUsecase, swipeRecords []repository.SwipeRecord) error | ||
} | ||
|
||
type StateContext struct { | ||
strategy StateStrategy | ||
} | ||
|
||
func (sc *StateContext) SetStrategy(strategy StateStrategy) { | ||
sc.strategy = strategy | ||
} | ||
|
||
func (sc *StateContext) ExecuteStrategy(ctx context.Context, s *SwipeManagerUsecase, swipeRecords []repository.SwipeRecord) ([]repository.Card, error) { | ||
sc.strategy.ChangeState(ctx, s, swipeRecords) | ||
return nil, nil | ||
} |
Oops, something went wrong.