speed update, new table for cached stats
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// Statistics.swift
|
||||
// WinLossRecords.swift
|
||||
// Statistics
|
||||
//
|
||||
// Created by Michael Simard on 8/2/21.
|
||||
@@ -8,32 +8,55 @@
|
||||
import Fluent
|
||||
import Vapor
|
||||
|
||||
final class Statistics: Model {
|
||||
final class WinLossRecords: Model, Content {
|
||||
// Name of the table or collection.
|
||||
static let schema = "statistics"
|
||||
static let schema = "win_loss_records"
|
||||
|
||||
@ID(key: .id)
|
||||
@ID(key: .id)
|
||||
var id: UUID?
|
||||
|
||||
@Field(key: "title")
|
||||
@Field(key: "title")
|
||||
var title: String
|
||||
|
||||
@Field(key: "Wins")
|
||||
@Field(key: "wins")
|
||||
var wins: Int
|
||||
|
||||
@Field(key: "losses")
|
||||
var losses: Int
|
||||
|
||||
@Field(key: "cod_tracker_id")
|
||||
var codTrackerId: String
|
||||
|
||||
|
||||
// Creates a new, empty .
|
||||
init() { }
|
||||
|
||||
// Creates a new with all properties set.
|
||||
init(id: UUID? = nil, title: String, wins: Int, losses: Int) {
|
||||
init(id: UUID? = nil, title: String, wins: Int, losses: Int, codTrackerId:String) {
|
||||
self.id = id
|
||||
self.title = title
|
||||
self.wins = wins
|
||||
self.losses = losses
|
||||
self.codTrackerId = codTrackerId
|
||||
|
||||
}
|
||||
|
||||
func update( statistics:WinLossRecords) {
|
||||
|
||||
print ("saving: \(statistics.codTrackerId)")
|
||||
guard let _ = statistics.id else {
|
||||
return
|
||||
}
|
||||
print ("saving: \(statistics)")
|
||||
|
||||
|
||||
self.id = statistics.id
|
||||
self.title = statistics.title
|
||||
self.wins = statistics.wins
|
||||
self.losses = statistics.losses
|
||||
self.codTrackerId = statistics.codTrackerId
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user