diff options
author | Chocobozzz <me@florianbigard.com> | 2020-12-30 11:41:36 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-12-30 11:41:36 +0100 |
commit | 47d8e266f16b91fec7e4a15a8372d50c2909c042 (patch) | |
tree | 41902b4ff8dfc73dfd69f064a2e343a34c43ab97 /server | |
parent | a046453549bf8f2ced083cc8ac414a9cab42dcf5 (diff) | |
download | PeerTube-47d8e266f16b91fec7e4a15a8372d50c2909c042.tar.gz PeerTube-47d8e266f16b91fec7e4a15a8372d50c2909c042.tar.zst PeerTube-47d8e266f16b91fec7e4a15a8372d50c2909c042.zip |
Support activeMonth and activeHalfyear in nodeinfo
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/static.ts | 6 | ||||
-rw-r--r-- | server/models/account/user.ts | 4 | ||||
-rw-r--r-- | server/tests/misc-endpoints.ts | 2 |
3 files changed, 9 insertions, 3 deletions
diff --git a/server/controllers/static.ts b/server/controllers/static.ts index f12f00e1b..bdb9c3041 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts | |||
@@ -206,7 +206,7 @@ export { | |||
206 | async function generateNodeinfo (req: express.Request, res: express.Response) { | 206 | async function generateNodeinfo (req: express.Request, res: express.Response) { |
207 | const { totalVideos } = await VideoModel.getStats() | 207 | const { totalVideos } = await VideoModel.getStats() |
208 | const { totalLocalVideoComments } = await VideoCommentModel.getStats() | 208 | const { totalLocalVideoComments } = await VideoCommentModel.getStats() |
209 | const { totalUsers } = await UserModel.getStats() | 209 | const { totalUsers, totalMonthlyActiveUsers, totalHalfYearActiveUsers } = await UserModel.getStats() |
210 | let json = {} | 210 | let json = {} |
211 | 211 | ||
212 | if (req.params.version && (req.params.version === '2.0')) { | 212 | if (req.params.version && (req.params.version === '2.0')) { |
@@ -229,7 +229,9 @@ async function generateNodeinfo (req: express.Request, res: express.Response) { | |||
229 | openRegistrations: CONFIG.SIGNUP.ENABLED, | 229 | openRegistrations: CONFIG.SIGNUP.ENABLED, |
230 | usage: { | 230 | usage: { |
231 | users: { | 231 | users: { |
232 | total: totalUsers | 232 | total: totalUsers, |
233 | activeMonth: totalMonthlyActiveUsers, | ||
234 | activeHalfyear: totalHalfYearActiveUsers | ||
233 | }, | 235 | }, |
234 | localPosts: totalVideos, | 236 | localPosts: totalVideos, |
235 | localComments: totalLocalVideoComments | 237 | localComments: totalLocalVideoComments |
diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 8e437c3be..11003645c 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts | |||
@@ -794,12 +794,14 @@ export class UserModel extends Model { | |||
794 | const totalDailyActiveUsers = await getActiveUsers(1) | 794 | const totalDailyActiveUsers = await getActiveUsers(1) |
795 | const totalWeeklyActiveUsers = await getActiveUsers(7) | 795 | const totalWeeklyActiveUsers = await getActiveUsers(7) |
796 | const totalMonthlyActiveUsers = await getActiveUsers(30) | 796 | const totalMonthlyActiveUsers = await getActiveUsers(30) |
797 | const totalHalfYearActiveUsers = await getActiveUsers(180) | ||
797 | 798 | ||
798 | return { | 799 | return { |
799 | totalUsers, | 800 | totalUsers, |
800 | totalDailyActiveUsers, | 801 | totalDailyActiveUsers, |
801 | totalWeeklyActiveUsers, | 802 | totalWeeklyActiveUsers, |
802 | totalMonthlyActiveUsers | 803 | totalMonthlyActiveUsers, |
804 | totalHalfYearActiveUsers | ||
803 | } | 805 | } |
804 | } | 806 | } |
805 | 807 | ||
diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.ts index 698d83328..162b53e18 100644 --- a/server/tests/misc-endpoints.ts +++ b/server/tests/misc-endpoints.ts | |||
@@ -110,6 +110,8 @@ describe('Test misc endpoints', function () { | |||
110 | }) | 110 | }) |
111 | 111 | ||
112 | expect(res.body.software.name).to.equal('peertube') | 112 | expect(res.body.software.name).to.equal('peertube') |
113 | expect(res.body.usage.users.activeMonth).to.equal(1) | ||
114 | expect(res.body.usage.users.activeHalfyear).to.equal(1) | ||
113 | }) | 115 | }) |
114 | }) | 116 | }) |
115 | 117 | ||