Skip to content

Commit

Permalink
Merge branch 'main' into lf/chore/make-private-packages
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizAsFight authored Sep 16, 2024
2 parents 5fcbc81 + 049b011 commit f46ee80
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 8 deletions.
5 changes: 0 additions & 5 deletions .changeset/soft-forks-hope.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
{
"isLive": true,
"name": "Charcoal Transpiler",
"url": "https://www.sway-playground.org/",
"url": "https://github.com/ourovoros-io/charcoal",
"tags": ["Tooling"],
"description": "Solidity to Sway transpiler",
"github": "https://github.com/ourovoros-io",
Expand Down
33 changes: 33 additions & 0 deletions packages/graphql/src/application/uc/GetMetrics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { client } from '~/graphql/GraphQLSDK';
import BlockDAO from '~/infra/dao/BlockDAO';

export default class GetMetrics {
async getFuelCoreLastBlockHeight() {
const { data } = await client.sdk.blocks({ last: 1 });
const blocks = data.blocks;
const [lastBlock] = blocks.nodes;
const height = Number(lastBlock?.header.height ?? '0');
return height;
}

async getIndexerLastBlockHeight() {
const blockDAO = new BlockDAO();
const latestBlock = await blockDAO.findLatestBlockAdded();
const blockId = latestBlock ? latestBlock.id : 0;
return blockId;
}

async execute(): Promise<any> {
const fuelCoreLastBlockHeight = await this.getFuelCoreLastBlockHeight();
const indexerLastBlockHeight = await this.getIndexerLastBlockHeight();
const indexerBlockHeightDelay =
fuelCoreLastBlockHeight - indexerLastBlockHeight;
const indexerHealth = indexerBlockHeightDelay < 100 ? 1 : 0;
return {
explorer_indexer_fuel_core_last_block_height: fuelCoreLastBlockHeight,
explorer_indexer_last_block_height_synced: indexerLastBlockHeight,
explorer_indexer_block_height_sync_delay: indexerBlockHeightDelay,
explorer_indexer_health: indexerHealth,
};
}
}
14 changes: 13 additions & 1 deletion packages/graphql/src/infra/server/App.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import cors from 'cors';
import express from 'express';
import express, { Request, Response } from 'express';
import GetMetrics from '~/application/uc/GetMetrics';

export class Server {
setup() {
const app = express();
app.use(cors<cors.CorsRequest>());
app.use(express.json());

app.get('/metrics', async (_req: Request, res: Response) => {
const getMetrics = new GetMetrics();
const output = await getMetrics.execute();
const lines: any = [];
for (const element in output) {
lines.push(`${element} ${output[element]}`);
}
res.setHeader('content-type', 'text/plain');
res.send(lines.join('\n'));
});
return app;
}

Expand Down
13 changes: 13 additions & 0 deletions packages/ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# @fuels/ui

## 0.1.0

### Minor Changes

- [#467](https://github.com/FuelLabs/fuel-explorer/pull/467) [`4d90c26`](https://github.com/FuelLabs/fuel-explorer/commit/4d90c26031be165919135b30b9bcf813ad7d28f6) Thanks [@LeoCourbassier](https://github.com/LeoCourbassier)! - Make the @fuels/ui package public and publishable

## 0.1.0

### Minor Changes

- [#467](https://github.com/FuelLabs/fuel-explorer/pull/467) [`4d90c26`](https://github.com/FuelLabs/fuel-explorer/commit/4d90c26031be165919135b30b9bcf813ad7d28f6) Thanks [@LeoCourbassier](https://github.com/LeoCourbassier)! - Make the @fuels/ui package public and publishable
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fuels/ui",
"version": "0.0.1",
"version": "0.1.0",
"access": "public",
"main": "./src/index.ts",
"exports": {
Expand Down

0 comments on commit f46ee80

Please sign in to comment.