Compare commits

..

2 Commits

Author SHA1 Message Date
Rosalina 93b360d5b2
write fixer script 2023-03-04 19:19:22 -05:00
Rosalina a7fa1541b2
fix types 2023-03-04 19:17:19 -05:00
3 changed files with 54 additions and 5 deletions

View File

@ -69,7 +69,9 @@
"https://deno.land/x/ts_essentials@v9.1.2/mod.ts": "ffae461c16d4a1bf24c2179582ab8d5c81ad0df61e4ae2fba51ef5e5bdf90345"
},
"npm": {
"specifiers": { "mongodb": "mongodb@5.1.0" },
"specifiers": {
"mongodb": "mongodb@5.1.0"
},
"packages": {
"@types/node@18.14.2": {
"integrity": "sha512-1uEQxww3DaghA0RxqHx0O0ppVlo43pJhepY51OxuQIKHpjbnYLA7vcdwioNPzIqmC2u3I/dmylcqjlh0e7AyUA==",
@ -120,7 +122,9 @@
},
"saslprep@1.0.3": {
"integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==",
"dependencies": { "sparse-bitfield": "sparse-bitfield@3.0.3" }
"dependencies": {
"sparse-bitfield": "sparse-bitfield@3.0.3"
}
},
"smart-buffer@4.2.0": {
"integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==",
@ -135,11 +139,15 @@
},
"sparse-bitfield@3.0.3": {
"integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==",
"dependencies": { "memory-pager": "memory-pager@1.5.0" }
"dependencies": {
"memory-pager": "memory-pager@1.5.0"
}
},
"tr46@3.0.0": {
"integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==",
"dependencies": { "punycode": "punycode@2.3.0" }
"dependencies": {
"punycode": "punycode@2.3.0"
}
},
"webidl-conversions@7.0.0": {
"integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==",

View File

@ -0,0 +1,41 @@
import { MongoDB } from "../deps.ts";
import { DEFAULT_ENV } from "../src/env.ts";
import { MongoDBExporter } from "../src/exporters/mongodb.ts";
import { FileStateBackend, Profile } from "../src/state.ts";
const env = DEFAULT_ENV;
const stateBackend = new FileStateBackend("./profile.json");
const profile = new Profile({ stateBackend, env });
await profile.readState();
if (!profile.state.mongoDbUri) {
console.error("MongoDB URI not set");
Deno.exit(1);
}
const mongoDbClient = new MongoDB.MongoClient(profile.state.mongoDbUri);
const battlesCollection = mongoDbClient.db("splashcat").collection("battles");
const filter = {
"splatNetData.playedTime": {
$type: "string"
}
};
const cursor = battlesCollection.find(filter);
const oldDocuments = await battlesCollection.countDocuments(filter);
console.log(`Found ${oldDocuments} old battles to update...`);
for await (const doc of cursor) {
const { splatNetData, _id } = doc;
await battlesCollection.updateOne({ _id }, { "$set": {
"splatNetData.playedTime": new Date(splatNetData.playedTime),
}});
console.log(`Updated ${splatNetData.playedTime} to ${new Date(splatNetData.playedTime)}`);
}
console.log("Done!")

View File

@ -63,7 +63,7 @@ export class MongoDBExporter implements GameExporter {
const body:
{
data: Game,
splatNetData: VsHistoryDetail | CoopHistoryDetail,
splatNetData: Omit<(VsHistoryDetail | CoopHistoryDetail), "playedTime"> & { playedTime: Date },
gameId: string,
} & typeof common = {
...common,