From 60650c77c8a2a98e92d869b237ae4900f369a8fc Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 11 Jan 2018 09:35:50 +0100 Subject: Add scores to follows and remove bad ones --- server/initializers/constants.ts | 21 +++++++++------- .../migrations/0170-actor-follow-score.ts | 28 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 server/initializers/migrations/0170-actor-follow-score.ts (limited to 'server/initializers') diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index c735e6daf..0c139912c 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -9,7 +9,7 @@ import { isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 165 +const LAST_MIGRATION_VERSION = 170 // --------------------------------------------------------------------------- @@ -40,12 +40,12 @@ const OAUTH_LIFETIME = { // --------------------------------------------------------------------------- -// Number of points we add/remove from a friend after a successful/bad request -const SERVERS_SCORE = { +// Number of points we add/remove after a successful/bad request +const ACTOR_FOLLOW_SCORE = { PENALTY: -10, BONUS: 10, - BASE: 100, - MAX: 1000 + BASE: 1000, + MAX: 10000 } const FOLLOW_STATES: { [ id: string ]: FollowState } = { @@ -76,6 +76,9 @@ const JOBS_FETCH_LIMIT_PER_CYCLE = { // 1 minutes let JOBS_FETCHING_INTERVAL = 60000 +// 1 hour +let SCHEDULER_INTERVAL = 60000 * 60 + // --------------------------------------------------------------------------- const CONFIG = { @@ -346,7 +349,7 @@ const OPENGRAPH_AND_OEMBED_COMMENT = '' // Special constants for a test instance if (isTestInstance() === true) { - SERVERS_SCORE.BASE = 20 + ACTOR_FOLLOW_SCORE.BASE = 20 JOBS_FETCHING_INTERVAL = 1000 REMOTE_SCHEME.HTTP = 'http' REMOTE_SCHEME.WS = 'ws' @@ -354,6 +357,7 @@ if (isTestInstance() === true) { ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE = 2 ACTIVITY_PUB.ACTOR_REFRESH_INTERVAL = 60 // 1 minute CONSTRAINTS_FIELDS.ACTORS.AVATAR.FILE_SIZE.max = 100 * 1024 // 100KB + SCHEDULER_INTERVAL = 10000 } CONFIG.WEBSERVER.URL = sanitizeUrl(CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT) @@ -378,7 +382,7 @@ export { OAUTH_LIFETIME, OPENGRAPH_AND_OEMBED_COMMENT, PAGINATION_COUNT_DEFAULT, - SERVERS_SCORE, + ACTOR_FOLLOW_SCORE, PREVIEWS_SIZE, REMOTE_SCHEME, FOLLOW_STATES, @@ -396,5 +400,6 @@ export { VIDEO_LICENCES, VIDEO_RATE_TYPES, VIDEO_MIMETYPE_EXT, - AVATAR_MIMETYPE_EXT + AVATAR_MIMETYPE_EXT, + SCHEDULER_INTERVAL } diff --git a/server/initializers/migrations/0170-actor-follow-score.ts b/server/initializers/migrations/0170-actor-follow-score.ts new file mode 100644 index 000000000..2deabaf98 --- /dev/null +++ b/server/initializers/migrations/0170-actor-follow-score.ts @@ -0,0 +1,28 @@ +import * as Sequelize from 'sequelize' +import { ACTOR_FOLLOW_SCORE } from '../index' + +async function up (utils: { + transaction: Sequelize.Transaction, + queryInterface: Sequelize.QueryInterface, + sequelize: Sequelize.Sequelize +}): Promise { + await utils.queryInterface.removeColumn('server', 'score') + + const data = { + type: Sequelize.INTEGER, + allowNull: false, + defaultValue: ACTOR_FOLLOW_SCORE.BASE + } + + await utils.queryInterface.addColumn('actorFollow', 'score', data) + +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { + up, + down +} -- cgit v1.2.3