summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2020-03-21 13:36:41 +0900
committersyuilo <syuilotan@yahoo.co.jp>2020-03-21 13:36:41 +0900
commit6fb7721798657cf842556fb63f116316365efa74 (patch)
tree6917342553156b6483b899eafc66ef8f040b8352 /src/server/api/endpoints
parentUpdate CHANGELOG.md (diff)
parent12.22.0 (diff)
downloadmisskey-6fb7721798657cf842556fb63f116316365efa74.tar.gz
misskey-6fb7721798657cf842556fb63f116316365efa74.tar.bz2
misskey-6fb7721798657cf842556fb63f116316365efa74.zip
Merge branch 'develop'
Diffstat (limited to 'src/server/api/endpoints')
-rw-r--r--src/server/api/endpoints/antennas/create.ts4
-rw-r--r--src/server/api/endpoints/antennas/update.ts4
-rw-r--r--src/server/api/endpoints/charts/active-users.ts7
-rw-r--r--src/server/api/endpoints/charts/drive.ts7
-rw-r--r--src/server/api/endpoints/charts/federation.ts7
-rw-r--r--src/server/api/endpoints/charts/hashtag.ts7
-rw-r--r--src/server/api/endpoints/charts/instance.ts7
-rw-r--r--src/server/api/endpoints/charts/network.ts7
-rw-r--r--src/server/api/endpoints/charts/notes.ts7
-rw-r--r--src/server/api/endpoints/charts/user/drive.ts7
-rw-r--r--src/server/api/endpoints/charts/user/following.ts7
-rw-r--r--src/server/api/endpoints/charts/user/notes.ts7
-rw-r--r--src/server/api/endpoints/charts/user/reactions.ts7
-rw-r--r--src/server/api/endpoints/charts/users.ts7
-rw-r--r--src/server/api/endpoints/stats.ts6
-rw-r--r--src/server/api/endpoints/users/search-by-username-and-host.ts7
-rw-r--r--src/server/api/endpoints/users/search.ts2
17 files changed, 86 insertions, 21 deletions
diff --git a/src/server/api/endpoints/antennas/create.ts b/src/server/api/endpoints/antennas/create.ts
index f11b198f86..bc79385260 100644
--- a/src/server/api/endpoints/antennas/create.ts
+++ b/src/server/api/endpoints/antennas/create.ts
@@ -82,7 +82,7 @@ export default define(meta, async (ps, user) => {
id: ps.userListId,
userId: user.id,
});
-
+
if (userList == null) {
throw new ApiError(meta.errors.noSuchUserList);
}
@@ -91,7 +91,7 @@ export default define(meta, async (ps, user) => {
userGroupId: ps.userGroupId,
userId: user.id,
});
-
+
if (userGroupJoining == null) {
throw new ApiError(meta.errors.noSuchUserGroup);
}
diff --git a/src/server/api/endpoints/antennas/update.ts b/src/server/api/endpoints/antennas/update.ts
index ab4ce57937..b329e86ade 100644
--- a/src/server/api/endpoints/antennas/update.ts
+++ b/src/server/api/endpoints/antennas/update.ts
@@ -101,7 +101,7 @@ export default define(meta, async (ps, user) => {
id: ps.userListId,
userId: user.id,
});
-
+
if (userList == null) {
throw new ApiError(meta.errors.noSuchUserList);
}
@@ -110,7 +110,7 @@ export default define(meta, async (ps, user) => {
userGroupId: ps.userGroupId,
userId: user.id,
});
-
+
if (userGroupJoining == null) {
throw new ApiError(meta.errors.noSuchUserGroup);
}
diff --git a/src/server/api/endpoints/charts/active-users.ts b/src/server/api/endpoints/charts/active-users.ts
index 59bb1db109..df427ff4b7 100644
--- a/src/server/api/endpoints/charts/active-users.ts
+++ b/src/server/api/endpoints/charts/active-users.ts
@@ -25,11 +25,16 @@ export const meta = {
'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。'
}
},
+
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
},
res: convertLog(activeUsersChart.schema),
};
export default define(meta, async (ps) => {
- return await activeUsersChart.getChart(ps.span as any, ps.limit!);
+ return await activeUsersChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/src/server/api/endpoints/charts/drive.ts b/src/server/api/endpoints/charts/drive.ts
index 5c26fe719a..e1f279fa0a 100644
--- a/src/server/api/endpoints/charts/drive.ts
+++ b/src/server/api/endpoints/charts/drive.ts
@@ -25,11 +25,16 @@ export const meta = {
'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。'
}
},
+
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
},
res: convertLog(driveChart.schema),
};
export default define(meta, async (ps) => {
- return await driveChart.getChart(ps.span as any, ps.limit!);
+ return await driveChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/src/server/api/endpoints/charts/federation.ts b/src/server/api/endpoints/charts/federation.ts
index ebd60cc24b..581e42f307 100644
--- a/src/server/api/endpoints/charts/federation.ts
+++ b/src/server/api/endpoints/charts/federation.ts
@@ -25,11 +25,16 @@ export const meta = {
'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。'
}
},
+
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
},
res: convertLog(federationChart.schema),
};
export default define(meta, async (ps) => {
- return await federationChart.getChart(ps.span as any, ps.limit!);
+ return await federationChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/src/server/api/endpoints/charts/hashtag.ts b/src/server/api/endpoints/charts/hashtag.ts
index 8d14430137..1aa5c86b35 100644
--- a/src/server/api/endpoints/charts/hashtag.ts
+++ b/src/server/api/endpoints/charts/hashtag.ts
@@ -26,6 +26,11 @@ export const meta = {
}
},
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
+
tag: {
validator: $.str,
desc: {
@@ -38,5 +43,5 @@ export const meta = {
};
export default define(meta, async (ps) => {
- return await hashtagChart.getChart(ps.span as any, ps.limit!, ps.tag);
+ return await hashtagChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.tag);
});
diff --git a/src/server/api/endpoints/charts/instance.ts b/src/server/api/endpoints/charts/instance.ts
index 4c26b7614c..f0f85ed71a 100644
--- a/src/server/api/endpoints/charts/instance.ts
+++ b/src/server/api/endpoints/charts/instance.ts
@@ -26,6 +26,11 @@ export const meta = {
}
},
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
+
host: {
validator: $.str,
desc: {
@@ -39,5 +44,5 @@ export const meta = {
};
export default define(meta, async (ps) => {
- return await instanceChart.getChart(ps.span as any, ps.limit!, ps.host);
+ return await instanceChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.host);
});
diff --git a/src/server/api/endpoints/charts/network.ts b/src/server/api/endpoints/charts/network.ts
index 162c0c9ecd..d1337681a9 100644
--- a/src/server/api/endpoints/charts/network.ts
+++ b/src/server/api/endpoints/charts/network.ts
@@ -25,11 +25,16 @@ export const meta = {
'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。'
}
},
+
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
},
res: convertLog(networkChart.schema),
};
export default define(meta, async (ps) => {
- return await networkChart.getChart(ps.span as any, ps.limit!);
+ return await networkChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/src/server/api/endpoints/charts/notes.ts b/src/server/api/endpoints/charts/notes.ts
index c25f46f543..74aa48b36e 100644
--- a/src/server/api/endpoints/charts/notes.ts
+++ b/src/server/api/endpoints/charts/notes.ts
@@ -25,11 +25,16 @@ export const meta = {
'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。'
}
},
+
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
},
res: convertLog(notesChart.schema),
};
export default define(meta, async (ps) => {
- return await notesChart.getChart(ps.span as any, ps.limit!);
+ return await notesChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/src/server/api/endpoints/charts/user/drive.ts b/src/server/api/endpoints/charts/user/drive.ts
index 6bfa427403..5aae5bd757 100644
--- a/src/server/api/endpoints/charts/user/drive.ts
+++ b/src/server/api/endpoints/charts/user/drive.ts
@@ -27,6 +27,11 @@ export const meta = {
}
},
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
+
userId: {
validator: $.type(ID),
desc: {
@@ -40,5 +45,5 @@ export const meta = {
};
export default define(meta, async (ps) => {
- return await perUserDriveChart.getChart(ps.span as any, ps.limit!, ps.userId);
+ return await perUserDriveChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
});
diff --git a/src/server/api/endpoints/charts/user/following.ts b/src/server/api/endpoints/charts/user/following.ts
index 0da995e2ec..9d772c39c9 100644
--- a/src/server/api/endpoints/charts/user/following.ts
+++ b/src/server/api/endpoints/charts/user/following.ts
@@ -27,6 +27,11 @@ export const meta = {
}
},
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
+
userId: {
validator: $.type(ID),
desc: {
@@ -40,5 +45,5 @@ export const meta = {
};
export default define(meta, async (ps) => {
- return await perUserFollowingChart.getChart(ps.span as any, ps.limit!, ps.userId);
+ return await perUserFollowingChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
});
diff --git a/src/server/api/endpoints/charts/user/notes.ts b/src/server/api/endpoints/charts/user/notes.ts
index 754ade1228..8de7c0c3e4 100644
--- a/src/server/api/endpoints/charts/user/notes.ts
+++ b/src/server/api/endpoints/charts/user/notes.ts
@@ -27,6 +27,11 @@ export const meta = {
}
},
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
+
userId: {
validator: $.type(ID),
desc: {
@@ -40,5 +45,5 @@ export const meta = {
};
export default define(meta, async (ps) => {
- return await perUserNotesChart.getChart(ps.span as any, ps.limit!, ps.userId);
+ return await perUserNotesChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
});
diff --git a/src/server/api/endpoints/charts/user/reactions.ts b/src/server/api/endpoints/charts/user/reactions.ts
index f3344c6648..4c37305fc3 100644
--- a/src/server/api/endpoints/charts/user/reactions.ts
+++ b/src/server/api/endpoints/charts/user/reactions.ts
@@ -27,6 +27,11 @@ export const meta = {
}
},
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
+
userId: {
validator: $.type(ID),
desc: {
@@ -40,5 +45,5 @@ export const meta = {
};
export default define(meta, async (ps) => {
- return await perUserReactionsChart.getChart(ps.span as any, ps.limit!, ps.userId);
+ return await perUserReactionsChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null, ps.userId);
});
diff --git a/src/server/api/endpoints/charts/users.ts b/src/server/api/endpoints/charts/users.ts
index 0d7fb7b951..18eec384a6 100644
--- a/src/server/api/endpoints/charts/users.ts
+++ b/src/server/api/endpoints/charts/users.ts
@@ -25,11 +25,16 @@ export const meta = {
'ja-JP': '最大数。例えば 30 を指定したとすると、スパンが"day"の場合は30日分のデータが、スパンが"hour"の場合は30時間分のデータが返ります。'
}
},
+
+ offset: {
+ validator: $.optional.nullable.num,
+ default: null,
+ },
},
res: convertLog(usersChart.schema),
};
export default define(meta, async (ps) => {
- return await usersChart.getChart(ps.span as any, ps.limit!);
+ return await usersChart.getChart(ps.span as any, ps.limit!, ps.offset ? new Date(ps.offset) : null);
});
diff --git a/src/server/api/endpoints/stats.ts b/src/server/api/endpoints/stats.ts
index 5bc224450b..dab05c1675 100644
--- a/src/server/api/endpoints/stats.ts
+++ b/src/server/api/endpoints/stats.ts
@@ -60,9 +60,9 @@ export default define(meta, async () => {
Notes.count({ where: { userHost: null }, cache: 3600000 }),
Users.count({ cache: 3600000 }),
Users.count({ where: { host: null }, cache: 3600000 }),
- federationChart.getChart('hour', 1).then(chart => chart.instance.total[0]),
- driveChart.getChart('hour', 1).then(chart => chart.local.totalSize[0]),
- driveChart.getChart('hour', 1).then(chart => chart.remote.totalSize[0]),
+ federationChart.getChart('hour', 1, null).then(chart => chart.instance.total[0]),
+ driveChart.getChart('hour', 1, null).then(chart => chart.local.totalSize[0]),
+ driveChart.getChart('hour', 1, null).then(chart => chart.remote.totalSize[0]),
]);
return {
diff --git a/src/server/api/endpoints/users/search-by-username-and-host.ts b/src/server/api/endpoints/users/search-by-username-and-host.ts
index 81ff19ff6f..bc68f44094 100644
--- a/src/server/api/endpoints/users/search-by-username-and-host.ts
+++ b/src/server/api/endpoints/users/search-by-username-and-host.ts
@@ -1,7 +1,6 @@
import $ from 'cafy';
import define from '../../define';
import { Users } from '../../../../models';
-import { User } from '../../../../models/entities/user';
export const meta = {
desc: {
@@ -73,14 +72,17 @@ export default define(meta, async (ps, me) => {
q.andWhere('user.usernameLower like :username', { username: ps.username.toLowerCase() + '%' })
}
+ q.orderBy('user.updatedAt', 'DESC');
+
const users = await q.take(ps.limit!).skip(ps.offset).getMany();
return await Users.packMany(users, me, { detail: ps.detail });
- } else {
+ } else if (ps.username) {
let users = await Users.createQueryBuilder('user')
.where('user.host IS NULL')
.andWhere('user.isSuspended = FALSE')
.andWhere('user.usernameLower like :username', { username: ps.username.toLowerCase() + '%' })
+ .orderBy('user.updatedAt', 'DESC')
.take(ps.limit!)
.skip(ps.offset)
.getMany();
@@ -90,6 +92,7 @@ export default define(meta, async (ps, me) => {
.where('user.host IS NOT NULL')
.andWhere('user.isSuspended = FALSE')
.andWhere('user.usernameLower like :username', { username: ps.username.toLowerCase() + '%' })
+ .orderBy('user.updatedAt', 'DESC')
.take(ps.limit! - users.length)
.getMany();
diff --git a/src/server/api/endpoints/users/search.ts b/src/server/api/endpoints/users/search.ts
index dbeb6eb6af..c01f355d8c 100644
--- a/src/server/api/endpoints/users/search.ts
+++ b/src/server/api/endpoints/users/search.ts
@@ -74,6 +74,7 @@ export default define(meta, async (ps, me) => {
.where('user.host IS NULL')
.andWhere('user.isSuspended = FALSE')
.andWhere('user.usernameLower like :username', { username: ps.query.replace('@', '').toLowerCase() + '%' })
+ .orderBy('user.updatedAt', 'DESC')
.take(ps.limit!)
.skip(ps.offset)
.getMany();
@@ -83,6 +84,7 @@ export default define(meta, async (ps, me) => {
.where('user.host IS NOT NULL')
.andWhere('user.isSuspended = FALSE')
.andWhere('user.usernameLower like :username', { username: ps.query.replace('@', '').toLowerCase() + '%' })
+ .orderBy('user.updatedAt', 'DESC')
.take(ps.limit! - users.length)
.getMany();