mirror of
https://github.com/stronk-dev/LivepeerEvents.git
synced 2025-07-05 10:45:10 +02:00
some prework for graph view
This commit is contained in:
parent
d4212e24e6
commit
82f533d582
@ -13,6 +13,9 @@ import UnbondEvent from "../models/UnbondEvent";
|
|||||||
import UpdateEvent from "../models/UpdateEvent";
|
import UpdateEvent from "../models/UpdateEvent";
|
||||||
import WithdrawFeesEvent from "../models/WithdrawFeesEvent";
|
import WithdrawFeesEvent from "../models/WithdrawFeesEvent";
|
||||||
import WithdrawStakeEvent from "../models/WithdrawStakeEvent";
|
import WithdrawStakeEvent from "../models/WithdrawStakeEvent";
|
||||||
|
import MonthlyStat from "../models/monthlyStat";
|
||||||
|
import CommissionDataPoint from "../models/CommissionDataPoint";
|
||||||
|
import TotalStakeDataPoint from "../models/TotalStakeDataPoint";
|
||||||
|
|
||||||
const apiRouter = express.Router();
|
const apiRouter = express.Router();
|
||||||
import {
|
import {
|
||||||
@ -38,9 +41,6 @@ const fs = require('fs');
|
|||||||
|
|
||||||
// Used for the livepeer thegraph API
|
// Used for the livepeer thegraph API
|
||||||
import { request, gql } from 'graphql-request';
|
import { request, gql } from 'graphql-request';
|
||||||
import MonthlyStat from "../models/monthlyStat";
|
|
||||||
import CommissionDataPoint from "../models/CommissionDataPoint";
|
|
||||||
import TotalStakeDataPoint from "../models/TotalStakeDataPoint";
|
|
||||||
|
|
||||||
// Gets ETH, LPT and other coin info
|
// Gets ETH, LPT and other coin info
|
||||||
let CoinMarketCap = require('coinmarketcap-api');
|
let CoinMarketCap = require('coinmarketcap-api');
|
||||||
@ -173,6 +173,8 @@ let unbondEventCache = [];
|
|||||||
let stakeEventCache = [];
|
let stakeEventCache = [];
|
||||||
|
|
||||||
let monthlyStatCache = [];
|
let monthlyStatCache = [];
|
||||||
|
let commissionDataPointCache = [];
|
||||||
|
let totalStakeDataPoint = [];
|
||||||
|
|
||||||
apiRouter.get("/getAllMonthlyStats", async (req, res) => {
|
apiRouter.get("/getAllMonthlyStats", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
@ -182,6 +184,22 @@ apiRouter.get("/getAllMonthlyStats", async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
apiRouter.get("/getAllCommissions", async (req, res) => {
|
||||||
|
try {
|
||||||
|
res.send(commissionDataPointCache);
|
||||||
|
} catch (err) {
|
||||||
|
res.status(400).send(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
apiRouter.get("/getAllTotalStakes", async (req, res) => {
|
||||||
|
try {
|
||||||
|
res.send(totalStakeDataPoint);
|
||||||
|
} catch (err) {
|
||||||
|
res.status(400).send(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
apiRouter.get("/getAllUpdateEvents", async (req, res) => {
|
apiRouter.get("/getAllUpdateEvents", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
res.send(updateEventCache);
|
res.send(updateEventCache);
|
||||||
@ -1368,6 +1386,20 @@ const initSync = async function () {
|
|||||||
testScores: 1,
|
testScores: 1,
|
||||||
_id: 0
|
_id: 0
|
||||||
});
|
});
|
||||||
|
// Get all graph data points
|
||||||
|
commissionDataPointCache = await CommissionDataPoint.find({}, {
|
||||||
|
address: 1,
|
||||||
|
feeCommission: 1,
|
||||||
|
rewardCommission: 1,
|
||||||
|
timestamp: 1,
|
||||||
|
_id: 0
|
||||||
|
});
|
||||||
|
totalStakeDataPoint = await TotalStakeDataPoint.find({}, {
|
||||||
|
address: 1,
|
||||||
|
totalStake: 1,
|
||||||
|
timestamp: 1,
|
||||||
|
_id: 0
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Does the actual looping over last parsed block -> latest block in chain
|
// Does the actual looping over last parsed block -> latest block in chain
|
||||||
|
@ -17,6 +17,8 @@ export const SET_ALL_ORCH_SCORES = "SET_ALL_ORCH_SCORES";
|
|||||||
export const SET_ALL_ORCH_INFO = "SET_ALL_ORCH_INFO";
|
export const SET_ALL_ORCH_INFO = "SET_ALL_ORCH_INFO";
|
||||||
export const SET_ALL_DEL_INFO = "SET_ALL_DEL_INFO";
|
export const SET_ALL_DEL_INFO = "SET_ALL_DEL_INFO";
|
||||||
export const SET_ALL_MONTHLY_STATS = "SET_ALL_MONTHLY_STATS";
|
export const SET_ALL_MONTHLY_STATS = "SET_ALL_MONTHLY_STATS";
|
||||||
|
export const SET_ALL_COMMISSIONS = "SET_ALL_COMMISSIONS";
|
||||||
|
export const SET_ALL_TOTAL_STAKES = "SET_ALL_TOTAL_STAKES";
|
||||||
export const SET_ALL_UPDATE_EVENTS = "SET_ALL_UPDATE_EVENTS";
|
export const SET_ALL_UPDATE_EVENTS = "SET_ALL_UPDATE_EVENTS";
|
||||||
export const SET_ALL_REWARD_EVENTS = "SET_ALL_REWARD_EVENTS";
|
export const SET_ALL_REWARD_EVENTS = "SET_ALL_REWARD_EVENTS";
|
||||||
export const SET_ALL_CLAIM_EVENTS = "SET_ALL_CLAIM_EVENTS";
|
export const SET_ALL_CLAIM_EVENTS = "SET_ALL_CLAIM_EVENTS";
|
||||||
@ -79,6 +81,14 @@ const setAllMonthlyStats = message => ({
|
|||||||
type: SET_ALL_MONTHLY_STATS, message
|
type: SET_ALL_MONTHLY_STATS, message
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const setAllCommissions = message => ({
|
||||||
|
type: SET_ALL_COMMISSIONS, message
|
||||||
|
});
|
||||||
|
|
||||||
|
const setAllTotalStakes = message => ({
|
||||||
|
type: SET_ALL_TOTAL_STAKES, message
|
||||||
|
});
|
||||||
|
|
||||||
const setAllUpdateEvents = message => ({
|
const setAllUpdateEvents = message => ({
|
||||||
type: SET_ALL_UPDATE_EVENTS, message
|
type: SET_ALL_UPDATE_EVENTS, message
|
||||||
});
|
});
|
||||||
@ -257,6 +267,24 @@ export const getAllMonthlyStats = () => async dispatch => {
|
|||||||
return dispatch(receiveErrors(data));
|
return dispatch(receiveErrors(data));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getAllCommissions = () => async dispatch => {
|
||||||
|
const response = await apiUtil.getAllCommissions();
|
||||||
|
const data = await response.json();
|
||||||
|
if (response.ok) {
|
||||||
|
return dispatch(setAllCommissions(data));
|
||||||
|
}
|
||||||
|
return dispatch(receiveErrors(data));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getAllTotalStakes = () => async dispatch => {
|
||||||
|
const response = await apiUtil.getAllTotalStakes();
|
||||||
|
const data = await response.json();
|
||||||
|
if (response.ok) {
|
||||||
|
return dispatch(setAllTotalStakes(data));
|
||||||
|
}
|
||||||
|
return dispatch(receiveErrors(data));
|
||||||
|
};
|
||||||
|
|
||||||
export const getAllUpdateEvents = () => async dispatch => {
|
export const getAllUpdateEvents = () => async dispatch => {
|
||||||
const response = await apiUtil.getAllUpdateEvents();
|
const response = await apiUtil.getAllUpdateEvents();
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
@ -9,7 +9,7 @@ import {
|
|||||||
getAllDelInfo, getAllMonthlyStats, getAllUpdateEvents, getAllRewardEvents,
|
getAllDelInfo, getAllMonthlyStats, getAllUpdateEvents, getAllRewardEvents,
|
||||||
getAllClaimEvents, getAllWithdrawStakeEvents, getAllWithdrawFeesEvents,
|
getAllClaimEvents, getAllWithdrawStakeEvents, getAllWithdrawFeesEvents,
|
||||||
getAllTransferTicketEvents, getAllRedeemTicketEvents, getAllActivateEvents,
|
getAllTransferTicketEvents, getAllRedeemTicketEvents, getAllActivateEvents,
|
||||||
getAllUnbondEvents, getAllStakeEvents,
|
getAllUnbondEvents, getAllStakeEvents, getAllCommissions, getAllTotalStakes
|
||||||
} from "../actions/livepeer";
|
} from "../actions/livepeer";
|
||||||
import { login } from "../actions/session";
|
import { login } from "../actions/session";
|
||||||
|
|
||||||
@ -55,6 +55,8 @@ const Startup = (obj) => {
|
|||||||
dispatch(getAllDelInfo());
|
dispatch(getAllDelInfo());
|
||||||
dispatch(getAllOrchScores());
|
dispatch(getAllOrchScores());
|
||||||
dispatch(getAllMonthlyStats());
|
dispatch(getAllMonthlyStats());
|
||||||
|
dispatch(getAllCommissions());
|
||||||
|
dispatch(getAllTotalStakes());
|
||||||
dispatch(getAllUpdateEvents());
|
dispatch(getAllUpdateEvents());
|
||||||
dispatch(getAllRewardEvents());
|
dispatch(getAllRewardEvents());
|
||||||
dispatch(getAllClaimEvents());
|
dispatch(getAllClaimEvents());
|
||||||
|
@ -5,6 +5,7 @@ import { useSelector, useDispatch } from 'react-redux';
|
|||||||
import { Accordion } from '@mantine/core';
|
import { Accordion } from '@mantine/core';
|
||||||
import ScrollContainer from 'react-indiana-drag-scroll';
|
import ScrollContainer from 'react-indiana-drag-scroll';
|
||||||
import WinnerMonth from '../components/WinnerMonth';
|
import WinnerMonth from '../components/WinnerMonth';
|
||||||
|
// import Graphs from '../components/Graphs';
|
||||||
|
|
||||||
const Stats = (obj) => {
|
const Stats = (obj) => {
|
||||||
const livepeer = useSelector((state) => state.livepeerstate);
|
const livepeer = useSelector((state) => state.livepeerstate);
|
||||||
@ -57,6 +58,7 @@ const Stats = (obj) => {
|
|||||||
content: { padding: 0, paddingTop: '1em', paddingBottom: '1em' },
|
content: { padding: 0, paddingTop: '1em', paddingBottom: '1em' },
|
||||||
contentInner: { padding: 0 },
|
contentInner: { padding: 0 },
|
||||||
}}>
|
}}>
|
||||||
|
{/* <Graphs commissions={livepeer.allCommissions} stakes={livepeer.allTotalStakes} /> */}
|
||||||
{
|
{
|
||||||
livepeer.monthlyStats.slice(0).reverse().map(function (data, i) {
|
livepeer.monthlyStats.slice(0).reverse().map(function (data, i) {
|
||||||
let thisMonth = "";
|
let thisMonth = "";
|
||||||
|
@ -15,6 +15,8 @@ import {
|
|||||||
SET_ALL_DEL_INFO,
|
SET_ALL_DEL_INFO,
|
||||||
CACHE_ORCHESTRATOR,
|
CACHE_ORCHESTRATOR,
|
||||||
SET_ALL_MONTHLY_STATS,
|
SET_ALL_MONTHLY_STATS,
|
||||||
|
SET_ALL_COMMISSIONS,
|
||||||
|
SET_ALL_TOTAL_STAKES,
|
||||||
SET_ALL_UPDATE_EVENTS,
|
SET_ALL_UPDATE_EVENTS,
|
||||||
SET_ALL_REWARD_EVENTS,
|
SET_ALL_REWARD_EVENTS,
|
||||||
SET_ALL_CLAIM_EVENTS,
|
SET_ALL_CLAIM_EVENTS,
|
||||||
@ -109,6 +111,10 @@ export default (state = {
|
|||||||
return { ...state, delInfo: message };
|
return { ...state, delInfo: message };
|
||||||
case SET_ALL_MONTHLY_STATS:
|
case SET_ALL_MONTHLY_STATS:
|
||||||
return { ...state, monthlyStats: message };
|
return { ...state, monthlyStats: message };
|
||||||
|
case SET_ALL_COMMISSIONS:
|
||||||
|
return { ...state, allCommissions: message };
|
||||||
|
case SET_ALL_TOTAL_STAKES:
|
||||||
|
return { ...state, allTotalStakes: message };
|
||||||
case SET_ALL_UPDATE_EVENTS:
|
case SET_ALL_UPDATE_EVENTS:
|
||||||
return { ...state, updateEvents: message };
|
return { ...state, updateEvents: message };
|
||||||
case SET_ALL_REWARD_EVENTS:
|
case SET_ALL_REWARD_EVENTS:
|
||||||
|
@ -154,6 +154,24 @@ export const getAllMonthlyStats = () => (
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const getAllCommissions = () => (
|
||||||
|
fetch("api/livepeer/getAllCommissions", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
export const getAllTotalStakes = () => (
|
||||||
|
fetch("api/livepeer/getAllTotalStakes", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
export const getAllUpdateEvents = () => (
|
export const getAllUpdateEvents = () => (
|
||||||
fetch("api/livepeer/getAllUpdateEvents", {
|
fetch("api/livepeer/getAllUpdateEvents", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user