测试环境开箱和探索不在检查链上记录
This commit is contained in:
parent
c45c4c5bf4
commit
084f8d195a
@ -16,6 +16,7 @@
|
||||
"repairdata2": "ts-node -r tsconfig-paths/register src/repairdata2.ts",
|
||||
"repairredis": "ts-node -r tsconfig-paths/register src/repairredis.ts",
|
||||
"checkredis": "ts-node -r tsconfig-paths/register src/checkredis.ts",
|
||||
"additem": "ts-node -r tsconfig-paths/register src/addboxdata.ts",
|
||||
"test:watch": "jest --watch",
|
||||
"test": "jest"
|
||||
},
|
||||
|
43
src/addboxdata.ts
Normal file
43
src/addboxdata.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import mongoose from 'mongoose'
|
||||
import * as dotenv from 'dotenv'
|
||||
|
||||
const envFile = process.env.NODE_ENV && process.env.NODE_ENV === 'production' ? `.env.production` : '.env.development'
|
||||
dotenv.config({ path: envFile })
|
||||
console.log(process.env.DB_MAIN)
|
||||
import { ActivityChest } from 'models/ActivityChest'
|
||||
import { ScoreRecord } from 'models/ScoreRecord'
|
||||
import { DeleteRecord } from 'models/DeleteRecord'
|
||||
import { rankKey, updateRank, updateRankInvite } from 'services/rank.svr'
|
||||
import { ZRedisClient } from 'zutils'
|
||||
import { RANK_SCORE_SCALE } from 'common/Constants'
|
||||
import { uuid } from 'zutils/utils/security.util'
|
||||
const db = mongoose.connection
|
||||
|
||||
const totalKey = 'uaw_activity:score'
|
||||
const keyInvite = `uaw_activity:invite`
|
||||
|
||||
const addItem = async (key, item) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
new ZRedisClient().pub.sadd(key, item, () => {
|
||||
resolve(true)
|
||||
})
|
||||
})
|
||||
}
|
||||
;(async () => {
|
||||
try {
|
||||
let opts = { url: process.env.REDIS }
|
||||
new ZRedisClient(opts)
|
||||
for (let i = 0; i < 10; i++) {
|
||||
let id = uuid()
|
||||
await addItem('chest_bonus_1', id)
|
||||
}
|
||||
for (let i = 0; i < 100; i++) {
|
||||
let id = uuid()
|
||||
await addItem('chest_bonus_2', id)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
console.log('end')
|
||||
process.exit(0)
|
||||
})()
|
@ -320,9 +320,11 @@ class BoxController extends BaseController {
|
||||
if (!isObjectIdString(chestId)) {
|
||||
throw new ZError(11, 'must provide valid chestId')
|
||||
}
|
||||
const openRecord = await ChestRecord.findOne({ from: user.address.toLowerCase(), chestId })
|
||||
if (!openRecord) {
|
||||
throw new ZError(12, 'onchain open record not found')
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
const openRecord = await ChestRecord.findOne({ from: user.address.toLowerCase(), chestId })
|
||||
if (!openRecord) {
|
||||
throw new ZError(12, 'onchain open record not found')
|
||||
}
|
||||
}
|
||||
const chest = await ActivityChest.findById(chestId)
|
||||
if (!chest) {
|
||||
|
@ -352,13 +352,15 @@ class GameController extends BaseController {
|
||||
if (!isObjectId(id)) {
|
||||
throw new ZError(12, 'invalid id')
|
||||
}
|
||||
const chainRecord = await GeneralScription.findOne({
|
||||
from: user.address.toLowerCase(),
|
||||
op: 'explore',
|
||||
data: id,
|
||||
})
|
||||
if (!chainRecord) {
|
||||
throw new ZError(13, 'waiting for chain confirm')
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
const chainRecord = await GeneralScription.findOne({
|
||||
from: user.address.toLowerCase(),
|
||||
op: 'explore',
|
||||
data: id,
|
||||
})
|
||||
if (!chainRecord) {
|
||||
throw new ZError(13, 'waiting for chain confirm')
|
||||
}
|
||||
}
|
||||
const exploreRecord = await ExploreRecord.findById(id)
|
||||
if (!exploreRecord) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user