Skip to content

Commit

Permalink
Merge pull request #3 from MatsMoll/feature/improvments
Browse files Browse the repository at this point in the history
Feature/improvments
  • Loading branch information
MatsMoll authored Dec 4, 2019
2 parents 93e4ad7 + ca38f93 commit 328f51d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 265 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
POSTGRES_DB: postgres
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v1.2.0
- name: Run unit tests
run: |
apt-get -qq update && apt-get install -y \
Expand Down
259 changes: 0 additions & 259 deletions Package.resolved

This file was deleted.

10 changes: 9 additions & 1 deletion Sources/App/Practice Session/PracticeSessionWebController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class PracticeSessionWebController: RouteCollection {
router.get("practice-sessions/history", use: getSessions)
}

func renderCurrentTask(on req: Request) throws -> Future<HTTPResponse> {
func renderCurrentTask(on req: Request) throws -> Future<Response> {

let user = try req.requireAuthenticated(User.self)

Expand All @@ -40,6 +40,14 @@ final class PracticeSessionWebController: RouteCollection {
.taskAt(index: index, on: conn)
.flatMap { task in
try task.render(in: session, index: index, for: user, on: req)
.encode(for: req)
}
.catchFlatMap { _ in
try PracticeSession.Repository
.end(session, for: user, on: conn)
.map { _ in
try req.redirect(to: "/practice-sessions/\(session.requireID())/result")
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/App/Topic/TopicWebController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ final class TopicWebController: RouteCollection {
.flatMap { subject in

try Topic.Repository
.getTopics(in: subject, conn: req)
.getTopicsWithTaskCount(in: subject, conn: req)
.flatMap { topics in

req.withPooledConnection(to: .psql) { conn in

try TaskResultRepository
.getUserLevel(for: user.requireID(), in: topics.map { try $0.requireID() }, on: conn)
.getUserLevel(for: user.requireID(), in: topics.map { try $0.0.requireID() }, on: conn)
.flatMap { levels in

try TaskResultRepository
Expand Down
3 changes: 1 addition & 2 deletions Tests/AppTests/MultipleChoiseTaskTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import KognitaCore
import KognitaCoreTestable

class MultipleChoiseTaskTests: VaporTestCase {



// GET /subjects/:id/topics/:id/multiple-choises

func testGetAllTasks() throws {
Expand Down
2 changes: 2 additions & 0 deletions test-on-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker build -t test -f test.dockerfile .
docker run test
11 changes: 11 additions & 0 deletions test.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM swift:5.1.2-bionic

WORKDIR /package

COPY . ./

RUN apt-get -qq update && apt-get install -y \
libssl-dev zlib1g-dev \
&& rm -r /var/lib/apt/lists/*
RUN swift package clean
CMD swift test

0 comments on commit 328f51d

Please sign in to comment.