]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/admin/requests/shared/request-stats.model.ts
Server: fix remaining milli seconds before the next requests feature
[github/Chocobozzz/PeerTube.git] / client / src / app / admin / requests / shared / request-stats.model.ts
index 7e4b26bca40fdb2b547e0f4a411021163886a650..dfa956f10a62d53fda446220dc4b067916415ffe 100644 (file)
@@ -1,8 +1,29 @@
-export interface RequestStats {
+export interface Request {
+  request: any;
+  to: any;
+}
+
+export class RequestStats {
   milliSecondsInterval: number;
        remainingMilliSeconds: number;
-  requests: {
-    request: any,
-    to: any
-  }[];
+  requests: Request[];
+
+  constructor(hash: {
+    milliSecondsInterval: number,
+    remainingMilliSeconds: number,
+    requests: Request[];
+  }) {
+    this.milliSecondsInterval = hash.milliSecondsInterval;
+    this.remainingMilliSeconds = hash.remainingMilliSeconds;
+    this.requests = hash.requests;
+  }
+
+  get remainingSeconds() {
+    return Math.floor(this.remainingMilliSeconds / 1000);
+  }
+
+  get secondsInterval() {
+    return Math.floor(this.milliSecondsInterval / 1000);
+  }
+
 }