Skip to content

Commit

Permalink
feat: checker integration (#53)
Browse files Browse the repository at this point in the history
# 🤖 Linear

Closes GIT-183

## Description
Integration between Indexer v2 and checker app

## Checklist before requesting a review

-   [x] I have conducted a self-review of my code.
-   [x] I have conducted a QA.
-   [x] If it is a core feature, I have included comprehensive tests.
  • Loading branch information
0xkenj1 authored Jan 15, 2025
1 parent 1f95d53 commit 0edae83
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,35 @@ cp .env.example .env
docker-compose up -d --build
```

3. Copy the Example Environment File on `apps/migration-scripts` and edit the `.env` file
3. Copy the Example Environment File on `scripts/migrations` and edit the `.env` file

```
cp apps/migration-scripts/.env.example apps/migration-scripts/.env
cp scripts/migrations/.env.example scripts/migrations/.env
```

4. After starting Docker Compose, run the following command to apply the database migrations:

```
pnpm script:db:migrate
pnpm db:migrate
```

5. Navigate to the processing service directory and start it with:
5. Copy the Example Environment File on `apps/processing` and edit the `.env` file

cp apps/processing/.env.example apps/processing/.env

6. Start the Processing service with:

```
cd apps/processing && pnpm dev
pnpm dev
```

Once the setup is completed you can access Hasura by navigating to:

```
http://localhost:8080/
http://localhost:8082/
```

Use the default password: `testing`.
Use the default password: `my-admin-secret`.

## Contributing

Expand Down
4 changes: 2 additions & 2 deletions apps/indexer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ COPY . /app
WORKDIR /app

RUN --mount=type=cache,id=pnpm,target=$PNPM_HOME/store pnpm install --frozen-lockfile
RUN pnpm dlx envio codegen
RUN pnpm envio codegen

CMD pnpm dlx envio local db-migrate up && pnpm dlx envio start
CMD pnpm envio local db-migrate up && pnpm envio start
3 changes: 2 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ services:
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: ${DATALAYER_HASURA_UNAUTHORIZED_ROLE:-public}
HASURA_GRAPHQL_CORS_DOMAIN: ${DATALAYER_HASURA_CORS_DOMAIN:-*}
HASURA_GRAPHQL_ENABLE_TELEMETRY: ${DATALAYER_HASURA_ENABLE_TELEMETRY:-false}
HASURA_GRAPHQL_EXPERIMENTAL_FEATURES: "bigquery_string_numeric_input"
HASURA_GRAPHQL_EXPERIMENTAL_FEATURES: "bigquery_string_numeric_input,naming_convention"
HASURA_GRAPHQL_DEFAULT_NAMING_CONVENTION: "graphql-default"
HASURA_GRAPHQL_BIGQUERY_STRING_NUMERIC_INPUT: "true"
## enable debugging mode. It is recommended to disable this in production
HASURA_GRAPHQL_DEV_MODE: ${DATALAYER_HASURA_DEV_MODE:-true}
Expand Down
23 changes: 22 additions & 1 deletion scripts/migrations/src/migrations/20241029T120000_initial.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Kysely, sql } from "kysely";
import { Kysely, RawBuilder, sql } from "kysely";

import { getSchemaName } from "../utils/index.js";

Expand All @@ -16,6 +16,7 @@ export async function up(db: Kysely<any>): Promise<void> {
const CURRENCY_TYPE = sql`numeric(18,2)`;

const schema = getSchemaName(db.schema);
const ref = (name: string): RawBuilder<unknown> => sql.table(`${schema}.${name}`);
await db.schema.createType("project_type").asEnum(["canonical", "linked"]).execute();

console.log("schema", schema);
Expand Down Expand Up @@ -206,6 +207,14 @@ export async function up(db: Kysely<any>): Promise<void> {
.addColumn("tags", sql`text[]`)

.addPrimaryKeyConstraint("applications_pkey", ["chainId", "roundId", "id"])
.addForeignKeyConstraint(
"applications_projects_fkey",
["chainId", "projectId"],
"projects",
["chainId", "id"],
(cb) => cb.onDelete("cascade"),
)

.addForeignKeyConstraint(
"applications_rounds_fkey",
["roundId", "chainId"],
Expand Down Expand Up @@ -288,6 +297,18 @@ export async function up(db: Kysely<any>): Promise<void> {
.addUniqueConstraint("unique_v1ProjectId", ["v1ProjectId"])
.addUniqueConstraint("unique_v2ProjectId", ["v2ProjectId"])
.execute();

// Project search function
await sql`
create function ${ref("search_projects")}(search_term text)
returns setof ${ref("projects")} as $$
select *
from ${ref("projects")}
where to_tsvector(name) @@ to_tsquery(search_term)
order by ts_rank_cd(to_tsvector(name), to_tsquery(search_term)) desc;
$$ language sql stable;
`.execute(db);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down

0 comments on commit 0edae83

Please sign in to comment.