Browse Source

heartbeat: announce storage size

Joystream Stats 3 years ago
parent
commit
9af242aef2

+ 5 - 1
community-contributions/joystreamtelegrambot/src/lib/announcements.ts

@@ -18,6 +18,7 @@ import {
   memberHandleByAccount,
   memberHandleByAccount,
   proposalDetail,
   proposalDetail,
   fetchTokenValue,
   fetchTokenValue,
+  fetchStorageSize,
 } from "./getters";
 } from "./getters";
 import moment from "moment";
 import moment from "moment";
 
 
@@ -248,6 +249,7 @@ export const heartbeat = async (
   channel: any
   channel: any
 ): Promise<[]> => {
 ): Promise<[]> => {
   const price = await fetchTokenValue();
   const price = await fetchTokenValue();
+  const storageSize = await fetchStorageSize();
   const durations = blocks.map((b) => b.duration);
   const durations = blocks.map((b) => b.duration);
   const blocktime = getAverage(durations) / 1000;
   const blocktime = getAverage(durations) / 1000;
 
 
@@ -279,7 +281,9 @@ export const heartbeat = async (
   Stake: ${avgStake.toFixed(1)} / ${avgIssued.toFixed()} M tJOY (${percent}%)
   Stake: ${avgStake.toFixed(1)} / ${avgIssued.toFixed()} M tJOY (${percent}%)
   Validators: ${avgVals.toFixed()} (${reward} tJOY/h)
   Validators: ${avgVals.toFixed()} (${reward} tJOY/h)
   Nominators: ${getAverage(noms).toFixed()}
   Nominators: ${getAverage(noms).toFixed()}
-  ${proposalString}`;
+  Volume: ${storageSize}
+  ${proposalString}
+  `;
 
 
   sendMessage(msg, channel);
   sendMessage(msg, channel);
   return [];
   return [];

+ 10 - 0
community-contributions/joystreamtelegrambot/src/lib/getters.ts

@@ -114,3 +114,13 @@ export const fetchTokenValue = async () => {
   const { data } = await axios.get("https://status.joystream.org/status");
   const { data } = await axios.get("https://status.joystream.org/status");
   return data ? `${Math.floor(+data.price * 100000000) / 100} $` : `?`;
   return data ? `${Math.floor(+data.price * 100000000) / 100} $` : `?`;
 };
 };
+
+export const fetchStorageSize = async () => {
+  const dashboard = "https://analytics.dapplooker.com/api/public/dashboard";
+  const asset = "c70b56bd-09a0-4472-a557-796afdc64d3b/card/155";
+
+  const { data } = await axios.get(`${dashboard}/${asset}`);
+
+  const size = Math.round(data.data.rows[0][0]) + "GB";
+  return size;
+};