Add reputation actions feature to Falukant module
- Introduced new endpoints for retrieving and executing reputation actions in FalukantController and falukantRouter. - Implemented service methods in FalukantService to handle reputation actions, including daily limits and action execution logic. - Updated the frontend ReputationView component to display available actions and their details, including cost and potential reputation gain. - Added translations for reputation actions in both German and English locales. - Enhanced initialization logic to set up reputation action types in the database.
This commit is contained in:
59
backend/models/falukant/log/reputation_action.js
Normal file
59
backend/models/falukant/log/reputation_action.js
Normal file
@@ -0,0 +1,59 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class ReputationActionLog extends Model {}
|
||||
|
||||
ReputationActionLog.init(
|
||||
{
|
||||
falukantUserId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'falukant_user_id',
|
||||
},
|
||||
actionTypeId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'action_type_id',
|
||||
},
|
||||
cost: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
baseGain: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'base_gain',
|
||||
},
|
||||
gain: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
timesUsedBefore: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'times_used_before',
|
||||
},
|
||||
actionTimestamp: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
defaultValue: sequelize.literal('CURRENT_TIMESTAMP'),
|
||||
field: 'action_timestamp',
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'ReputationActionLog',
|
||||
tableName: 'reputation_action',
|
||||
schema: 'falukant_log',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
indexes: [
|
||||
{ fields: ['falukant_user_id', 'action_type_id'] },
|
||||
{ fields: ['action_timestamp'] },
|
||||
],
|
||||
}
|
||||
);
|
||||
|
||||
export default ReputationActionLog;
|
||||
|
||||
|
||||
51
backend/models/falukant/type/reputation_action.js
Normal file
51
backend/models/falukant/type/reputation_action.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import { Model, DataTypes } from 'sequelize';
|
||||
import { sequelize } from '../../../utils/sequelize.js';
|
||||
|
||||
class ReputationActionType extends Model {}
|
||||
|
||||
ReputationActionType.init(
|
||||
{
|
||||
tr: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
cost: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
baseGain: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
field: 'base_gain',
|
||||
},
|
||||
decayFactor: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: false,
|
||||
field: 'decay_factor',
|
||||
},
|
||||
minGain: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
field: 'min_gain',
|
||||
},
|
||||
decayWindowDays: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 7,
|
||||
field: 'decay_window_days',
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'ReputationActionType',
|
||||
tableName: 'reputation_action',
|
||||
schema: 'falukant_type',
|
||||
timestamps: false,
|
||||
underscored: true,
|
||||
}
|
||||
);
|
||||
|
||||
export default ReputationActionType;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user