-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from cocoaheadsru/task/devops/generate-test-da…
…taset Pre-release PR (changed endpoints, created stage samples, refactored photo, VK - issues solved)
- Loading branch information
Showing
70 changed files
with
918 additions
and
308 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
Sources/App/Common/Extensions/Foundation/FileManager/FileManger+RemoveFiles.swift
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,31 @@ | ||
import Foundation | ||
|
||
extension FileManager { | ||
|
||
func removeAllFiles(atPath: String) throws { | ||
|
||
guard fileExists(atPath: atPath) else { | ||
return | ||
} | ||
|
||
try contentsOfDirectory(atPath: atPath).forEach { filename in | ||
let filePathToRemove = atPath + filename | ||
try removeItem(atPath: filePathToRemove) | ||
} | ||
|
||
} | ||
|
||
func removeAllFiles(at dir: URL) throws { | ||
|
||
guard fileExists(atPath: dir.path) else { | ||
return | ||
} | ||
|
||
try contentsOfDirectory(atPath: dir.path).forEach { filename in | ||
let filePathToRemove = dir.appendingPathComponent(filename) | ||
try removeItem(at: filePathToRemove) | ||
} | ||
|
||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
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,65 @@ | ||
import Foundation | ||
|
||
//swiftlint:disable superfluous_disable_command | ||
//swiftlint:disable force_try | ||
extension Samples { | ||
|
||
func truncateTables() throws { | ||
|
||
var tableList: [String]? | ||
|
||
var tableForTruncate: [String] { | ||
|
||
if tableList != nil { | ||
return tableList! | ||
} | ||
|
||
let db = try! drop.assertDatabase() | ||
// swiftlint:disable force_try | ||
guard let nodes = try! db.driver.makeConnection(.read).raw("SHOW TABLES;").array else { | ||
return [] | ||
} | ||
|
||
let jsons = nodes.map { node -> JSON in | ||
return JSON(node: node) | ||
} | ||
|
||
let dbName = drop.config["mysql", "database"]?.string ?? "" | ||
tableList = jsons | ||
.map { json -> String in | ||
json["Tables_in_\(dbName)"]?.string ?? "" | ||
} | ||
.filter { table -> Bool in | ||
table != "social" && | ||
table != "fluent" | ||
} | ||
|
||
return tableList! | ||
} | ||
|
||
guard drop.config.environment == .development else { | ||
return | ||
} | ||
|
||
let db = try! drop.assertDatabase() | ||
|
||
defer { | ||
// swiftlint:disable force_try | ||
try! db.raw("SET FOREIGN_KEY_CHECKS = 1;") | ||
print("Foreign key checks ON\n") | ||
} | ||
|
||
try! db.raw("SET FOREIGN_KEY_CHECKS = 0;") | ||
print("\nForeign key checks OFF") | ||
|
||
var truncatedTableCount = 0 | ||
|
||
tableForTruncate.forEach { (table) in | ||
try! db.raw("TRUNCATE \(table)") | ||
truncatedTableCount += 1 | ||
} | ||
|
||
print("Truncate table(s): \(truncatedTableCount)") | ||
|
||
} | ||
} |
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,27 @@ | ||
import Vapor | ||
|
||
//swiftlint:disable superfluous_disable_command | ||
//swiftlint:disable force_try | ||
extension Samples { | ||
|
||
func createCreatorSample() throws { | ||
|
||
func createCreator(user: User) throws { | ||
|
||
let creator = Creator( | ||
userId: user.id!, | ||
position: user.id!.int!, | ||
info: String.randomValue, | ||
url: String.randomURL, | ||
active: Bool.randomValue | ||
) | ||
|
||
try creator.save() | ||
} | ||
|
||
try createUserSample(count: 10).forEach { user in | ||
try createCreator(user: user) | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.