Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ix_plays_user_item_date index #7077

Merged
merged 10 commits into from
Jan 10, 2024
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
begin;
lock table plays in access exclusive mode;

create index ix_plays_user_track_date on plays(user_id, play_item_id, created_at) where user_id is not null;

commit;
2 changes: 0 additions & 2 deletions packages/trpc-server/.env

This file was deleted.

1 change: 1 addition & 0 deletions packages/trpc-server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
50 changes: 50 additions & 0 deletions packages/trpc-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,53 @@

* run once: `bash test.sh run`
* start watch mode: `bash test.sh`

A global fixture set is used across all tests
and is populated into both postgres and elasticsearch.

To add more fixtures, edit `test/_fixtures.ts` and restart `bash test.sh`.

Be sure to follow ID range conventions:
* 100-199: users
* 200-299: tracks
* 300-399: playlists

The upside of global fixture set is that a more complex dataset can be done once, and all tests can benefit from having tracks of all different visibility levels to test against.
This is the downside is that adding reposts can break existing tests that assert on repost count.
But I think it is worth it... and this is how rails fixtures work.

## Running against stage / prod

> in the future it would be nice to have stable sandbox + staging nodes
> so you can just pull down a staging .env file and start server
> for now it's manual style

You can run server locally (`npm run dev`) and point it at a staging or sandbox database.

First, `ssh some-sandbox` add this to `audius-docker-compose/discovery-provider/.env`.
These are only accessible via VPN so this is safe to do:

```
EXPOSE_POSTGRES: :5432
EXPOSE_ELASTICSEARCH: :9200
```

Now create `.env` file in this directory
(using the external IP of `some-sandbox`):

```
audius_elasticsearch_url=http://1.2.3.4:9200
audius_db_url=postgres://postgres:postgres@1.2.3.4:5432/audius_discovery
```

Start server:

```
npm run dev
```

Finally start client but override `VITE_TRPC_ENDPOINT`:

```
VITE_TRPC_ENDPOINT=http://localhost:2022/trpc npm run web:prod
```
5 changes: 5 additions & 0 deletions packages/trpc-server/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ services:
- 35764:5432
volumes:
- ../discovery-provider/ddl:/ddl
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5

elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.10.2
Expand Down
Loading