-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat:新增暂停功能 (#416) * feat:新增暂停功能 * feat: 修改状态相关功能 (#433) Co-authored-by: luchunhui <[email protected]> * fix: 修改刷数据逻辑错误和环境变量问题 * fix: 解决lint问题 --------- Co-authored-by: chaorenluo <[email protected]> Co-authored-by: luchunhui <[email protected]>
- Loading branch information
1 parent
054095e
commit 351f18f
Showing
110 changed files
with
1,287 additions
and
525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Important Disclosure re:XIAOJUSURVEY Data Collection | ||
|
||
XIAOJUSURVEY is open-source software developed and maintained by XIAOJUSURVEY Team and available at https://github.com/didi/xiaoju-survey. | ||
We hereby state the purpose and reason for collecting data. | ||
|
||
## Purpose of data collection | ||
|
||
Data collected is used to help improve XIAOJUSURVEY for all users. It is important that our team understands the usage patterns as soon as possible, so we can best decide how to design future features and prioritize current work. | ||
|
||
## Types of data collected | ||
|
||
XIAOJUSURVEY just collects data about version's information. The data collected is subsequently reported to the XIAOJUSURVEY's backend services. | ||
|
||
All data collected will be used exclusively by the XIAOJUSURVEY team for analytical purposes only. The data will be neither accessible nor sold to any third party. | ||
|
||
## Sensitive data | ||
|
||
XIAOJUSURVEY will never collect and/or report sensitive information, such as private keys, API keys, or passwords. | ||
|
||
## How do I opt-in to or opt-out of data sharing? | ||
|
||
See [docs](https://xiaojusurvey.didi.cn/docs/next/community/%E6%95%B0%E6%8D%AE%E4%B8%8A%E6%8A%A5%E5%A3%B0%E6%98%8E) for information on configuring this functionality. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
XIAOJU_SURVEY_MONGO_DB_NAME=xiaojuSurvey | ||
XIAOJU_SURVEY_MONGO_URL=mongodb://127.0.0.1:27017 | ||
XIAOJU_SURVEY_MONGO_AUTH_SOURCE=admin | ||
|
||
XIAOJU_SURVEY_REDIS_HOST= | ||
XIAOJU_SURVEY_REDIS_PORT= | ||
XIAOJU_SURVEY_REDIS_USERNAME= | ||
XIAOJU_SURVEY_REDIS_PASSWORD= | ||
XIAOJU_SURVEY_REDIS_DB= | ||
|
||
|
||
XIAOJU_SURVEY_RESPONSE_AES_ENCRYPT_SECRET_KEY=dataAesEncryptSecretKey | ||
XIAOJU_SURVEY_HTTP_DATA_ENCRYPT_TYPE=rsa | ||
|
||
XIAOJU_SURVEY_JWT_SECRET=xiaojuSurveyJwtSecret | ||
XIAOJU_SURVEY_JWT_EXPIRES_IN=8h | ||
|
||
XIAOJU_SURVEY_LOGGER_FILENAME=./logs/app.log | ||
|
||
XIAOJU_SURVEY_REPORT=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import fs, { promises as fsa } from 'fs-extra'; | ||
import path from 'path'; | ||
import fetch from 'node-fetch'; | ||
|
||
interface PackageJson { | ||
type?: string; | ||
name?: string; | ||
version?: string; | ||
description?: string; | ||
id?: string; | ||
msg?: string; | ||
} | ||
|
||
const getId = () => { | ||
const id = new Date().getTime().toString(); | ||
process.env.XIAOJU_SURVEY_REPORT_ID = id; | ||
|
||
return id; | ||
}; | ||
|
||
const readData = async (directory: string): Promise<PackageJson | null> => { | ||
const packageJsonPath = path.join(directory, 'package.json'); | ||
const id = process.env.XIAOJU_SURVEY_REPORT_ID || getId(); | ||
try { | ||
if (!fs.existsSync(directory)) { | ||
return { | ||
type: 'server', | ||
name: '', | ||
version: '', | ||
description: '', | ||
id, | ||
msg: '文件不存在', | ||
}; | ||
} | ||
const data = await fsa.readFile(packageJsonPath, 'utf8').catch((e) => e); | ||
const { name, version, description } = JSON.parse(data) as PackageJson; | ||
return { type: 'server', name, version, description, id }; | ||
} catch (error) { | ||
return error; | ||
} | ||
}; | ||
|
||
(async (): Promise<void> => { | ||
if ( | ||
process.env.NODE_ENV === 'development' && | ||
!process.env.XIAOJU_SURVEY_REPORT | ||
) { | ||
return; | ||
} | ||
|
||
const res = await readData(path.join(process.cwd())); | ||
|
||
// 上报 | ||
fetch('https://xiaojusurveysrc.didi.cn/reportSourceData', { | ||
method: 'POST', | ||
headers: { | ||
Accept: 'application/json, */*', | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(res), | ||
}).catch(() => {}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export enum DOWNLOAD_TASK_STATUS { | ||
WAITING = 'waiting', // 排队中 | ||
COMPUTING = 'computing', // 计算中 | ||
SUCCEED = 'succeed', // 导出成功 | ||
FAILED = 'failed', // 导出失败 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum SESSION_STATUS { | ||
ACTIVATED = 'activated', | ||
DEACTIVATED = 'deactivated', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,13 @@ | ||
import { Column, ObjectIdColumn, BeforeInsert, BeforeUpdate } from 'typeorm'; | ||
import { ObjectIdColumn, CreateDateColumn, UpdateDateColumn } from 'typeorm'; | ||
import { ObjectId } from 'mongodb'; | ||
import { RECORD_STATUS } from '../enums'; | ||
|
||
export class BaseEntity { | ||
@ObjectIdColumn() | ||
_id: ObjectId; | ||
|
||
@Column() | ||
curStatus: { | ||
status: RECORD_STATUS; | ||
date: number; | ||
}; | ||
@CreateDateColumn({ type: 'timestamp', precision: 3 }) | ||
createdAt: Date; | ||
|
||
@Column() | ||
statusList: Array<{ | ||
status: RECORD_STATUS; | ||
date: number; | ||
}>; | ||
|
||
@Column() | ||
createDate: number; | ||
|
||
@Column() | ||
updateDate: number; | ||
|
||
@BeforeInsert() | ||
initDefaultInfo() { | ||
const now = Date.now(); | ||
if (!this.curStatus) { | ||
const curStatus = { status: RECORD_STATUS.NEW, date: now }; | ||
this.curStatus = curStatus; | ||
this.statusList = [curStatus]; | ||
} | ||
this.createDate = now; | ||
this.updateDate = now; | ||
} | ||
|
||
@BeforeUpdate() | ||
onUpdate() { | ||
this.updateDate = Date.now(); | ||
} | ||
@UpdateDateColumn({ type: 'timestamp', precision: 3 }) | ||
updatedAt: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.