오류 수정, 통계 보강
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('../config/database');
|
||||
|
||||
const AverageCache = sequelize.define('AverageCache', {
|
||||
id: {
|
||||
type: DataTypes.BIGINT.UNSIGNED,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
comment: '캐시 고유값'
|
||||
},
|
||||
memberId: {
|
||||
type: DataTypes.INTEGER.UNSIGNED,
|
||||
allowNull: false,
|
||||
comment: '회원 ID'
|
||||
},
|
||||
clubId: {
|
||||
type: DataTypes.INTEGER.UNSIGNED,
|
||||
allowNull: false,
|
||||
comment: '클럽 ID'
|
||||
},
|
||||
startDate: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
comment: '계산 시작일'
|
||||
},
|
||||
endDate: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
comment: '계산 종료일'
|
||||
},
|
||||
average: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: false,
|
||||
comment: '에버리지'
|
||||
},
|
||||
games: {
|
||||
type: DataTypes.INTEGER.UNSIGNED,
|
||||
allowNull: false,
|
||||
comment: '경기수'
|
||||
},
|
||||
totalScore: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
comment: '총점'
|
||||
},
|
||||
expiredAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
comment: '만료 시각(TTL)'
|
||||
}
|
||||
}, {
|
||||
tableName: 'AverageCache',
|
||||
comment: '회원별 기간별 에버리지 캐시 테이블',
|
||||
timestamps: true,
|
||||
indexes: [
|
||||
{
|
||||
unique: true,
|
||||
fields: ['memberId', 'clubId', 'startDate', 'endDate']
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
module.exports = AverageCache;
|
||||
@@ -55,6 +55,20 @@ const Club = sequelize.define('Club', {
|
||||
defaultValue: 15,
|
||||
comment: '여성 기본 핸디캡'
|
||||
},
|
||||
averageCalculationPeriod: {
|
||||
type: DataTypes.ENUM(
|
||||
'3month',
|
||||
'6month',
|
||||
'1year',
|
||||
'firsthalf',
|
||||
'secondhalf',
|
||||
'quarterly',
|
||||
'total'
|
||||
),
|
||||
allowNull: false,
|
||||
defaultValue: '6month',
|
||||
comment: '에버리지 계산 기간'
|
||||
},
|
||||
createdAt: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
|
||||
@@ -28,9 +28,9 @@ const Event = sequelize.define('Event', {
|
||||
comment: '이벤트 설명'
|
||||
},
|
||||
eventType: {
|
||||
type: DataTypes.ENUM('정기전', '번개', '연습', '교류전', '이벤트', '기타'),
|
||||
type: DataTypes.ENUM('regular', 'lightning', 'practice', 'exchange', 'event', 'other'),
|
||||
allowNull: false,
|
||||
defaultValue: '정기전',
|
||||
defaultValue: 'regular',
|
||||
comment: '이벤트 유형'
|
||||
},
|
||||
publicHash: {
|
||||
@@ -88,9 +88,9 @@ const Event = sequelize.define('Event', {
|
||||
comment: '참가자 수'
|
||||
},
|
||||
status: {
|
||||
type: DataTypes.ENUM('준비', '활성', '완료', '취소', '삭제'),
|
||||
type: DataTypes.ENUM('ready', 'active', 'completed', 'canceled', 'deleted'),
|
||||
allowNull: false,
|
||||
defaultValue: '활성',
|
||||
defaultValue: 'active',
|
||||
comment: '이벤트 상태'
|
||||
},
|
||||
createdAt: {
|
||||
@@ -122,6 +122,11 @@ Event.associate = (models) => {
|
||||
Event.hasMany(models.EventScore, {
|
||||
foreignKey: 'eventId'
|
||||
});
|
||||
|
||||
// 팀 연관관계 추가
|
||||
Event.hasMany(models.EventTeam, {
|
||||
foreignKey: 'eventId'
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = Event;
|
||||
|
||||
@@ -41,15 +41,15 @@ const EventParticipant = sequelize.define('EventParticipant', {
|
||||
comment: '비고'
|
||||
},
|
||||
status: {
|
||||
type: DataTypes.ENUM('참가예정', '참가확정', '취소'),
|
||||
type: DataTypes.ENUM('pending', 'confirmed', 'canceled'),
|
||||
allowNull: false,
|
||||
defaultValue: '참가예정',
|
||||
defaultValue: 'pending',
|
||||
comment: '참가 상태'
|
||||
},
|
||||
paymentStatus: {
|
||||
type: DataTypes.ENUM('미납', '납부완료'),
|
||||
type: DataTypes.ENUM('unpaid', 'paid'),
|
||||
allowNull: false,
|
||||
defaultValue: '미납',
|
||||
defaultValue: 'unpaid',
|
||||
comment: '참가비 납부 상태'
|
||||
}
|
||||
}, {
|
||||
@@ -70,25 +70,15 @@ EventParticipant.associate = (models) => {
|
||||
EventParticipant.belongsTo(models.Event, {
|
||||
foreignKey: 'eventId'
|
||||
});
|
||||
|
||||
EventParticipant.belongsTo(models.Member, {
|
||||
foreignKey: 'memberId'
|
||||
});
|
||||
|
||||
EventParticipant.belongsTo(models.EventTeam, {
|
||||
foreignKey: 'teamId'
|
||||
});
|
||||
|
||||
EventParticipant.hasMany(models.EventScore, {
|
||||
foreignKey: 'participantId'
|
||||
});
|
||||
};
|
||||
|
||||
EventParticipant.associate = (models) => {
|
||||
EventParticipant.hasMany(models.EventScore, {
|
||||
foreignKey: 'participantId'
|
||||
});
|
||||
EventParticipant.belongsTo(models.Member, { foreignKey: 'memberId' });
|
||||
};
|
||||
|
||||
module.exports = EventParticipant;
|
||||
|
||||
@@ -34,14 +34,14 @@ const Member = sequelize.define('Member', {
|
||||
comment: '회원 이름'
|
||||
},
|
||||
gender: {
|
||||
type: DataTypes.ENUM('남성', '여성'),
|
||||
type: DataTypes.ENUM('male', 'female'),
|
||||
allowNull: false,
|
||||
comment: '성별'
|
||||
},
|
||||
memberType: {
|
||||
type: DataTypes.ENUM('정회원', '준회원', '게스트', '운영진', '모임장'),
|
||||
type: DataTypes.ENUM('regular', 'associate', 'guest', 'manager', 'owner'),
|
||||
allowNull: false,
|
||||
defaultValue: '준회원',
|
||||
defaultValue: 'regular',
|
||||
comment: '회원 유형'
|
||||
},
|
||||
handicap: {
|
||||
@@ -50,18 +50,6 @@ const Member = sequelize.define('Member', {
|
||||
defaultValue: 0,
|
||||
comment: '핸디캡'
|
||||
},
|
||||
average: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
comment: '평균 점수'
|
||||
},
|
||||
games: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
comment: '게임 수'
|
||||
},
|
||||
phone: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
|
||||
@@ -33,9 +33,9 @@ const Participant = sequelize.define('Participant', {
|
||||
comment: '팀 번호'
|
||||
},
|
||||
status: {
|
||||
type: DataTypes.ENUM('참가예정', '참가완료', '취소'),
|
||||
type: DataTypes.ENUM('pending', 'confirmed', 'canceled'),
|
||||
allowNull: false,
|
||||
defaultValue: '참가예정',
|
||||
defaultValue: 'pending',
|
||||
comment: '참가 상태'
|
||||
},
|
||||
attendance: {
|
||||
@@ -44,9 +44,9 @@ const Participant = sequelize.define('Participant', {
|
||||
comment: '출석 여부'
|
||||
},
|
||||
paymentStatus: {
|
||||
type: DataTypes.ENUM('미납', '납부완료'),
|
||||
type: DataTypes.ENUM('unpaid', 'paid'),
|
||||
allowNull: false,
|
||||
defaultValue: '미납',
|
||||
defaultValue: 'unpaid',
|
||||
comment: '참가비 납부 상태'
|
||||
},
|
||||
paymentAmount: {
|
||||
|
||||
@@ -17,6 +17,7 @@ const ClubSubscription = require('./ClubSubscription');
|
||||
const ActivityLog = require('./activityLog');
|
||||
const EventTeamMember = require('./EventTeamMember');
|
||||
const PaymentRequest = require('./PaymentRequest');
|
||||
const AverageCache = require('./AverageCache');
|
||||
|
||||
// 모델 동기화 함수
|
||||
const syncModels = async () => {
|
||||
@@ -51,6 +52,7 @@ const db = {
|
||||
SubscriptionPlan,
|
||||
SubscriptionPlanFeature,
|
||||
ClubSubscription,
|
||||
AverageCache,
|
||||
ActivityLog,
|
||||
EventTeamMember,
|
||||
PaymentRequest,
|
||||
@@ -78,5 +80,6 @@ module.exports = {
|
||||
ActivityLog,
|
||||
EventTeamMember,
|
||||
PaymentRequest,
|
||||
AverageCache,
|
||||
syncModels
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user