Commit 03f733bd authored by nanahira's avatar nanahira

pack

parent 9c59334f
Pipeline #665 failed with stages
in 4 minutes
......@@ -10,7 +10,7 @@ variables:
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
build:
docker:
stage: build
tags:
- docker
......@@ -18,6 +18,21 @@ build:
- docker build --pull -t $CONTAINER_TEST_IMAGE .
- docker push $CONTAINER_TEST_IMAGE
pack:
stage: build
image: node:buster-slim
tags:
- linux
dependencies: []
artifacts:
paths:
- dist/
script:
- apt update && apt -y install python3 build-essential
- npm ci
- npm run build
- npm run pack
deploy_latest:
stage: deploy
tags:
......
This diff is collapsed.
......@@ -2,9 +2,10 @@
"name": "tx3-bang-reader",
"version": "1.0.0",
"description": "Read TX3 bang and parse it",
"main": "build/fetcher.js",
"main": "build/src/run.js",
"scripts": {
"build": "./node_modules/.bin/tsc",
"pack": "mkdir dist ; ./node_modules/.bin/pkg --out-path dist .",
"fetch": "node build/src/run.js",
"start": "node build/src/run.js cron"
},
......@@ -21,6 +22,13 @@
"url": "https://github.com/purerosefallen/tx3-bang-reader/issues"
},
"homepage": "https://github.com/purerosefallen/tx3-bang-reader#readme",
"bin": "build/src/run.js",
"pkg": {
"scripts": [
"build/src/*.js"
],
"assets": []
},
"dependencies": {
"@types/cron": "^1.7.2",
"@types/csv-parse": "^1.2.2",
......@@ -32,6 +40,7 @@
"csv-parse": "^4.10.1",
"moment": "^2.27.0",
"mysql-promise": "^5.0.0",
"pkg": "^4.4.9",
"posthtml-parser": "^0.4.2",
"promise-mysql": "^4.1.3",
"querystring": "^0.2.0",
......
import mysql from "promise-mysql";
import fs from "fs";
import { Config } from "./fetcher";
import { PlayerRowFull } from "./playerlist";
import _ from "underscore";
import yaml from "yaml";
function checkSameRow(row: PlayerRowFull, lrow: PlayerRowFull) {
return _.every(["name", "category", "serverArea", "server", "region"], field => lrow[field] === row[field]);
}
async function main() {
console.error("Started.");
const config: Config = yaml.parse(await fs.promises.readFile("./config.yaml", "utf8"));
const db = await mysql.createPool(config.MySQLConfig);
const urlDataCache = new Map<string, PlayerRowFull>();
const deleteList: number[] = [];
const datas: PlayerRowFull[] = await db.query(`select * from userdata order by date asc`);
for (let row of datas) {
if (urlDataCache.has(row.url)) {
const oldRow = urlDataCache.get(row.url);
if (checkSameRow(row, oldRow)) {
deleteList.push(row.id);
}
}
urlDataCache.set(row.url, row);
}
console.error(`Deletes: ${deleteList.length}`);
for (let id of deleteList) {
const sql = `delete from userdata where id = ?`;
console.error(`Deleted: ${sql} ${id} ${JSON.stringify(await db.query(sql, id))}`);
}
console.error("Finished.");
process.exit();
}
main();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment