]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Support activeMonth and activeHalfyear in nodeinfo
authorChocobozzz <me@florianbigard.com>
Wed, 30 Dec 2020 10:41:36 +0000 (11:41 +0100)
committerChocobozzz <me@florianbigard.com>
Wed, 30 Dec 2020 10:41:36 +0000 (11:41 +0100)
server/controllers/static.ts
server/models/account/user.ts
server/tests/misc-endpoints.ts

index f12f00e1bba3fcbf72ecd89a4939c66018513ce7..bdb9c3041826c085efe8cf6859a949e4597b3803 100644 (file)
@@ -206,7 +206,7 @@ export {
 async function generateNodeinfo (req: express.Request, res: express.Response) {
   const { totalVideos } = await VideoModel.getStats()
   const { totalLocalVideoComments } = await VideoCommentModel.getStats()
-  const { totalUsers } = await UserModel.getStats()
+  const { totalUsers, totalMonthlyActiveUsers, totalHalfYearActiveUsers } = await UserModel.getStats()
   let json = {}
 
   if (req.params.version && (req.params.version === '2.0')) {
@@ -229,7 +229,9 @@ async function generateNodeinfo (req: express.Request, res: express.Response) {
       openRegistrations: CONFIG.SIGNUP.ENABLED,
       usage: {
         users: {
-          total: totalUsers
+          total: totalUsers,
+          activeMonth: totalMonthlyActiveUsers,
+          activeHalfyear: totalHalfYearActiveUsers
         },
         localPosts: totalVideos,
         localComments: totalLocalVideoComments
index 8e437c3be929f8fe6c1f85d140ab8e404ee71ef7..11003645c8d7d52456f7ac1c7c23cbbfc393c65f 100644 (file)
@@ -794,12 +794,14 @@ export class UserModel extends Model {
     const totalDailyActiveUsers = await getActiveUsers(1)
     const totalWeeklyActiveUsers = await getActiveUsers(7)
     const totalMonthlyActiveUsers = await getActiveUsers(30)
+    const totalHalfYearActiveUsers = await getActiveUsers(180)
 
     return {
       totalUsers,
       totalDailyActiveUsers,
       totalWeeklyActiveUsers,
-      totalMonthlyActiveUsers
+      totalMonthlyActiveUsers,
+      totalHalfYearActiveUsers
     }
   }
 
index 698d833283caea5b5a03e0463ccc1f2231b91453..162b53e18d6b7f6ab2e0e0960bcdcdd4d117f051 100644 (file)
@@ -110,6 +110,8 @@ describe('Test misc endpoints', function () {
       })
 
       expect(res.body.software.name).to.equal('peertube')
+      expect(res.body.usage.users.activeMonth).to.equal(1)
+      expect(res.body.usage.users.activeHalfyear).to.equal(1)
     })
   })