speed update, new table for cached stats

This commit is contained in:
Michael Simard
2021-08-04 16:32:17 -05:00
parent c38b621bdd
commit bc0dc93e9e
11 changed files with 485 additions and 139 deletions

View File

@@ -16,7 +16,9 @@ public func configure(_ app: Application) throws {
app.http.server.configuration.hostname = "0.0.0.0"
app.http.server.configuration.port = 8080
app.commands.use(RecalulateRecords(), as: "recalc")
app.databases.use(.postgres(
hostname: Environment.get("DATABASE_HOST") ?? "localhost",
username: Environment.get("DATABASE_USERNAME") ?? "cod",
@@ -26,7 +28,8 @@ public func configure(_ app: Application) throws {
//app.migrations.add(CreateMatch())
app.migrations.add(CreateStatistics())
app.migrations.add(AddCodTrackerId())
// create a new JSON encoder that uses unix-timestamp dates
@@ -45,23 +48,11 @@ formatter.timeZone = TimeZone(secondsFromGMT: 0)
encodeFormatter.calendar = Calendar(identifier: .iso8601)
encodeFormatter.locale = Locale(identifier: "en_US_POSIX")
let date = Date()
let tz = TimeZone.current
// if tz.isDaylightSavingTime(for: date) {
// encodeFormatter.timeZone = TimeZone(abbreviation: "EST")
// }
// else{
// encodeFormatter.timeZone = TimeZone(abbreviation: "EDT")
//
// }
encodeFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
encodeFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
encoder.dateEncodingStrategy = .formatted(encodeFormatter)
// override the global encoder used for the `.json` media type
ContentConfiguration.global.use(decoder: decoder, for: .json)
// ContentConfiguration.global.use(encoder: encoder, for: .json)
// register routes
try routes(app)