Skip to content

Commit

Permalink
fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
thejessewinton committed Aug 2, 2024
1 parent e2a7678 commit 8b398c9
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 25 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ PUBLIC_APPWRITE_PROJECT_INIT_ID=
PUBLIC_GROWTH_ENDPOINT=
APPWRITE_DB_INIT_ID=
APPWRITE_COL_INIT_ID=
APPWRITE_COL_INIT_TWO_ID=
APPWRITE_API_KEY_INIT=
SENTRY_AUTH_TOKEN=
1 change: 0 additions & 1 deletion .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ jobs:
"PUBLIC_GROWTH_ENDPOINT=${{ vars.PUBLIC_GROWTH_ENDPOINT }}"
"APPWRITE_DB_INIT_ID=${{ secrets.APPWRITE_DB_INIT_ID }}"
"APPWRITE_COL_INIT_ID=${{ secrets.APPWRITE_COL_INIT_ID }}"
"APPWRITE_COL_INIT_TWO_ID=${{ secrets.APPWRITE_COL_INIT_TWO_ID }}"
"APPWRITE_API_KEY_INIT=${{ secrets.APPWRITE_API_KEY_INIT }}"
"GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}"
"SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}"
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
"PUBLIC_GROWTH_ENDPOINT=${{ vars.PUBLIC_GROWTH_ENDPOINT }}"
"APPWRITE_DB_INIT_ID=${{ secrets.APPWRITE_DB_INIT_ID }}"
"APPWRITE_COL_INIT_ID=${{ secrets.APPWRITE_COL_INIT_ID }}"
"APPWRITE_COL_INIT_TWO_ID=${{ secrets.APPWRITE_COL_INIT_TWO_ID }}"
"APPWRITE_API_KEY_INIT=${{ secrets.APPWRITE_API_KEY_INIT }}"
"GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}"
"SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}"
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ jobs:
PUBLIC_GROWTH_ENDPOINT: ${{ secrets.PUBLIC_GROWTH_ENDPOINT }}
APPWRITE_DB_INIT_ID: ${{ secrets.APPWRITE_DB_INIT_ID }}
APPWRITE_COL_INIT_ID: ${{ secrets.APPWRITE_COL_INIT_ID }}
APPWRITE_COL_INIT_TWO_ID: ${{ secrets.APPWRITE_COL_INIT_TWO_ID }}
APPWRITE_API_KEY_INIT: ${{ secrets.APPWRITE_API_KEY_INIT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm run build
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ ENV APPWRITE_DB_INIT_ID ${APPWRITE_DB_INIT_ID}
ARG APPWRITE_COL_INIT_ID
ENV APPWRITE_COL_INIT_ID ${APPWRITE_COL_INIT_ID}

ARG APPWRITE_COL_INIT_TWO_ID
ENV APPWRITE_COL_INIT_TWO_ID ${APPWRITE_COL_INIT_TWO_ID}

ARG APPWRITE_API_KEY_INIT
ENV APPWRITE_API_KEY_INIT ${APPWRITE_API_KEY_INIT}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { APPWRITE_DB_INIT_ID, APPWRITE_COL_INIT_TWO_ID } from '$env/static/private';
import { APPWRITE_DB_INIT_ID, APPWRITE_COL_INIT_ID } from '$env/static/private';
import { appwriteInitServer } from '$lib/appwrite/init.server';
import { parse } from 'node-html-parser';
import type { TicketData, ContributionsMatrix } from '../../constants';

export async function getContributions(id: string): Promise<ContributionsMatrix | null> {
const { gh_user, contributions } = (await appwriteInitServer.databases.getDocument(
APPWRITE_DB_INIT_ID,
APPWRITE_COL_INIT_TWO_ID,
APPWRITE_COL_INIT_ID,
id
)) as unknown as TicketData;

Expand Down Expand Up @@ -50,7 +50,7 @@ export async function getContributions(id: string): Promise<ContributionsMatrix
// Update the document with the new contributions
await appwriteInitServer.databases.updateDocument(
APPWRITE_DB_INIT_ID,
APPWRITE_COL_INIT_TWO_ID,
APPWRITE_COL_INIT_ID,
id,
{
contributions: matrix.flat()
Expand Down
4 changes: 2 additions & 2 deletions src/routes/init/tickets/[id]/og/+server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APPWRITE_COL_INIT_TWO_ID, APPWRITE_DB_INIT_ID } from '$env/static/private';
import { APPWRITE_COL_INIT_ID, APPWRITE_DB_INIT_ID } from '$env/static/private';
import { appwriteInitServer } from '$lib/appwrite/init.server';
import sharp from 'sharp';
import type { TicketData } from '../../constants.js';
Expand All @@ -7,7 +7,7 @@ import { getTicketSvg } from './getTicketSvg.server.js';
export async function GET({ params }) {
const ticket = (await appwriteInitServer.databases.getDocument(
APPWRITE_DB_INIT_ID,
APPWRITE_COL_INIT_TWO_ID,
APPWRITE_COL_INIT_ID,
params.id
)) as unknown as TicketData;
const svg = await getTicketSvg({ ...ticket });
Expand Down
21 changes: 10 additions & 11 deletions src/routes/init/tickets/get-ticket-doc/+server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { APPWRITE_DB_INIT_ID } from '$env/static/private';
import { env } from '$env/dynamic/private';
import { APPWRITE_DB_INIT_ID, APPWRITE_COL_INIT_ID } from '$env/static/private';
import { appwriteInitServer } from '$lib/appwrite/init.server';
import { isProUser } from '$lib/utils/console.js';
import type { User } from '$routes/init/helpers.js';
Expand Down Expand Up @@ -36,14 +35,14 @@ async function getTicketDocByUser(user: User) {
user.github?.login
? appwriteInitServer.databases.listDocuments(
APPWRITE_DB_INIT_ID,
env.APPWRITE_COL_INIT_TWO_ID,
APPWRITE_COL_INIT_ID,
[Query.equal('gh_user', user.github.login)]
)
: null,
user.appwrite?.$id
? appwriteInitServer.databases.listDocuments(
APPWRITE_DB_INIT_ID,
env.APPWRITE_COL_INIT_TWO_ID,
APPWRITE_COL_INIT_ID,
[Query.equal('aw_email', user.appwrite.email)]
)
: null,
Expand All @@ -60,7 +59,7 @@ async function getTicketDocByUser(user: User) {
const newest = gh_doc.id > aw_doc.id ? gh_doc.$id : aw_doc.$id;
await appwriteInitServer.databases.updateDocument(
APPWRITE_DB_INIT_ID,
env.APPWRITE_COL_INIT_TWO_ID,
APPWRITE_COL_INIT_ID,
oldest,
{
gh_user: null,
Expand All @@ -69,7 +68,7 @@ async function getTicketDocByUser(user: User) {
);
return (await appwriteInitServer.databases.updateDocument(
APPWRITE_DB_INIT_ID,
env.APPWRITE_COL_INIT_TWO_ID,
APPWRITE_COL_INIT_ID,
newest,
{
gh_user: user.github?.login,
Expand All @@ -84,7 +83,7 @@ async function getTicketDocByUser(user: User) {
if (!doc.gh_user || !doc.aw_email) {
return (await appwriteInitServer.databases.updateDocument(
APPWRITE_DB_INIT_ID,
env.APPWRITE_COL_INIT_TWO_ID,
APPWRITE_COL_INIT_ID,
doc.$id,
{
gh_user: user.github?.login,
Expand All @@ -97,7 +96,7 @@ async function getTicketDocByUser(user: User) {
if (!!user.appwrite && doc.is_pro !== isPro) {
return (await appwriteInitServer.databases.updateDocument(
APPWRITE_DB_INIT_ID,
env.APPWRITE_COL_INIT_TWO_ID,
APPWRITE_COL_INIT_ID,
doc.$id,
{
is_pro: isPro
Expand All @@ -111,11 +110,11 @@ async function getTicketDocByUser(user: User) {
// If no document exists, create one
const allDocs = await appwriteInitServer.databases.listDocuments(
APPWRITE_DB_INIT_ID,
env.APPWRITE_COL_INIT_TWO_ID
APPWRITE_COL_INIT_ID
);
return (await appwriteInitServer.databases.createDocument(
APPWRITE_DB_INIT_ID,
env.APPWRITE_COL_INIT_TWO_ID,
APPWRITE_COL_INIT_ID,
ID.unique(),
{
aw_email: user.appwrite?.email ?? undefined,
Expand All @@ -130,7 +129,7 @@ async function getTicketDocByUser(user: User) {
async function getTicketDocById(id: string) {
return (await appwriteInitServer.databases.getDocument(
APPWRITE_DB_INIT_ID,
env.APPWRITE_COL_INIT_TWO_ID,
APPWRITE_COL_INIT_ID,
id
)) as unknown as Omit<TicketData, 'contributions' | 'variant'>;
}
Expand Down
4 changes: 2 additions & 2 deletions src/routes/init/tickets/update/+server.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { APPWRITE_COL_INIT_TWO_ID, APPWRITE_DB_INIT_ID } from '$env/static/private';
import { APPWRITE_COL_INIT_ID, APPWRITE_DB_INIT_ID } from '$env/static/private';
import { appwriteInitServer } from '$lib/appwrite/init.server';

export async function POST({ request }) {
const data = await request.json();

await appwriteInitServer.databases.updateDocument(
APPWRITE_DB_INIT_ID,
APPWRITE_COL_INIT_TWO_ID,
APPWRITE_COL_INIT_ID,
data.ticketId,
{
name: data.name,
Expand Down

0 comments on commit 8b398c9

Please sign in to comment.