feat: analytics controller
This commit is contained in:
parent
cf988b2681
commit
d230e10870
|
|
@ -23,18 +23,15 @@ export class AnalyticsController {
|
|||
|
||||
@Get('/trending')
|
||||
async getTrending() {
|
||||
const stars = await this._starsService.predictTrending(10);
|
||||
const findFirst = stars.find(star => dayjs(star).isBefore(dayjs()));
|
||||
const trendings = (await this._starsService.getTrending('')).reverse();
|
||||
const dates = trendings.map(result => dayjs(result.date).toDate());
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-expect-error
|
||||
const intervals = dates.slice(1).map((date, i) => (date - dates[i]) / (1000 * 60 * 60 * 24));
|
||||
const nextInterval = intervals.length === 0 ? null : mean(intervals);
|
||||
const lastTrendingDate = dates[dates.length - 1];
|
||||
const nextTrendingDate = !nextInterval ? 'Not possible yet' : dayjs(new Date(lastTrendingDate.getTime() + nextInterval * 24 * 60 * 60 * 1000)).format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
return {
|
||||
last: dayjs(lastTrendingDate).format('YYYY-MM-DD HH:mm:ss'),
|
||||
predictions: nextTrendingDate
|
||||
predictions: findFirst
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ title: How it works
|
|||
description: 'Learn the architecture of the project'
|
||||
---
|
||||
|
||||
crosspublic is a tool to convert private communication into public knowledge.<br />
|
||||
Gitroom is a tool to convert private communication into public knowledge.<br />
|
||||
The entire project is built under [NX](https://nx.dev/) to have a monorepo with multiple projects.<br /><br />
|
||||
Unlike other NX project, this project has one `.env` file that is shared between all the apps.<br />
|
||||
It makes it easier to develop and deploy the project.<br /><br />
|
||||
|
|
@ -20,7 +20,7 @@ When deploying to websites like [Railway](https://railway.app) or [Heroku](https
|
|||
|
||||
<img
|
||||
src="/images/arch.png"
|
||||
alt="Architecture of crosspublic"
|
||||
alt="Architecture of Gitroom"
|
||||
/>
|
||||
|
||||
## Architecture
|
||||
|
|
@ -49,7 +49,7 @@ It's the website for the end-users to see the FAQ.<br />
|
|||
It contains a simple search bar and a list of questions.<br />
|
||||
The search bar uses [Algolia](https://www.algolia.com/) to search through the questions.<br />
|
||||
It uses the style from the control panel to customize the website.<br />
|
||||
The tenants cache each pages on the `crosspublic.com/[domainName]` path, it uses a middleware to rewrite the Vercel apex domain or the custom domain to the route.<br />
|
||||
The tenants cache each pages on the `Gitroom.com/[domainName]` path, it uses a middleware to rewrite the Vercel apex domain or the custom domain to the route.<br />
|
||||
|
||||
### Discord
|
||||
The Discord bot is built with [Discord.JS](https://discord.js.org/) and [NestJS](https://nestjs.com/).<br />
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
title: Introduction
|
||||
description: 'Welcome to crosspublic documentation'
|
||||
description: 'Welcome to Gitroom documentation'
|
||||
---
|
||||
|
||||
<div className="w-full flex justify-center rounded-full">
|
||||
|
|
@ -16,22 +16,25 @@ description: 'Welcome to crosspublic documentation'
|
|||
/>
|
||||
</div>
|
||||
|
||||
## What is crosspublic?
|
||||
## What is Gitroom?
|
||||
|
||||
crosspublic is a tool to convert private communication into public knowledge.<br />
|
||||
Most of your users are not on your communication channels, and they are not aware of the questions that have already been asked and answered.<br />
|
||||
Gitroom can help you launch your open-source tool every week<br />
|
||||
<ul>
|
||||
<li>Schedule social media and articles.</li>
|
||||
<li>Exchange or buy posts from other members.</li>
|
||||
<li>Monitor your GitHub trending, and so much more.</li>
|
||||
</ul>
|
||||
|
||||
## Architecture
|
||||
crosspublic is an [NX monorepo](https://nx.dev) that contains the backend, control panel, discord bot, marketing website and the docs.<br /><br />
|
||||
Gitroom is an [NX monorepo](https://nx.dev) that contains a backend, a frontend, workers, cron jobs and the docs.<br /><br />
|
||||
Unlike other NX project, this project has one `.env` file that is shared between all the apps.<br />
|
||||
It makes it easier to develop and deploy the project.<br /><br />
|
||||
When deploying to websites like [Railway](https://railway.app) or [Heroku](https://heroku.com), you can use a shared environment variables for all the apps.<br />
|
||||
|
||||
**It has four main components:**
|
||||
- `Panel` - NextJS control panel to manage your FAQ, it also contains the public website of every user FAQ page.
|
||||
- `Tenants` - NextJS website that contains the FAQ of every end-user.
|
||||
- `Backend` - NestJS that operate as the server for both the bots and the website.
|
||||
- `Discord` - Discord bot that listen to messages, and send them to the backend.
|
||||
- `frontend` - NextJS control panel serving as the admin dashboard for the project.
|
||||
- `backend` - NestJS backend that serves as the API for the frontend.
|
||||
- `cron` - NestJS cron jobs that run every X to update the database with new trendings,
|
||||
|
||||
In the future there will also be a bot of Slack, Intercom, Telegram, and more.
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 11 KiB |
File diff suppressed because one or more lines are too long
|
|
@ -60,7 +60,7 @@ Create a new [Algolia](https://www.algolia.com/) account, head over to the [API
|
|||
### Clone the repository
|
||||
|
||||
```bash
|
||||
git clone https://github.com/github-20k/crosspublic
|
||||
git clone https://github.com/github-20k/Gitroom
|
||||
```
|
||||
|
||||
### Copy environment variables
|
||||
|
|
@ -69,7 +69,7 @@ Copy the `.env.example` file to `.env` and fill in the values
|
|||
```bash
|
||||
DISCORD_CLIENT=<copied discord client key>
|
||||
DISCORD_TOKEN=<copied discord token key>
|
||||
DATABASE_URL=postgres://root:your_password@localhost:5432/crosspublic
|
||||
DATABASE_URL=postgres://root:your_password@localhost:5432/Gitroom
|
||||
BACKEND_URL=http://localhost:3000
|
||||
NEXT_PUBLIC_BACKEND_URL=http://localhost:3000
|
||||
BACKEND_TOKEN_PROTECTOR=<anything you want, better be long>
|
||||
|
|
|
|||
Loading…
Reference in New Issue