Skip to content

Commit

Permalink
Merge pull request #67 from complexdatacollective/biome
Browse files Browse the repository at this point in the history
Biome
  • Loading branch information
jthrilly authored Nov 21, 2024
2 parents 12bfcc6 + b1a9ce9 commit 75ac94c
Show file tree
Hide file tree
Showing 737 changed files with 13,863 additions and 51,912 deletions.
18 changes: 9 additions & 9 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
15 changes: 9 additions & 6 deletions .github/workflows/check-links.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: Check for broken links

on: deployment_status
name: Check for Broken Links

on:
deployment_status
jobs:
linkinator:
runs-on: ubuntu-latest
if: ${{ startsWith(github.event.deployment_status.environment_url, 'https://documentation') && github.event.deployment_status.state == 'success' }}
# Runs if the deployment environment starts with 'preview' and the deployment status is 'success', and if the url does not contain 'analytics'
if: ${{ startsWith(github.event.deployment_status.environment, 'preview') && github.event.deployment_status.state == 'success' }} && !contains(github.event.deployment_status.environment_url, 'analytics')
steps:
- name: Run linkinator against deployment preview URL
run: npx --yes linkinator ${{ github.event.deployment_status.environment_url}} -r
- name: Checkout the repository
uses: actions/checkout@v4
- name: Run dead-link-checker
run: npx @jthrilly/dead-link-checker ${{ github.event.deployment_status.environment_url }} -v --yes
28 changes: 28 additions & 0 deletions .github/workflows/lint-and-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint and Format

on:
pull_request:
push:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install pnpm
run: npm install -g pnpm
- name: Cache pnpm
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Install dependencies
run: pnpm install
- name: Run Biome
run: pnpm biome check .
27 changes: 27 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Dependency Update Tests

on:
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install pnpm
run: npm install -g pnpm
- name: Cache pnpm
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Install dependencies
run: pnpm install
- name: Run All Tests
run: pnpm test
10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ node_modules
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/
**/.next/
**/out/

# production
/build
**/build

# misc
.DS_Store
Expand All @@ -30,7 +28,7 @@ yarn-error.log*
.env

# vercel
.vercel
**/.vercel

# typescript
*.tsbuildinfo
Expand Down
30 changes: 15 additions & 15 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"cSpell.enableFiletypes": [
"mdx"
],
"cSpell.words": [
"netcanvas",
"Tipbox"
]
}
"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"cSpell.words": ["netcanvas", "Tipbox"],
"editor.defaultFormatter": "biomejs.biome",
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"editor.codeActionsOnSave": {
"source.organizeImports": "always",
"source.fixAll": "always"
}
}
43 changes: 19 additions & 24 deletions apps/analytics-web/app/_actions/actions.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
'use server';
"use server";

import { type EventInsertType, db } from '~/db/db';
import { eventsTable } from '~/db/schema';
import { type EventInsertType, db } from "~/db/db";
import { eventsTable } from "~/db/schema";

export async function getEvents() {
try {
const events = await db.query.eventsTable.findMany({
orderBy: (events, { desc }) => [desc(events.timestamp)],
});
try {
const events = await db.query.eventsTable.findMany({
orderBy: (events, { desc }) => [desc(events.timestamp)],
});

return events;
} catch (error) {
// eslint-disable-next-line no-console
console.error('Error getting events', error);
return [];
}
return events;
} catch (error) {
console.error("Error getting events", error);
return [];
}
}

type Events = Awaited<ReturnType<typeof getEvents>>;
export type Event = Events[0];

export async function insertEvent(event: EventInsertType) {
try {
const insertedEvent = await db
.insert(eventsTable)
.values(event)
.returning();
try {
const insertedEvent = await db.insert(eventsTable).values(event).returning();

return { data: insertedEvent, error: null };
} catch (error) {
// eslint-disable-next-line no-console
console.error('Error inserting events', error);
return { data: null, error: 'Error inserting events' };
}
return { data: insertedEvent, error: null };
} catch (error) {
console.error("Error inserting events", error);
return { data: null, error: "Error inserting events" };
}
}
68 changes: 34 additions & 34 deletions apps/analytics-web/app/_components/analytics/AnalyticsView.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
import { getEvents } from '~/app/_actions/actions';
import { Card, CardContent, CardHeader } from '~/components/ui/card';
import EventsTable from './EventsTable/EventsTable';
import RegionsTable from './RegionsTable/RegionsTable';
import TotalAppsCard from './cards/TotalAppsCard';
import TotalDataExported from './cards/TotalDataExported';
import TotalErrorsCard from './cards/TotalErrorsCard';
import TotalInterviewsCompletedCard from './cards/TotalInterviewsCompletedCard';
import TotalInterviewsStartedCard from './cards/TotalInterviewsStartedCard';
import TotalProtocolsInstalledCard from './cards/TotalProtocolsInstalledCard';
import { getEvents } from "~/app/_actions/actions";
import { Card, CardContent, CardHeader } from "~/components/ui/card";
import EventsTable from "./EventsTable/EventsTable";
import RegionsTable from "./RegionsTable/RegionsTable";
import TotalAppsCard from "./cards/TotalAppsCard";
import TotalDataExported from "./cards/TotalDataExported";
import TotalErrorsCard from "./cards/TotalErrorsCard";
import TotalInterviewsCompletedCard from "./cards/TotalInterviewsCompletedCard";
import TotalInterviewsStartedCard from "./cards/TotalInterviewsStartedCard";
import TotalProtocolsInstalledCard from "./cards/TotalProtocolsInstalledCard";

export default async function AnalyticsView() {
const events = await getEvents();
const events = await getEvents();

return (
<div className="space-y-4">
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
<TotalAppsCard events={events} />
<TotalProtocolsInstalledCard events={events} />
<TotalInterviewsStartedCard events={events} />
<TotalInterviewsCompletedCard events={events} />
<TotalDataExported events={events} />
<TotalErrorsCard events={events} />
</div>
<div className="grid gap-4 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
<div className="lg:col-span-2">
<EventsTable />
</div>
<Card className="h-fit">
<CardHeader>Regions</CardHeader>
<CardContent>
<RegionsTable events={events} />
</CardContent>
</Card>
</div>
</div>
);
return (
<div className="space-y-4">
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
<TotalAppsCard events={events} />
<TotalProtocolsInstalledCard events={events} />
<TotalInterviewsStartedCard events={events} />
<TotalInterviewsCompletedCard events={events} />
<TotalDataExported events={events} />
<TotalErrorsCard events={events} />
</div>
<div className="grid gap-4 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
<div className="lg:col-span-2">
<EventsTable />
</div>
<Card className="h-fit">
<CardHeader>Regions</CardHeader>
<CardContent>
<RegionsTable events={events} />
</CardContent>
</Card>
</div>
</div>
);
}
Loading

0 comments on commit 75ac94c

Please sign in to comment.