From 0cc5ca598a6ca5b3ac105419e905cb89df854698 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Mar 2018 09:10:05 +0900 Subject: wip --- tools/migration/shell.camel-case.js | 81 +++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 tools/migration/shell.camel-case.js (limited to 'tools') diff --git a/tools/migration/shell.camel-case.js b/tools/migration/shell.camel-case.js new file mode 100644 index 0000000000..6d6b01a071 --- /dev/null +++ b/tools/migration/shell.camel-case.js @@ -0,0 +1,81 @@ +db.access_tokens.renameCollection('accessTokens'); +db.accessTokens.update({}, { + $rename: { + created_at: 'createdAt', + app_id: 'appId', + user_id: 'userId', + } +}, false, true); + +db.apps.update({}, { + $rename: { + created_at: 'createdAt', + user_id: 'userId', + name_id: 'nameId', + name_id_lower: 'nameIdLower', + callback_url: 'callbackUrl', + } +}, false, true); + +db.auth_sessions.renameCollection('authSessions'); +db.authSessions.update({}, { + $rename: { + created_at: 'createdAt', + app_id: 'appId', + user_id: 'userId', + } +}, false, true); + +db.channel_watching.renameCollection('channelWatching'); +db.channelWatching.update({}, { + $rename: { + created_at: 'createdAt', + deleted_at: 'deletedAt', + channel_id: 'channelId', + user_id: 'userId', + } +}, false, true); + +db.channels.update({}, { + $rename: { + created_at: 'createdAt', + user_id: 'userId', + watching_count: 'watchingCount' + } +}, false, true); + +db.drive_files.files.renameCollection('driveFiles.files'); +db.drive_files.chunks.renameCollection('driveFiles.chunks'); +db.driveFiles.files.update({}, { + $rename: { + 'metadata.user_id': 'metadata.userId', + 'metadata.folder_id': 'metadata.folderId', + 'metadata.properties.average_color': 'metadata.properties.avgColor' + } +}, false, true); + +db.drive_folders.renameCollection('driveFolders'); +db.driveFolders.update({}, { + $rename: { + created_at: 'createdAt', + user_id: 'userId', + parent_id: 'parentId', + } +}, false, true); + +db.favorites.update({}, { + $rename: { + created_at: 'createdAt', + user_id: 'userId', + post_id: 'postId', + } +}, false, true); + +db.following.update({}, { + $rename: { + created_at: 'createdAt', + deleted_at: 'deletedAt', + followee_id: 'followeeId', + follower_id: 'followerId', + } +}, false, true); -- cgit v1.2.3-freya From 73bb57480b01ece02bdf43866389bc9ef478f271 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Mar 2018 13:13:10 +0900 Subject: wip --- src/api/models/messaging-history.ts | 12 +++++++++++- src/api/models/messaging-message.ts | 11 ++++++----- tools/migration/shell.camel-case.js | 22 ++++++++++++++++++++++ 3 files changed, 39 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/src/api/models/messaging-history.ts b/src/api/models/messaging-history.ts index c06987e451..1e79032ed6 100644 --- a/src/api/models/messaging-history.ts +++ b/src/api/models/messaging-history.ts @@ -1,3 +1,13 @@ +import * as mongo from 'mongodb'; import db from '../../db/mongodb'; -export default db.get('messaging_histories') as any; // fuck type definition +const MessagingHistory = db.get('messagingHistories'); +export default MessagingHistory; + +export type IMessagingHistory = { + _id: mongo.ObjectID; + updatedAt: Date; + userId: mongo.ObjectID; + partnerId: mongo.ObjectID; + messageId: mongo.ObjectID; +}; diff --git a/src/api/models/messaging-message.ts b/src/api/models/messaging-message.ts index fcb356c5ca..026b23cf36 100644 --- a/src/api/models/messaging-message.ts +++ b/src/api/models/messaging-message.ts @@ -5,16 +5,17 @@ import { pack as packFile } from './drive-file'; import db from '../../db/mongodb'; import parse from '../common/text'; -const MessagingMessage = db.get('messaging_messages'); +const MessagingMessage = db.get('messagingMessages'); export default MessagingMessage; export interface IMessagingMessage { _id: mongo.ObjectID; - created_at: Date; + createdAt: Date; text: string; - user_id: mongo.ObjectID; - recipient_id: mongo.ObjectID; - is_read: boolean; + userId: mongo.ObjectID; + recipientId: mongo.ObjectID; + isRead: boolean; + fileId: mongo.ObjectID; } export function isValidText(text: string): boolean { diff --git a/tools/migration/shell.camel-case.js b/tools/migration/shell.camel-case.js index 6d6b01a071..ac0476af0c 100644 --- a/tools/migration/shell.camel-case.js +++ b/tools/migration/shell.camel-case.js @@ -79,3 +79,25 @@ db.following.update({}, { follower_id: 'followerId', } }, false, true); + +db.messaging_histories.renameCollection('messagingHistories'); +db.messagingHistories.update({}, { + $rename: { + updated_at: 'updatedAt', + user_id: 'userId', + partner: 'partnerId', + message: 'messageId', + } +}, false, true); + +db.messaging_messages.renameCollection('messagingMessages'); +db.messagingMessages.update({}, { + $rename: { + created_at: 'createdAt', + user_id: 'userId', + recipient_id: 'recipientId', + file_id: 'fileId', + is_read: 'isRead' + } +}, false, true); + -- cgit v1.2.3-freya From ac12e63a853359b819dfd5df3ef9604a51e27cd4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Mar 2018 13:20:19 +0900 Subject: wip --- src/api/models/mute.ts | 12 +++++++++++- tools/migration/shell.camel-case.js | 9 +++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/src/api/models/mute.ts b/src/api/models/mute.ts index 16018b82f7..fdc8cc714b 100644 --- a/src/api/models/mute.ts +++ b/src/api/models/mute.ts @@ -1,3 +1,13 @@ +import * as mongo from 'mongodb'; import db from '../../db/mongodb'; -export default db.get('mute') as any; // fuck type definition +const Mute = db.get('mute'); +export default Mute; + +export interface IMute { + _id: mongo.ObjectID; + createdAt: Date; + deletedAt: Date; + muterId: mongo.ObjectID; + muteeId: mongo.ObjectID; +} diff --git a/tools/migration/shell.camel-case.js b/tools/migration/shell.camel-case.js index ac0476af0c..9f07bd946d 100644 --- a/tools/migration/shell.camel-case.js +++ b/tools/migration/shell.camel-case.js @@ -101,3 +101,12 @@ db.messagingMessages.update({}, { } }, false, true); +db.mute.update({}, { + $rename: { + created_at: 'createdAt', + deleted_at: 'deletedAt', + mutee_id: 'muteeId', + muter_id: 'muterId', + } +}, false, true); + -- cgit v1.2.3-freya From 69cef75b53671ccd7e0a199d31fa2d6d7c91fe78 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Mar 2018 13:32:05 +0900 Subject: wip --- src/api/endpoints/othello/games.ts | 4 ++-- src/api/endpoints/othello/games/show.ts | 4 ++-- src/api/endpoints/othello/match.ts | 4 ++-- src/api/models/othello-game.ts | 34 ++++++++++++++++----------------- src/api/stream/othello-game.ts | 32 +++++++++++++++---------------- tools/migration/shell.camel-case.js | 20 +++++++++++++++++++ 6 files changed, 59 insertions(+), 39 deletions(-) (limited to 'tools') diff --git a/src/api/endpoints/othello/games.ts b/src/api/endpoints/othello/games.ts index 2a6bbb4043..f6e38b8d87 100644 --- a/src/api/endpoints/othello/games.ts +++ b/src/api/endpoints/othello/games.ts @@ -1,5 +1,5 @@ import $ from 'cafy'; -import Game, { pack } from '../../models/othello-game'; +import OthelloGame, { pack } from '../../models/othello-game'; module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'my' parameter @@ -50,7 +50,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { } // Fetch games - const games = await Game.find(q, { + const games = await OthelloGame.find(q, { sort, limit }); diff --git a/src/api/endpoints/othello/games/show.ts b/src/api/endpoints/othello/games/show.ts index 2b0db4dd00..c7bd74a39a 100644 --- a/src/api/endpoints/othello/games/show.ts +++ b/src/api/endpoints/othello/games/show.ts @@ -1,5 +1,5 @@ import $ from 'cafy'; -import Game, { pack } from '../../../models/othello-game'; +import OthelloGame, { pack } from '../../../models/othello-game'; import Othello from '../../../../common/othello/core'; module.exports = (params, user) => new Promise(async (res, rej) => { @@ -7,7 +7,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { const [gameId, gameIdErr] = $(params.game_id).id().$; if (gameIdErr) return rej('invalid game_id param'); - const game = await Game.findOne({ _id: gameId }); + const game = await OthelloGame.findOne({ _id: gameId }); if (game == null) { return rej('game not found'); diff --git a/src/api/endpoints/othello/match.ts b/src/api/endpoints/othello/match.ts index b73e105ef0..f73386ba7c 100644 --- a/src/api/endpoints/othello/match.ts +++ b/src/api/endpoints/othello/match.ts @@ -1,6 +1,6 @@ import $ from 'cafy'; import Matching, { pack as packMatching } from '../../models/othello-matching'; -import Game, { pack as packGame } from '../../models/othello-game'; +import OthelloGame, { pack as packGame } from '../../models/othello-game'; import User from '../../models/user'; import publishUserStream, { publishOthelloStream } from '../../event'; import { eighteight } from '../../../common/othello/maps'; @@ -28,7 +28,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { }); // Create game - const game = await Game.insert({ + const game = await OthelloGame.insert({ created_at: new Date(), user1_id: exist.parent_id, user2_id: user._id, diff --git a/src/api/models/othello-game.ts b/src/api/models/othello-game.ts index 01c6ca6c00..b9e57632d4 100644 --- a/src/api/models/othello-game.ts +++ b/src/api/models/othello-game.ts @@ -3,17 +3,17 @@ import deepcopy = require('deepcopy'); import db from '../../db/mongodb'; import { IUser, pack as packUser } from './user'; -const Game = db.get('othello_games'); -export default Game; +const OthelloGame = db.get('othelloGames'); +export default OthelloGame; -export interface IGame { +export interface IOthelloGame { _id: mongo.ObjectID; - created_at: Date; - started_at: Date; - user1_id: mongo.ObjectID; - user2_id: mongo.ObjectID; - user1_accepted: boolean; - user2_accepted: boolean; + createdAt: Date; + startedAt: Date; + user1Id: mongo.ObjectID; + user2Id: mongo.ObjectID; + user1Accepted: boolean; + user2Accepted: boolean; /** * どちらのプレイヤーが先行(黒)か @@ -22,9 +22,9 @@ export interface IGame { */ black: number; - is_started: boolean; - is_ended: boolean; - winner_id: mongo.ObjectID; + isStarted: boolean; + isEnded: boolean; + winnerId: mongo.ObjectID; logs: Array<{ at: Date; color: boolean; @@ -33,9 +33,9 @@ export interface IGame { settings: { map: string[]; bw: string | number; - is_llotheo: boolean; - can_put_everywhere: boolean; - looped_board: boolean; + isLlotheo: boolean; + canPutEverywhere: boolean; + loopedBoard: boolean; }; form1: any; form2: any; @@ -62,11 +62,11 @@ export const pack = ( // Populate the game if 'game' is ID if (mongo.ObjectID.prototype.isPrototypeOf(game)) { - _game = await Game.findOne({ + _game = await OthelloGame.findOne({ _id: game }); } else if (typeof game === 'string') { - _game = await Game.findOne({ + _game = await OthelloGame.findOne({ _id: new mongo.ObjectID(game) }); } else { diff --git a/src/api/stream/othello-game.ts b/src/api/stream/othello-game.ts index 1c846f27ae..45a931c7e7 100644 --- a/src/api/stream/othello-game.ts +++ b/src/api/stream/othello-game.ts @@ -1,7 +1,7 @@ import * as websocket from 'websocket'; import * as redis from 'redis'; import * as CRC32 from 'crc-32'; -import Game, { pack } from '../models/othello-game'; +import OthelloGame, { pack } from '../models/othello-game'; import { publishOthelloGameStream } from '../event'; import Othello from '../../common/othello/core'; import * as maps from '../../common/othello/maps'; @@ -60,14 +60,14 @@ export default function(request: websocket.request, connection: websocket.connec }); async function updateSettings(settings) { - const game = await Game.findOne({ _id: gameId }); + const game = await OthelloGame.findOne({ _id: gameId }); if (game.is_started) return; if (!game.user1_id.equals(user._id) && !game.user2_id.equals(user._id)) return; if (game.user1_id.equals(user._id) && game.user1_accepted) return; if (game.user2_id.equals(user._id) && game.user2_accepted) return; - await Game.update({ _id: gameId }, { + await OthelloGame.update({ _id: gameId }, { $set: { settings } @@ -77,7 +77,7 @@ export default function(request: websocket.request, connection: websocket.connec } async function initForm(form) { - const game = await Game.findOne({ _id: gameId }); + const game = await OthelloGame.findOne({ _id: gameId }); if (game.is_started) return; if (!game.user1_id.equals(user._id) && !game.user2_id.equals(user._id)) return; @@ -88,7 +88,7 @@ export default function(request: websocket.request, connection: websocket.connec form2: form }; - await Game.update({ _id: gameId }, { + await OthelloGame.update({ _id: gameId }, { $set: set }); @@ -99,7 +99,7 @@ export default function(request: websocket.request, connection: websocket.connec } async function updateForm(id, value) { - const game = await Game.findOne({ _id: gameId }); + const game = await OthelloGame.findOne({ _id: gameId }); if (game.is_started) return; if (!game.user1_id.equals(user._id) && !game.user2_id.equals(user._id)) return; @@ -118,7 +118,7 @@ export default function(request: websocket.request, connection: websocket.connec form1: form }; - await Game.update({ _id: gameId }, { + await OthelloGame.update({ _id: gameId }, { $set: set }); @@ -138,14 +138,14 @@ export default function(request: websocket.request, connection: websocket.connec } async function accept(accept: boolean) { - const game = await Game.findOne({ _id: gameId }); + const game = await OthelloGame.findOne({ _id: gameId }); if (game.is_started) return; let bothAccepted = false; if (game.user1_id.equals(user._id)) { - await Game.update({ _id: gameId }, { + await OthelloGame.update({ _id: gameId }, { $set: { user1_accepted: accept } @@ -158,7 +158,7 @@ export default function(request: websocket.request, connection: websocket.connec if (accept && game.user2_accepted) bothAccepted = true; } else if (game.user2_id.equals(user._id)) { - await Game.update({ _id: gameId }, { + await OthelloGame.update({ _id: gameId }, { $set: { user2_accepted: accept } @@ -177,7 +177,7 @@ export default function(request: websocket.request, connection: websocket.connec if (bothAccepted) { // 3秒後、まだacceptされていたらゲーム開始 setTimeout(async () => { - const freshGame = await Game.findOne({ _id: gameId }); + const freshGame = await OthelloGame.findOne({ _id: gameId }); if (freshGame == null || freshGame.is_started || freshGame.is_ended) return; if (!freshGame.user1_accepted || !freshGame.user2_accepted) return; @@ -196,7 +196,7 @@ export default function(request: websocket.request, connection: websocket.connec const map = freshGame.settings.map != null ? freshGame.settings.map : getRandomMap(); - await Game.update({ _id: gameId }, { + await OthelloGame.update({ _id: gameId }, { $set: { started_at: new Date(), is_started: true, @@ -222,7 +222,7 @@ export default function(request: websocket.request, connection: websocket.connec winner = null; } - await Game.update({ + await OthelloGame.update({ _id: gameId }, { $set: { @@ -245,7 +245,7 @@ export default function(request: websocket.request, connection: websocket.connec // 石を打つ async function set(pos) { - const game = await Game.findOne({ _id: gameId }); + const game = await OthelloGame.findOne({ _id: gameId }); if (!game.is_started) return; if (game.is_ended) return; @@ -288,7 +288,7 @@ export default function(request: websocket.request, connection: websocket.connec const crc32 = CRC32.str(game.logs.map(x => x.pos.toString()).join('') + pos.toString()); - await Game.update({ + await OthelloGame.update({ _id: gameId }, { $set: { @@ -314,7 +314,7 @@ export default function(request: websocket.request, connection: websocket.connec } async function check(crc32) { - const game = await Game.findOne({ _id: gameId }); + const game = await OthelloGame.findOne({ _id: gameId }); if (!game.is_started) return; diff --git a/tools/migration/shell.camel-case.js b/tools/migration/shell.camel-case.js index 9f07bd946d..11c6fe401d 100644 --- a/tools/migration/shell.camel-case.js +++ b/tools/migration/shell.camel-case.js @@ -1,3 +1,5 @@ +// このスクリプトを走らせる前か後に notifications コレクションはdropしてください + db.access_tokens.renameCollection('accessTokens'); db.accessTokens.update({}, { $rename: { @@ -110,3 +112,21 @@ db.mute.update({}, { } }, false, true); +db.othello_games.renameCollection('othelloGames'); +db.othelloGames.update({}, { + $rename: { + created_at: 'createdAt', + started_at: 'startedAt', + is_started: 'isStarted', + is_ended: 'isEnded', + user1_id: 'user1Id', + user2_id: 'user2Id', + user1_accepted: 'user1Accepted', + user2_accepted: 'user2Accepted', + winner_id: 'winnerId', + 'settings.is_llotheo': 'settings.isLlotheo', + 'settings.can_put_everywhere': 'settings.canPutEverywhere', + 'settings.looped_board': 'settings.loopedBoard', + } +}, false, true); + -- cgit v1.2.3-freya From 02be56cfc0feaa6dad6a63759eeae0ec7dfbfff4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Mar 2018 15:54:47 +0900 Subject: wip --- src/api/models/othello-matching.ts | 8 ++++---- src/api/models/poll-vote.ts | 12 +++++++++++- tools/migration/shell.camel-case.js | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) (limited to 'tools') diff --git a/src/api/models/othello-matching.ts b/src/api/models/othello-matching.ts index 5cc39cae13..9c84d7fb9f 100644 --- a/src/api/models/othello-matching.ts +++ b/src/api/models/othello-matching.ts @@ -3,14 +3,14 @@ import deepcopy = require('deepcopy'); import db from '../../db/mongodb'; import { IUser, pack as packUser } from './user'; -const Matching = db.get('othello_matchings'); +const Matching = db.get('othelloMatchings'); export default Matching; export interface IMatching { _id: mongo.ObjectID; - created_at: Date; - parent_id: mongo.ObjectID; - child_id: mongo.ObjectID; + createdAt: Date; + parentId: mongo.ObjectID; + childId: mongo.ObjectID; } /** diff --git a/src/api/models/poll-vote.ts b/src/api/models/poll-vote.ts index af77a2643e..3e883f2137 100644 --- a/src/api/models/poll-vote.ts +++ b/src/api/models/poll-vote.ts @@ -1,3 +1,13 @@ +import * as mongo from 'mongodb'; import db from '../../db/mongodb'; -export default db.get('poll_votes') as any; // fuck type definition +const PollVote = db.get('pollVotes'); +export default PollVote; + +export interface IPollVote { + _id: mongo.ObjectID; + createdAt: Date; + userId: mongo.ObjectID; + postId: mongo.ObjectID; + choice: number; +} diff --git a/tools/migration/shell.camel-case.js b/tools/migration/shell.camel-case.js index 11c6fe401d..6045dfa00c 100644 --- a/tools/migration/shell.camel-case.js +++ b/tools/migration/shell.camel-case.js @@ -130,3 +130,20 @@ db.othelloGames.update({}, { } }, false, true); +db.othello_matchings.renameCollection('othelloMatchings'); +db.othelloMatchings.update({}, { + $rename: { + created_at: 'createdAt', + parent_id: 'parentId', + child_id: 'childId' + } +}, false, true); + +db.poll_votes.renameCollection('pollVotes'); +db.pollVotes.update({}, { + $rename: { + created_at: 'createdAt', + user_id: 'userId', + post_id: 'postId' + } +}, false, true); -- cgit v1.2.3-freya From 65069d5fdb9af3214d62fcd48f140c9e735fa892 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Mar 2018 15:59:34 +0900 Subject: wip --- src/api/models/post-reaction.ts | 8 +++++--- src/api/models/post-watching.ts | 11 ++++++++++- tools/migration/shell.camel-case.js | 9 +++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/src/api/models/post-reaction.ts b/src/api/models/post-reaction.ts index 639a70e006..f581f01535 100644 --- a/src/api/models/post-reaction.ts +++ b/src/api/models/post-reaction.ts @@ -4,13 +4,15 @@ import db from '../../db/mongodb'; import Reaction from './post-reaction'; import { pack as packUser } from './user'; -const PostReaction = db.get('post_reactions'); +const PostReaction = db.get('postReactions'); export default PostReaction; export interface IPostReaction { _id: mongo.ObjectID; - created_at: Date; - deleted_at: Date; + createdAt: Date; + deletedAt: Date; + postId: mongo.ObjectID; + userId: mongo.ObjectID; reaction: string; } diff --git a/src/api/models/post-watching.ts b/src/api/models/post-watching.ts index 41d37e2703..907909a50f 100644 --- a/src/api/models/post-watching.ts +++ b/src/api/models/post-watching.ts @@ -1,3 +1,12 @@ +import * as mongo from 'mongodb'; import db from '../../db/mongodb'; -export default db.get('post_watching') as any; // fuck type definition +const PostWatching = db.get('postWatching'); +export default PostWatching; + +export interface IPostWatching { + _id: mongo.ObjectID; + createdAt: Date; + userId: mongo.ObjectID; + postId: mongo.ObjectID; +} diff --git a/tools/migration/shell.camel-case.js b/tools/migration/shell.camel-case.js index 6045dfa00c..2a5456b4d0 100644 --- a/tools/migration/shell.camel-case.js +++ b/tools/migration/shell.camel-case.js @@ -147,3 +147,12 @@ db.pollVotes.update({}, { post_id: 'postId' } }, false, true); + +db.post_reactions.renameCollection('postReactions'); +db.postReactions.update({}, { + $rename: { + created_at: 'createdAt', + user_id: 'userId', + post_id: 'postId' + } +}, false, true); -- cgit v1.2.3-freya From bed17efd1b40e05e49b4de50c118f2acf804b95e Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Mar 2018 16:04:44 +0900 Subject: wip --- src/api/models/post.ts | 18 ++++++++---------- tools/migration/shell.camel-case.js | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 10 deletions(-) (limited to 'tools') diff --git a/src/api/models/post.ts b/src/api/models/post.ts index c37c8371c0..fc44256516 100644 --- a/src/api/models/post.ts +++ b/src/api/models/post.ts @@ -20,18 +20,16 @@ export function isValidText(text: string): boolean { export type IPost = { _id: mongo.ObjectID; - channel_id: mongo.ObjectID; - created_at: Date; - media_ids: mongo.ObjectID[]; - reply_id: mongo.ObjectID; - repost_id: mongo.ObjectID; + channelId: mongo.ObjectID; + createdAt: Date; + mediaIds: mongo.ObjectID[]; + replyId: mongo.ObjectID; + repostId: mongo.ObjectID; poll: any; // todo text: string; - user_id: mongo.ObjectID; - app_id: mongo.ObjectID; - category: string; - is_category_verified: boolean; - via_mobile: boolean; + userId: mongo.ObjectID; + appId: mongo.ObjectID; + viaMobile: boolean; geo: { latitude: number; longitude: number; diff --git a/tools/migration/shell.camel-case.js b/tools/migration/shell.camel-case.js index 2a5456b4d0..326d0a1b0f 100644 --- a/tools/migration/shell.camel-case.js +++ b/tools/migration/shell.camel-case.js @@ -156,3 +156,25 @@ db.postReactions.update({}, { post_id: 'postId' } }, false, true); + +db.post_watching.renameCollection('postWatching'); +db.postWatching.update({}, { + $rename: { + created_at: 'createdAt', + user_id: 'userId', + post_id: 'postId' + } +}, false, true); + +db.posts.update({}, { + $rename: { + created_at: 'createdAt', + channel_id: 'channelId', + user_id: 'userId', + app_id: 'appId', + media_ids: 'mediaIds', + reply_id: 'replyId', + repost_id: 'repostId', + via_mobile: 'viaMobile' + } +}, false, true); -- cgit v1.2.3-freya From b6c190e1fd915178100357009707aaa39a7bc687 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Mar 2018 16:07:48 +0900 Subject: wip --- tools/migration/shell.camel-case.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/migration/shell.camel-case.js b/tools/migration/shell.camel-case.js index 326d0a1b0f..a7e8afcdce 100644 --- a/tools/migration/shell.camel-case.js +++ b/tools/migration/shell.camel-case.js @@ -175,6 +175,8 @@ db.posts.update({}, { media_ids: 'mediaIds', reply_id: 'replyId', repost_id: 'repostId', - via_mobile: 'viaMobile' + via_mobile: 'viaMobile', + '_reply.user_id': '_reply.userId', + '_repost.user_id': '_repost.userId', } }, false, true); -- cgit v1.2.3-freya From 9bcd3cde46c457f0f59dbf8694652615ba9b272f Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Mar 2018 16:09:49 +0900 Subject: wip --- src/api/models/signin.ts | 5 +++++ tools/migration/shell.camel-case.js | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'tools') diff --git a/src/api/models/signin.ts b/src/api/models/signin.ts index 262c8707ed..62ee796d85 100644 --- a/src/api/models/signin.ts +++ b/src/api/models/signin.ts @@ -7,6 +7,11 @@ export default Signin; export interface ISignin { _id: mongo.ObjectID; + createdAt: Date; + userId: mongo.ObjectID; + ip: string; + headers: any; + success: boolean; } /** diff --git a/tools/migration/shell.camel-case.js b/tools/migration/shell.camel-case.js index a7e8afcdce..533868cdc4 100644 --- a/tools/migration/shell.camel-case.js +++ b/tools/migration/shell.camel-case.js @@ -180,3 +180,10 @@ db.posts.update({}, { '_repost.user_id': '_repost.userId', } }, false, true); + +db.signin.update({}, { + $rename: { + created_at: 'createdAt', + user_id: 'userId', + } +}, false, true); -- cgit v1.2.3-freya From efb7c71d88f177cb245873f3c705c82c4647b1ed Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Mar 2018 16:11:50 +0900 Subject: wip --- src/api/models/sw-subscription.ts | 12 +++++++++++- tools/migration/shell.camel-case.js | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/src/api/models/sw-subscription.ts b/src/api/models/sw-subscription.ts index ecca04cb91..235c801c7d 100644 --- a/src/api/models/sw-subscription.ts +++ b/src/api/models/sw-subscription.ts @@ -1,3 +1,13 @@ +import * as mongo from 'mongodb'; import db from '../../db/mongodb'; -export default db.get('sw_subscriptions') as any; // fuck type definition +const SwSubscription = db.get('swSubscriptions'); +export default SwSubscription; + +export interface ISwSubscription { + _id: mongo.ObjectID; + userId: mongo.ObjectID; + endpoint: string; + auth: string; + publickey: string; +} diff --git a/tools/migration/shell.camel-case.js b/tools/migration/shell.camel-case.js index 533868cdc4..9cb0baaaf5 100644 --- a/tools/migration/shell.camel-case.js +++ b/tools/migration/shell.camel-case.js @@ -187,3 +187,10 @@ db.signin.update({}, { user_id: 'userId', } }, false, true); + +db.sw_subscriptions.renameCollection('swSubscriptions'); +db.swSubscriptions.update({}, { + $rename: { + user_id: 'userId', + } +}, false, true); -- cgit v1.2.3-freya From 7d4d9dbaa61f2eaaa66eac2d9ac282c41044e2c7 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Mar 2018 16:20:46 +0900 Subject: wip --- src/api/models/user.ts | 2 +- src/api/private/signup.ts | 2 -- tools/migration/shell.camel-case.js | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/src/api/models/user.ts b/src/api/models/user.ts index e73c95faf2..9aa7c4efae 100644 --- a/src/api/models/user.ts +++ b/src/api/models/user.ts @@ -46,7 +46,7 @@ export type ILocalAccount = { password: string; token: string; twitter: { - access_token: string; + accessToken: string; access_token_secret: string; user_id: string; screen_name: string; diff --git a/src/api/private/signup.ts b/src/api/private/signup.ts index 96e0495709..29d75b62f9 100644 --- a/src/api/private/signup.ts +++ b/src/api/private/signup.ts @@ -115,8 +115,6 @@ export default async (req: express.Request, res: express.Response) => { following_count: 0, name: name, posts_count: 0, - likes_count: 0, - liked_count: 0, drive_capacity: 1073741824, // 1GB username: username, username_lower: username.toLowerCase(), diff --git a/tools/migration/shell.camel-case.js b/tools/migration/shell.camel-case.js index 9cb0baaaf5..afe831e5b7 100644 --- a/tools/migration/shell.camel-case.js +++ b/tools/migration/shell.camel-case.js @@ -194,3 +194,36 @@ db.swSubscriptions.update({}, { user_id: 'userId', } }, false, true); + +db.users.update({}, { + $rename: { + created_at: 'createdAt', + deleted_at: 'deletedAt', + followers_count: 'followersCount', + following_count: 'followingCount', + posts_count: 'postsCount', + drive_capacity: 'driveCapacity', + username_lower: 'usernameLower', + avatar_id: 'avatarId', + banner_id: 'bannerId', + pinned_post_id: 'pinnedPostId', + is_suspended: 'isSuspended', + host_lower: 'hostLower', + 'twitter.access_token': 'twitter.accessToken', + 'twitter.access_token_secret': 'twitter.accessTokenSecret', + 'twitter.user_id': 'twitter.userId', + 'twitter.screen_name': 'twitter.screenName', + 'line.user_id': 'line.userId', + last_used_at: 'lastUsedAt', + is_bot: 'isBot', + is_pro: 'isPro', + two_factor_secret: 'twoFactorSecret', + two_factor_enabled: 'twoFactorEnabled', + client_settings: 'clientSettings' + }, + $unset: { + likes_count: '', + liked_count: '', + latest_post: '' + } +}, false, true); -- cgit v1.2.3-freya From 71065077f66662381a6d5f08ad8b345ceaf742db Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Mar 2018 16:59:11 +0900 Subject: wip --- src/api/endpoints/meta.ts | 1 - src/api/endpoints/othello/games/show.ts | 6 +++--- src/api/endpoints/posts/create.ts | 16 ++++++++-------- src/api/endpoints/posts/reactions/create.ts | 2 +- src/api/endpoints/posts/reactions/delete.ts | 2 +- src/api/endpoints/posts/search.ts | 18 +++++++++--------- src/api/endpoints/posts/trend.ts | 4 ++-- src/api/endpoints/stats.ts | 4 ++-- src/api/endpoints/users/posts.ts | 12 ++++++------ src/api/models/app.ts | 2 +- src/api/models/channel.ts | 2 +- src/api/models/drive-folder.ts | 4 ++-- src/api/models/post.ts | 6 +++++- src/api/models/user.ts | 14 +++++++------- src/web/app/auth/views/index.vue | 4 ++-- src/web/app/ch/tags/channel.tag | 8 ++++---- src/web/app/common/scripts/parse-search-query.ts | 4 ++-- .../common/views/components/messaging-room.message.vue | 4 ++-- src/web/app/common/views/components/othello.vue | 2 +- src/web/app/common/views/components/poll.vue | 8 ++++---- .../app/common/views/components/reactions-viewer.vue | 2 +- src/web/app/desktop/views/components/follow-button.vue | 18 +++++++++--------- src/web/app/desktop/views/components/followers.vue | 2 +- src/web/app/desktop/views/components/following.vue | 2 +- src/web/app/desktop/views/components/post-detail.vue | 10 +++++----- src/web/app/desktop/views/components/posts.post.vue | 10 +++++----- .../app/desktop/views/components/users-list.item.vue | 2 +- src/web/app/desktop/views/pages/othello.vue | 2 +- src/web/app/desktop/views/pages/user/user.photos.vue | 2 +- src/web/app/desktop/views/pages/user/user.profile.vue | 10 +++++----- src/web/app/mobile/views/components/drive.vue | 8 ++++---- src/web/app/mobile/views/components/follow-button.vue | 18 +++++++++--------- src/web/app/mobile/views/components/post-detail.vue | 10 +++++----- src/web/app/mobile/views/components/post.vue | 10 +++++----- src/web/app/mobile/views/components/user-timeline.vue | 4 ++-- src/web/app/mobile/views/pages/followers.vue | 2 +- src/web/app/mobile/views/pages/following.vue | 2 +- src/web/app/mobile/views/pages/othello.vue | 2 +- src/web/app/mobile/views/pages/user.vue | 2 +- src/web/app/mobile/views/pages/user/home.photos.vue | 2 +- src/web/app/stats/tags/index.tag | 2 +- src/web/docs/api/entities/post.yaml | 4 ++-- src/web/docs/api/entities/user.yaml | 6 +++--- tools/migration/shell.camel-case.js | 3 +++ 44 files changed, 132 insertions(+), 126 deletions(-) (limited to 'tools') diff --git a/src/api/endpoints/meta.ts b/src/api/endpoints/meta.ts index 1370ead3c5..80a3725eb0 100644 --- a/src/api/endpoints/meta.ts +++ b/src/api/endpoints/meta.ts @@ -53,7 +53,6 @@ module.exports = (params) => new Promise(async (res, rej) => { model: os.cpus()[0].model, cores: os.cpus().length }, - top_image: meta.top_image, broadcasts: meta.broadcasts }); }); diff --git a/src/api/endpoints/othello/games/show.ts b/src/api/endpoints/othello/games/show.ts index 19f5d0fef0..f9084682fa 100644 --- a/src/api/endpoints/othello/games/show.ts +++ b/src/api/endpoints/othello/games/show.ts @@ -3,9 +3,9 @@ import OthelloGame, { pack } from '../../../models/othello-game'; import Othello from '../../../../common/othello/core'; module.exports = (params, user) => new Promise(async (res, rej) => { - // Get 'game_id' parameter - const [gameId, gameIdErr] = $(params.game_id).id().$; - if (gameIdErr) return rej('invalid game_id param'); + // Get 'gameId' parameter + const [gameId, gameIdErr] = $(params.gameId).id().$; + if (gameIdErr) return rej('invalid gameId param'); const game = await OthelloGame.findOne({ _id: gameId }); diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts index b99d1fbbc1..2817374545 100644 --- a/src/api/endpoints/posts/create.ts +++ b/src/api/endpoints/posts/create.ts @@ -211,12 +211,12 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { // 直近の投稿と重複してたらエラー // TODO: 直近の投稿が一日前くらいなら重複とは見なさない - if (user.latest_post) { + if (user.latestPost) { if (deepEqual({ - text: user.latest_post.text, - reply: user.latest_post.replyId ? user.latest_post.replyId.toString() : null, - repost: user.latest_post.repostId ? user.latest_post.repostId.toString() : null, - mediaIds: (user.latest_post.mediaIds || []).map(id => id.toString()) + text: user.latestPost.text, + reply: user.latestPost.replyId ? user.latestPost.replyId.toString() : null, + repost: user.latestPost.repostId ? user.latestPost.repostId.toString() : null, + mediaIds: (user.latestPost.mediaIds || []).map(id => id.toString()) }, { text: text, reply: reply ? reply._id.toString() : null, @@ -277,7 +277,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { User.update({ _id: user._id }, { $set: { - latest_post: post + latestPost: post } }); @@ -362,7 +362,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { // Increment replies count Post.update({ _id: reply._id }, { $inc: { - replies_count: 1 + repliesCount: 1 } }); @@ -457,7 +457,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => { // Update repostee status Post.update({ _id: repost._id }, { $inc: { - repost_count: 1 + repostCount: 1 } }); } diff --git a/src/api/endpoints/posts/reactions/create.ts b/src/api/endpoints/posts/reactions/create.ts index 6f75a923cd..a1e6779805 100644 --- a/src/api/endpoints/posts/reactions/create.ts +++ b/src/api/endpoints/posts/reactions/create.ts @@ -73,7 +73,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { res(); const inc = {}; - inc[`reaction_counts.${reaction}`] = 1; + inc[`reactionCounts.${reaction}`] = 1; // Increment reactions count await Post.update({ _id: post._id }, { diff --git a/src/api/endpoints/posts/reactions/delete.ts b/src/api/endpoints/posts/reactions/delete.ts index 18fdabcdc2..b09bcbb4b7 100644 --- a/src/api/endpoints/posts/reactions/delete.ts +++ b/src/api/endpoints/posts/reactions/delete.ts @@ -51,7 +51,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { res(); const dec = {}; - dec[`reaction_counts.${exist.reaction}`] = -1; + dec[`reactionCounts.${exist.reaction}`] = -1; // Decrement reactions count Post.update({ _id: post._id }, { diff --git a/src/api/endpoints/posts/search.ts b/src/api/endpoints/posts/search.ts index f90b9aa0dd..5c324bfe9a 100644 --- a/src/api/endpoints/posts/search.ts +++ b/src/api/endpoints/posts/search.ts @@ -21,21 +21,21 @@ module.exports = (params, me) => new Promise(async (res, rej) => { const [text, textError] = $(params.text).optional.string().$; if (textError) return rej('invalid text param'); - // Get 'include_userIds' parameter - const [includeUserIds = [], includeUserIdsErr] = $(params.include_userIds).optional.array('id').$; - if (includeUserIdsErr) return rej('invalid include_userIds param'); + // Get 'includeUserIds' parameter + const [includeUserIds = [], includeUserIdsErr] = $(params.includeUserIds).optional.array('id').$; + if (includeUserIdsErr) return rej('invalid includeUserIds param'); // Get 'exclude_userIds' parameter const [excludeUserIds = [], excludeUserIdsErr] = $(params.exclude_userIds).optional.array('id').$; if (excludeUserIdsErr) return rej('invalid exclude_userIds param'); - // Get 'include_user_usernames' parameter - const [includeUserUsernames = [], includeUserUsernamesErr] = $(params.include_user_usernames).optional.array('string').$; - if (includeUserUsernamesErr) return rej('invalid include_user_usernames param'); + // Get 'includeUserUsernames' parameter + const [includeUserUsernames = [], includeUserUsernamesErr] = $(params.includeUserUsernames).optional.array('string').$; + if (includeUserUsernamesErr) return rej('invalid includeUserUsernames param'); - // Get 'exclude_user_usernames' parameter - const [excludeUserUsernames = [], excludeUserUsernamesErr] = $(params.exclude_user_usernames).optional.array('string').$; - if (excludeUserUsernamesErr) return rej('invalid exclude_user_usernames param'); + // Get 'exclude_userUsernames' parameter + const [excludeUserUsernames = [], excludeUserUsernamesErr] = $(params.exclude_userUsernames).optional.array('string').$; + if (excludeUserUsernamesErr) return rej('invalid exclude_userUsernames param'); // Get 'following' parameter const [following = null, followingErr] = $(params.following).optional.nullable.boolean().$; diff --git a/src/api/endpoints/posts/trend.ts b/src/api/endpoints/posts/trend.ts index 3f92f06167..bc0c47fbc6 100644 --- a/src/api/endpoints/posts/trend.ts +++ b/src/api/endpoints/posts/trend.ts @@ -41,7 +41,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { createdAt: { $gte: new Date(Date.now() - ms('1days')) }, - repost_count: { + repostCount: { $gt: 0 } } as any; @@ -68,7 +68,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => { limit: limit, skip: offset, sort: { - repost_count: -1, + repostCount: -1, _id: -1 } }); diff --git a/src/api/endpoints/stats.ts b/src/api/endpoints/stats.ts index eee6f48706..719792d40d 100644 --- a/src/api/endpoints/stats.ts +++ b/src/api/endpoints/stats.ts @@ -18,7 +18,7 @@ import User from '../models/user'; * postsCount: * description: count of all posts of misskey * type: number - * users_count: + * usersCount: * description: count of all users of misskey * type: number * @@ -43,6 +43,6 @@ module.exports = params => new Promise(async (res, rej) => { res({ postsCount: postsCount, - users_count: usersCount + usersCount: usersCount }); }); diff --git a/src/api/endpoints/users/posts.ts b/src/api/endpoints/users/posts.ts index 9ece429b60..9346907492 100644 --- a/src/api/endpoints/users/posts.ts +++ b/src/api/endpoints/users/posts.ts @@ -34,13 +34,13 @@ module.exports = (params, me) => new Promise(async (res, rej) => { return rej('userId or pair of username and host is required'); } - // Get 'include_replies' parameter - const [includeReplies = true, includeRepliesErr] = $(params.include_replies).optional.boolean().$; - if (includeRepliesErr) return rej('invalid include_replies param'); + // Get 'includeReplies' parameter + const [includeReplies = true, includeRepliesErr] = $(params.includeReplies).optional.boolean().$; + if (includeRepliesErr) return rej('invalid includeReplies param'); - // Get 'with_media' parameter - const [withMedia = false, withMediaErr] = $(params.with_media).optional.boolean().$; - if (withMediaErr) return rej('invalid with_media param'); + // Get 'withMedia' parameter + const [withMedia = false, withMediaErr] = $(params.withMedia).optional.boolean().$; + if (withMediaErr) return rej('invalid withMedia param'); // Get 'limit' parameter const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$; diff --git a/src/api/models/app.ts b/src/api/models/app.ts index 20af049b27..528ab156f1 100644 --- a/src/api/models/app.ts +++ b/src/api/models/app.ts @@ -96,7 +96,7 @@ export const pack = ( limit: 1 }); - _app.is_authorized = exist === 1; + _app.isAuthorized = exist === 1; } resolve(_app); diff --git a/src/api/models/channel.ts b/src/api/models/channel.ts index aab21db070..1c7c52a34e 100644 --- a/src/api/models/channel.ts +++ b/src/api/models/channel.ts @@ -67,7 +67,7 @@ export const pack = ( deletedAt: { $exists: false } }); - _channel.is_watching = watch !== null; + _channel.isWatching = watch !== null; //#endregion } diff --git a/src/api/models/drive-folder.ts b/src/api/models/drive-folder.ts index 52f784e069..958e3fb9ef 100644 --- a/src/api/models/drive-folder.ts +++ b/src/api/models/drive-folder.ts @@ -62,8 +62,8 @@ export const pack = ( 'metadata.folderId': _folder.id }); - _folder.folders_count = childFoldersCount; - _folder.files_count = childFilesCount; + _folder.foldersCount = childFoldersCount; + _folder.filesCount = childFilesCount; } if (opts.detail && _folder.parentId) { diff --git a/src/api/models/post.ts b/src/api/models/post.ts index 4ab840b5ed..4f7729fbe8 100644 --- a/src/api/models/post.ts +++ b/src/api/models/post.ts @@ -30,6 +30,10 @@ export type IPost = { userId: mongo.ObjectID; appId: mongo.ObjectID; viaMobile: boolean; + repostCount: number; + repliesCount: number; + reactionCounts: any; + mentions: mongo.ObjectID[]; geo: { latitude: number; longitude: number; @@ -184,7 +188,7 @@ export const pack = async ( const myChoice = poll.choices .filter(c => c.id == vote.choice)[0]; - myChoice.is_voted = true; + myChoice.isVoted = true; } return poll; diff --git a/src/api/models/user.ts b/src/api/models/user.ts index 9ee413e0d8..0cf0fe0bdb 100644 --- a/src/api/models/user.ts +++ b/src/api/models/user.ts @@ -88,7 +88,7 @@ export type IUser = { bannerId: mongo.ObjectID; data: any; description: string; - latest_post: IPost; + latestPost: IPost; pinnedPostId: mongo.ObjectID; isSuspended: boolean; keywords: string[]; @@ -167,7 +167,7 @@ export const pack = ( delete _user._id; // Remove needless properties - delete _user.latest_post; + delete _user.latestPost; if (!_user.host) { // Remove private properties @@ -212,7 +212,7 @@ export const pack = ( if (meId && !meId.equals(_user.id)) { // Whether the user is following - _user.is_following = (async () => { + _user.isFollowing = (async () => { const follow = await Following.findOne({ followerId: meId, followeeId: _user.id, @@ -222,7 +222,7 @@ export const pack = ( })(); // Whether the user is followed - _user.is_followed = (async () => { + _user.isFollowed = (async () => { const follow2 = await Following.findOne({ followerId: _user.id, followeeId: meId, @@ -232,7 +232,7 @@ export const pack = ( })(); // Whether the user is muted - _user.is_muted = (async () => { + _user.isMuted = (async () => { const mute = await Mute.findOne({ muterId: meId, muteeId: _user.id, @@ -254,14 +254,14 @@ export const pack = ( const myFollowingIds = await getFriends(meId); // Get following you know count - _user.following_you_know_count = Following.count({ + _user.followingYouKnowCount = Following.count({ followeeId: { $in: myFollowingIds }, followerId: _user.id, deletedAt: { $exists: false } }); // Get followers you know count - _user.followers_you_know_count = Following.count({ + _user.followersYouKnowCount = Following.count({ followeeId: _user.id, followerId: { $in: myFollowingIds }, deletedAt: { $exists: false } diff --git a/src/web/app/auth/views/index.vue b/src/web/app/auth/views/index.vue index 690cc4f28e..e1e1b265e1 100644 --- a/src/web/app/auth/views/index.vue +++ b/src/web/app/auth/views/index.vue @@ -14,7 +14,7 @@

このアプリがあなたのアカウントにアクセスすることはありません。

-

{{ session.app.is_authorized ? 'このアプリは既に連携済みです' : 'アプリケーションの連携を許可しました'}}

+

{{ session.app.isAuthorized ? 'このアプリは既に連携済みです' : 'アプリケーションの連携を許可しました' }}

アプリケーションに戻っています

アプリケーションに戻って、やっていってください。

@@ -61,7 +61,7 @@ export default Vue.extend({ this.fetching = false; // 既に連携していた場合 - if (this.session.app.is_authorized) { + if (this.session.app.isAuthorized) { this.$root.$data.os.api('auth/accept', { token: this.session.token }).then(() => { diff --git a/src/web/app/ch/tags/channel.tag b/src/web/app/ch/tags/channel.tag index 225129088d..2abfb106a5 100644 --- a/src/web/app/ch/tags/channel.tag +++ b/src/web/app/ch/tags/channel.tag @@ -5,8 +5,8 @@

{ channel.title }

-

このチャンネルをウォッチしています ウォッチ解除

-

このチャンネルをウォッチする

+

このチャンネルをウォッチしています ウォッチ解除

+

このチャンネルをウォッチする