Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/harshithpabbati/daily-metrics


https://github.com/harshithpabbati/daily-metrics

Last synced: 3 days ago
JSON representation

Awesome Lists containing this project

README

        

# Daily Metrics

### Steps for installation

1. Clone this project

```sh
git clone https://github.com/harshithpabbati/daily-metrics.git
```

2. Change into the directory and install the dependencies

```sh
cd daily-metrics

npm install
```

3. Create a project in supabase, and use the below sql command to create table.

```
CREATE TABLE metrics (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
inserted_at timestamp with time zone DEFAULT timezone('utc'::text, now()) NOT NULL,
data jsonb,
call_data jsonb,
user_id uuid references auth.users not null
);
```

and postgresql functions

```
CREATE OR REPLACE FUNCTION room_metrics(roomname text)
returns table (
roomID bigint,
roomData jsonb,
roomMeetingData jsonb,
insertedAt timestamptz,
userId uuid,
name text
) LANGUAGE PLPGSQL
AS $$
BEGIN
RETURN query
SELECT
id as roomID,
data as roomData,
call_data as roomMeetingData,
inserted_at as insertedAt,
user_id as userId,
room as name
FROM
metrics
WHERE
room = roomName
GROUP BY user_id, id;
END
$$
```

4. Create a file named __.env.local__ and update it with the values from your Supabase project and Daily API:

```
NEXT_PUBLIC_SUPABASE_URL=https://app-id.supabase.co
NEXT_PUBLIC_SUPABASE_KEY=your-public-api-key
DAILY_API_KEY=daily-public-key
```

![Image URLs](https://user-images.githubusercontent.com/43822585/130856654-ddbb99ed-2807-4ae6-9ffe-0375312d0192.png)

5. Run the server

```sh
npm run dev
```