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: anonymous posts #44

Merged
merged 6 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/check-formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Pre-commit Checks

on:
pull_request:
paths:
- '**/*.{js,jsx,ts,tsx,json,css,scss,md}'

jobs:
pre-commit-checks:
runs-on: ubuntu-latest
steps:
- name: Run Prettier
run: yarn format-check
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ yarn-error.log*
next-env.d.ts

userbase.csv
pscale_dump_apunts-dades_main_20240310_112108
pscale_dump_apunts-dades_main_20240310_112108
prisma/migrations
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": false,
"semi": false,
"tabWidth": 2,
"printWidth": 80
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
}
10 changes: 6 additions & 4 deletions .vscode/typescriptreact.json.code-snippets
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"Typescript React Function Component": {
{
"Typescript React Function Component": {
"prefix": "fc",
"body": [
"import { FC } from 'react'",
Expand All @@ -11,7 +12,8 @@
" return <div>$TM_FILENAME_BASE</div>",
"}",
"",
"export default $TM_FILENAME_BASE"
"export default $TM_FILENAME_BASE",
],
"description": "Typescript React Function Component"
},
"description": "Typescript React Function Component",
},
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Benvinguts al repo d'Apunts Dades

## M'agradaria contribuir:

Obre un [Issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-an-issue) explicant una mica què t'agradaria que s'afegís, preferiblement [etiqueta l'issue segons el tipus](https://docs.github.com/en/issues/using-labels-and-milestones-to-track-work/managing-labels).

Si t'animes a fer la implementació de qualsevol issue no assignat a ningú afegeix un comentari avisant que estàs en ello i quan estigui resolt envia una [PR enllaçada a l'Issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) explicant una mica com ho has solucionat.

No fa falta que estigui tot perfecte ni que tinguis molta experiència en software. Des de l'AED animem a tothom qui en tingui ganes a contribuir i intentarem donar suport en la mesura del que ens sigui possible amb els recursos dels que disposem.

Si necessites credencials de dev per alguna api escriu-nos.
Si necessites credencials de dev per alguna api escriu-nos.
2 changes: 1 addition & 1 deletion components.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"components": "@/components",
"utils": "@/lib/utils"
}
}
}
6 changes: 3 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
domains: ['uploadthing.com', 'lh3.googleusercontent.com'],
domains: ["uploadthing.com", "lh3.googleusercontent.com"],
},
experimental: {
appDir: true
}
appDir: true,
},
}

module.exports = nextConfig
18 changes: 17 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,24 @@
"build": "prisma db push && prisma db seed && next build",
"start": "next start",
"lint": "next lint",
"postinstall": "prisma generate"
"postinstall": "prisma generate",
"format": "prettier --write .",
"format-check": "prettier --check ."
},
"prisma": {
"seed": "node prisma/seed.js"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,jsx,ts,tsx,json,css,scss,md}": [
"prettier --write",
"git add"
]
},
"dependencies": {
"@editorjs/attaches": "^1.3.0",
"@editorjs/code": "^2.8.0",
Expand Down Expand Up @@ -86,6 +99,9 @@
"devDependencies": {
"@types/editorjs__header": "^2.6.0",
"@types/lodash.debounce": "^4.0.7",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"prisma": "^5.9.1"
}
}
32 changes: 16 additions & 16 deletions prisma/accountVerify.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
const { PrismaClient } = require("@prisma/client");
const Papa = require("papaparse");
const fs = require("fs");
const { PrismaClient } = require("@prisma/client")
const Papa = require("papaparse")
const fs = require("fs")

const prisma = new PrismaClient();
const prisma = new PrismaClient()

async function processUserRequests() {
const userbasePath = "userbase.csv";
const userBaseFileData = fs.readFileSync(userbasePath, "utf8");
const verifiedValid = ["sí", "si"];
const userbasePath = "userbase.csv"
const userBaseFileData = fs.readFileSync(userbasePath, "utf8")
const verifiedValid = ["sí", "si"]
const parsedUserBase = Papa.parse(userBaseFileData, {
header: true, // Assuming the first row contains the headers
dynamicTyping: true, // Automatically convert strings to their appropriate data type
skipEmptyLines: true, // Skip empty lines in the CSV
complete: function async(result) {
result.data.forEach(async (row) => {
const email = row.email;
const generacio = row.generacio;
const verificat = row.verificat;
const email = row.email
const generacio = row.generacio
const verificat = row.verificat

if (verificat && verifiedValid.includes(verificat.toLowerCase())) {
const existingUser = await prisma.authorizedUsers.findUnique({
where: {
email: email,
},
});
})
if (!existingUser) {
await prisma.authorizedUsers.create({
data: {
email: email,
generacio: generacio,
createdAt: new Date(),
},
});
})
}
}
});
})
},
});
await prisma.$disconnect();
})
await prisma.$disconnect()
}

processUserRequests();
processUserRequests()
31 changes: 16 additions & 15 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ model User {
}

model AuthorizedUsers {
email String @id
email String @id
generacio Int
createdAt DateTime @default(now())
}
Expand Down Expand Up @@ -86,26 +86,27 @@ model Question {
updatedAt DateTime @updatedAt
subjectId String
authorId String
subject Subject @relation(fields: [subjectId], references: [id])
subject Subject @relation(fields: [subjectId], references: [id])
author User @relation(fields: [authorId], references: [id])
answers Answer[]
votes QuestionVote[]
}

model Post {
id String @id @default(cuid())
title String
content String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
subjectId String
authorId String
tipus TipusType
year Int
subject Subject @relation(fields: [subjectId], references: [id])
author User @relation(fields: [authorId], references: [id])
comments Comment[]
votes PostVote[]
id String @id @default(cuid())
title String
content String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
subjectId String
authorId String
tipus TipusType
year Int
isAnonymous Boolean @default(false)
subject Subject @relation(fields: [subjectId], references: [id])
author User @relation(fields: [authorId], references: [id])
comments Comment[]
votes PostVote[]
}

model Answer {
Expand Down
Loading