Browse Source

算力积分

tags/v1.22.9.2^2
chenshihai 3 years ago
parent
commit
77cdc92ef4
5 changed files with 191 additions and 40 deletions
  1. +117
    -0
      templates/reward/point/rule.tmpl
  2. +3
    -2
      web_src/vuepages/pages/reward/point/const.js
  3. +63
    -17
      web_src/vuepages/pages/reward/point/utils.js
  4. +0
    -1
      web_src/vuepages/pages/reward/point/vp-point.js
  5. +8
    -20
      web_src/vuepages/pages/reward/point/vp-point.vue

+ 117
- 0
templates/reward/point/rule.tmpl View File

@@ -0,0 +1,117 @@
{{template "base/head_home" .}}
<style>
.m-table {
width: 100%;
}
.m-table th {
border: 1px solid #EBEEF5;
padding: 8px 10px;
background-color: #f5f5f6;
}
.m-table td {
border: 1px solid #EBEEF5;
padding: 8px 10px;
}
.t-center {
text-align: center;
}
</style>
<div class="ui container">
<h1 class="ui center am-pt-30 am-pb-20">个人算力积分奖励规则</h1>
<div class="ui divider am-pb-10"></div>
<p>说明:单日用户积分的获取上限为50分。</p>
<table class="m-table">
<tr>
<th style="width:200px;">奖励名称</th>
<th style="width:180px;">获取积分值</th>
<th style="width:200px;">上限值</th>
<th>奖励细节澄清</th>
</tr>
<tr>
<td class="t-center">完成微信扫码验证</td>
<td class="t-center">50</td>
<td class="t-center">累计积分获取上限50</td>
<td>1、首次完成微信扫码验证,即获取50积分。<br>2、同个账号,更换微信号码再验证不重复给积分。<br>3、同一个微信,绑定第一个账号时奖励50分,下次绑定其他账号时不再奖励。</td>
</tr>
<tr>
<td class="t-center">每日首次Fork项目</td>
<td class="t-center">1</td>
<td class="t-center">每日积分获取上限1</td>
<td></td>
</tr>
<tr>
<td class="t-center">创建公开项目</td>
<td class="t-center">1</td>
<td class="t-center">每日积分获取上限3</td>
<td>请注意项目质量,请勿复制粘贴或者重复公开项目,任何非常规的以公开项目去获取积分的行为将被认定为积分舞弊,将扣除所有积分。</td>
</tr>
<tr>
<td class="t-center">每日提出PR</td>
<td class="t-center">1</td>
<td class="t-center">每日积分获取上限3</td>
<td></td>
</tr>
<tr>
<td class="t-center">每日commit</td>
<td class="t-center">1</td>
<td class="t-center">每日积分获取上限3</td>
<td>通过前台界面和后台命令行方式commit,都可获得奖励积分。</td>
</tr>
<tr>
<td class="t-center">每日提出任务</td>
<td class="t-center">1</td>
<td class="t-center">每日积分获取上限3</td>
<td></td>
</tr>
<tr>
<td class="t-center">发表评论</td>
<td class="t-center">1</td>
<td class="t-center">每日积分获取上限2</td>
<td>禁止空评论或评论后马上删除等非正常获取积分的方式,一经发现将扣除所有积分。</td>
</tr>
<tr>
<td class="t-center">上传数据集文件</td>
<td class="t-center">1</td>
<td class="t-center">每日积分获取上限1</td>
<td>请注意数据集质量,请勿复制粘贴或者重复公开数据集,任何非常规的以公开数据集去获取积分的行为将被认定为积分舞弊,将扣除所有积分。</td>
</tr>
<tr>
<td class="t-center">数据集被平台推荐</td>
<td class="t-center">5</td>
<td class="t-center">每日积分获取上限15</td>
<td>仅统计属于个人的数据集,属于组织的数据集暂不统计。</td>
</tr>
<tr>
<td class="t-center">导入新模型</td>
<td class="t-center">1</td>
<td class="t-center">每日积分获取上限3</td>
<td>请注意模型质量,请勿重复导入相同模型,任何非常规的以导入新模型去获取 积分的行为将被认定为积分舞弊,将扣除所有积分。</td>
</tr>
<tr>
<td class="t-center">每日运行云脑任务</td>
<td class="t-center">10</td>
<td class="t-center">每日积分获取上限10</td>
<td> 每日运行调试、训练、推理、评测中任何一种任务,即可获得。</td>
</tr>
<tr>
<td class="t-center">提交新公开镜像</td>
<td class="t-center">1</td>
<td class="t-center">每日积分获取上限3</td>
<td></td>
</tr>
<tr>
<td class="t-center">镜像被平台推荐</td>
<td class="t-center">5</td>
<td class="t-center">每日积分获取上限15</td>
<td></td>
</tr>
<tr>
<td class="t-center">首次更换头像</td>
<td class="t-center">2</td>
<td class="t-center">累计积分获取上限2</td>
<td>首次更换头像,积分+2。</td>
</tr>
</table>

</div>
{{template "base/footer" .}}

+ 3
- 2
web_src/vuepages/pages/reward/point/const.js View File

@@ -1,6 +1,7 @@
export const SOURCE_TYPE = [{ k: 'ACCOMPLISH_TASK', v: '积分任务' }, { k: 'ADMIN_OPERATE', v: '管理员操作' }, { k: 'RUN_CLOUDBRAIN_TASK', v: '运行云脑任务' }];
export const CONSUME_STATUS = [{ k: 'OPERATING', v: '进行中' }, { k: 'SUCCEEDED', v: '已完成' }];
export const POINT_ACTIONS = [
{ k: 1, v: '创建公开项目' }, { k: 6, v: '每日提出任务' }, { k: 7, v: '每日提出PR' }, { k: 10, v: '发表评论' }, { k: 24, v: '上传数据集文件' }, { k: 30, v: '导入新模型' }, { k: 32, v: '完成微信扫码验证' },
{ k: 33, v: '每日运行云脑任务' }, { k: 34, v: '数据集被平台推荐' }, { k: 35, v: '提交新公开镜像' }, { k: 36, v: '镜像被平台推荐' }, { k: 37, v: '首次更换头像' }, { k: 38, v: '每日commit' }, { k: 39, v: '每日首次Fork项目' },
{ k: 1, v: '创建公开项目' }, { k: 6, v: '每日提出任务' }, { k: 7, v: '每日提出PR' }, { k: 10, v: '发表评论' }, { k: 24, v: '上传数据集文件' }, { k: 30, v: '导入新模型' }, { k: 34, v: '完成微信扫码验证' },
{ k: 35, v: '每日运行云脑任务' }, { k: 36, v: '数据集被平台推荐' }, { k: 37, v: '提交新公开镜像' }, { k: 38, v: '镜像被平台推荐' }, { k: 39, v: '首次更换头像' }, { k: 40, v: '每日commit' }, { k: 41, v: '每日首次Fork项目' },
];
export const JOB_TYPE = [{ k: 'DEBUG', v: '调试任务' }, { k: 'TRAIN', v: '训练任务' }, { k: 'INFERENCE', v: '推理任务' }, { k: 'BENCHMARK', v: '评测任务' }];

+ 63
- 17
web_src/vuepages/pages/reward/point/utils.js View File

@@ -1,24 +1,63 @@

import { formatDate } from 'element-ui/lib/utils/date-util';
import { SOURCE_TYPE, CONSUME_STATUS, POINT_ACTIONS } from './const';
import { SOURCE_TYPE, CONSUME_STATUS, POINT_ACTIONS, JOB_TYPE } from './const';

const getSourceType = (key) => {
const find = SOURCE_TYPE.filter(item => item.k === key);
return find.length ? find[0].v : key;
};

const getConsumeStatus = (key) => {
const find = CONSUME_STATUS.filter(item => item.k === key);
return find.length ? find[0].v : key;
};

const getPointAction = (key) => {
const find = POINT_ACTIONS.filter(item => item.k === key);
return find.length ? find[0].v : key;
};

const getJobType = (key) => {
const find = JOB_TYPE.filter(item => item.k === key);
return find.length ? find[0].v : key;
};

const getJobTypeLink = (record, type) => {
let link = type === 'INCREASE' ? record.Action.RepoLink : '/' + record.Cloudbrain.RepoFullName;
const cloudbrain = type === 'INCREASE' ? record.Action?.Cloudbrain : record.Cloudbrain;
switch (cloudbrain?.JobType) {
case 'DEBUG':
if (cloudbrain.ComputeResource === 'CPU/GPU') {
link += `/cloudbrain/${cloudbrain.ID}`;
} else {
link += `/modelarts/notebook/${cloudbrain.ID}`;
}
break;
case 'TRAIN':
if (cloudbrain.Type === 1) {
link += `/modelarts/train-job/${cloudbrain.ID}`;
} else if (cloudbrain.Type === 0) {
link += `/cloudbrain/train-job/${cloudbrain.ID}`;
} else if (cloudbrain.Type === 2) {
link += `/grampus/train-job/${cloudbrain.ID}`;
}
break;
case 'INFERENCE':
link += `/modelarts/inference-job/${cloudbrain.ID}`;
break;
case 'BENCHMARK':
link += `/cloudbrain/benchmark/${cloudbrain.ID}`;
break;
default:
break;
};
return link;
};

export const getRewardPointRecordInfo = (record) => {
const out = {
sn: record.SerialNo,
date: formatDate(new Date(record.LastOperateDate * 1000), 'yyyy-MM-DD HH:mm:ss'),
date: formatDate(new Date(record.LastOperateDate * 1000), 'yyyy-MM-dd HH:mm:ss'),
_status: record.Status,
status: getConsumeStatus(record.Status) || '--',
statusColor: record.Status === 'OPERATING' ? 'rgb(33, 186, 69)' : '',
@@ -52,46 +91,53 @@ export const getRewardPointRecordInfo = (record) => {
out.remark = `上传了数据集文件<a href="${record.Action.RepoLink}/datasets" rel="nofollow">${record.Action.RefName}</a>`;
break;
case 30: // 导入新模型 - 导入了新模型resnet50_qx7l
out.remark = '导入了新模型{{}}';
break;
case 32: // 完成微信扫码验证 - 首次绑定微信奖励
case 34: // 完成微信扫码验证 - 首次绑定微信奖励
out.remark = '首次绑定微信奖励';
break;
case 33: // 每日运行云脑任务 - 创建了(CPU/GPU/NPU)类型(调试/训练/推理/评测)任务tangl202204131431995
out.remark = `创建了{{}}类型{{}}任务<a href="${record.Action.RepoLink}/cloudbrain/${record.Action.Content}" rel="nofollow">${record.Action.RefName}</a>`;
case 35: // 每日运行云脑任务 - 创建了(CPU/GPU/NPU)类型(调试/训练/推理/评测)任务tangl202204131431995
out.remark = `创建了${record.Action?.Cloudbrain?.ComputeResource}类型${getJobType(record.Action?.Cloudbrain?.JobType)}<a href="${getJobTypeLink(record, 'INCREASE')}" rel="nofollow">${record.Action.RefName}</a>`;
break;
case 34: // 数据集被平台推荐 - 数据集XXX被设置为推荐数据集
out.remark = `数据集<a href="${record.Action.RepoLink}/datasets" rel="nofollow">${record.Action.RefName}</a>被设置为推荐数据集`;
case 36: // 数据集被平台推荐 - 数据集XXX被设置为推荐数据集
out.remark = `数据集<a href="${record.Action.RepoLink}/datasets" rel="nofollow">${record.Action.Content && record.Action.Content.split('|')[1]}</a>被设置为推荐数据集`;
break;
case 35: // 提交新公开镜像 - 提交了镜像jiangxiang_ceshi_tang03
out.remark = `提交了镜像${record.Action.RefName}`;
case 37: // 提交新公开镜像 - 提交了镜像jiangxiang_ceshi_tang03
out.remark = `提交了镜像<span style="font-weight:bold;">${record.Action.Content && record.Action.Content.split('|')[1]}</span>`;
break;
case 36: // 镜像被平台推荐 - 镜像XXX被设置为推荐镜像
out.remark = `镜像${record.Action.RefName}被设置为推荐镜像`;
case 38: // 镜像被平台推荐 - 镜像XXX被设置为推荐镜像
out.remark = `镜像<span style="font-weight:bold;">${record.Action.Content && record.Action.Content.split('|')[1]}</span>被设置为推荐镜像`;
break;
case 37: // 首次更换头像 - 更新了头像
case 39: // 首次更换头像 - 更新了头像
out.remark = '更新了头像';
break;
case 38: // 每日commit - 推送了xxxx分支的代码到OpenI/aiforge
case 40: // 每日commit - 推送了xxxx分支的代码到OpenI/aiforge
const words = record.Action.RefName.split('/');
const branch = words[words.length - 1];
out.remark = `推送了<a href="${record.Action.RepoLink}/src/branch/${branch}" rel="nofollow">${branch}</a>分支的代码到<a href="${record.Action.RepoLink}" rel="nofollow">${record.Action.ShortRepoFullDisplayName}</a>`;
break;
case 39: // 每日首次Fork项目 - 创建了项目OpenI/fork_aiforge
case 41: // 每日首次Fork项目 - 创建了项目OpenI/fork_aiforge
out.remark = `创建了项目<a href="${record.Action.RepoLink}" rel="nofollow">${record.Action.ShortRepoFullDisplayName}</a>`;
break;
default:
break;
}
} else if (record.SourceType === 'RUN_CLOUDBRAIN_TASK') {
//
}
} else if (record.OperateType === 'DECREASE') {
if (record.SourceType === 'ADMIN_OPERATE') {
out.remark = record.Remark;
} else if (record.SourceType === 'ACCOMPLISH_TASK') {
//
} else if (record.SourceType === 'RUN_CLOUDBRAIN_TASK') {

out.taskName = `<a href="${getJobTypeLink(record, 'DECREASE')}" rel="nofollow">${record?.Cloudbrain?.DisplayJobName}</a>`;
if (record?.Cloudbrain?.ComputeResource === 'CPU/GPU') {
const resourceSpec = record?.Cloudbrain?.ResourceSpec?.ResourceSpec;
out.remark = `【${getJobType(record?.Cloudbrain?.JobType)}】【${record?.Cloudbrain?.ComputeResource}】【GPU: ${resourceSpec?.gpu}, CPU: ${resourceSpec?.cpu}, 内存: ${(resourceSpec?.memMiB / 1024).toFixed(2)}GB, 共享内存: ${(resourceSpec?.shareMemMiB / 1024).toFixed(2)}GB】`;
} else {
out.remark = `【${getJobType(record?.Cloudbrain?.JobType)}】【${record?.Cloudbrain?.ComputeResource}】【${record?.Cloudbrain?.ResourceSpec.FlavorInfo.desc}】`;
}
}
}
return out;


+ 0
- 1
web_src/vuepages/pages/reward/point/vp-point.js View File

@@ -4,7 +4,6 @@ import 'element-ui/lib/theme-chalk/index.css';

Vue.use(ElementUI);
import App from './vp-point.vue';
// import App from '../manage/vp-point-manage.vue';

new Vue({
el: '#__vue-root',


+ 8
- 20
web_src/vuepages/pages/reward/point/vp-point.vue View File

@@ -6,12 +6,10 @@
<p class="__title">算力积分明细</p>
</div>
<div style="padding: 0 5px; font-size: 14px">
<el-button @click="operatePoint(1)">+</el-button>
<el-button @click="operatePoint(0)">-</el-button>
<span>
<i class="question circle icon link" style="color: rgba(3, 102, 214, 1)" data-position="right center"
data-variation="mini"></i>
<a href="" target="_blank" style="color: rgba(3, 102, 214, 1)">积分获取说明</a>
<a href="/reward/point/rule" target="_blank" style="color: rgba(3, 102, 214, 1)">积分获取说明</a>
</span>
</div>
</div>
@@ -78,13 +76,17 @@
<el-table-column column-key="sourceType" prop="sourceType" label="场景" align="center" header-align="center"
width="180"></el-table-column>
<el-table-column column-key="duration" prop="duration" label="运行时长" align="center" header-align="center"
width="150"></el-table-column>
width="120"></el-table-column>
<el-table-column column-key="remark" prop="remark" label="说明" align="left" header-align="center">
<template slot-scope="scope">
<span v-html="scope.row.remark"></span>
</template>
</el-table-column>
<el-table-column column-key="taskName" prop="taskName" label="任务名称" align="center" header-align="center">
<el-table-column column-key="taskName" prop="taskName" label="任务名称" align="center" header-align="center"
width="180">
<template slot-scope="scope">
<span v-html="scope.row.taskName"></span>
</template>
</el-table-column>
<el-table-column column-key="amount" prop="amount" label="积分" align="center" header-align="center"
width="120"></el-table-column>
@@ -109,8 +111,7 @@
</template>

<script>
import { formatDate } from 'element-ui/lib/utils/date-util';
import { getPoint, getPointAccount, getPointList, setPointOperate } from "../../../apis/modules/point";
import { getPoint, getPointAccount, getPointList } from "../../../apis/modules/point";
import { getRewardPointRecordInfo } from './utils';
export default {
data() {
@@ -184,19 +185,6 @@ export default {
this.tableData.splice(0, Infinity);
});
},
operatePoint: function (type) {
setPointOperate({
TargetUserId: 369,
OperateType: type === 1 ? 'INCREASE' : 'DECREASE',
Amount: 1,
Remark: 'Remark: ' + (type === 1 ? 'INCREASE' : 'DECREASE') + ' 1.',
RewardType: 'POINT',
}).then(res => {
console.log(res);
}).catch(err => {
console.log(err);
})
}
},
mounted: function () {
this.getSummaryInfo();


Loading…
Cancel
Save