correction news widget v5
This commit is contained in:
commit
220ad5fdb5
8
.env
8
.env
@ -11,6 +11,7 @@ NEXTCLOUD_URL=https://espace.slm-lab.net
|
||||
NEXTCLOUD_CLIENT_ID=espace.slm-lab.net
|
||||
NEXTCLOUD_CLIENT_SECRET=YHLVMGpu0nGRaP7gMDpSjRr1ia6HiSr1
|
||||
|
||||
# Agenda/Calendar database (Prisma)
|
||||
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/calendar_db?schema=public"
|
||||
|
||||
# Sidebar iframes
|
||||
@ -46,5 +47,12 @@ ROCKET_CHAT_TOKEN=w91TYgkH-Z67Oz72usYdkW5TZLLRwnre7qyAhp7aHJB
|
||||
ROCKET_CHAT_USER_ID=Tpuww59PJKsrGNQJB
|
||||
LEANTIME_TOKEN=lt_lsdShQdoYHaPUWuL07XZR1Rf3GeySsIs_UDlll3VJPk5EwAuILpMC4BwzJ9MZFRrb
|
||||
LEANTIME_API_URL=https://agilite.slm-lab.net
|
||||
<<<<<<< HEAD
|
||||
|
||||
NEWSDB_URL=postgresql://alma:Sict33711###@cube.governance-labs.com/rivacube
|
||||
=======
|
||||
DB_USER=alma
|
||||
DB_PASSWORD=Sict33711###
|
||||
DB_NAME=rivacube
|
||||
DB_HOST=cube.governance-labs.com
|
||||
>>>>>>> 1abc8e9fe8b5d9382da1c53238741114288da34c
|
||||
|
||||
@ -1,25 +1,25 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
import { Pool } from 'pg';
|
||||
|
||||
const pool = new Pool({
|
||||
connectionString: process.env.NEWSDB_URL,
|
||||
});
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const news = await prisma.news.findMany({
|
||||
orderBy: {
|
||||
date: 'desc'
|
||||
},
|
||||
take: 5,
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
date: true,
|
||||
source: true,
|
||||
description: true,
|
||||
category: true,
|
||||
url: true
|
||||
}
|
||||
});
|
||||
const client = await pool.connect();
|
||||
try {
|
||||
const result = await client.query(
|
||||
`SELECT id, title, date, source, description, category, url
|
||||
FROM news
|
||||
ORDER BY date DESC
|
||||
LIMIT 5`
|
||||
);
|
||||
|
||||
return NextResponse.json(news);
|
||||
return NextResponse.json(result.rows);
|
||||
} finally {
|
||||
client.release();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching news:', error);
|
||||
return NextResponse.json(
|
||||
|
||||
13
lib/prisma-news.ts
Normal file
13
lib/prisma-news.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { PrismaClient } from '@prisma/client/news'
|
||||
|
||||
const globalForPrisma = globalThis as unknown as {
|
||||
prismaNews: PrismaClient | undefined;
|
||||
}
|
||||
|
||||
export const prismaNews =
|
||||
globalForPrisma.prismaNews ||
|
||||
new PrismaClient({
|
||||
log: ['query'],
|
||||
})
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') globalForPrisma.prismaNews = prismaNews
|
||||
59
node_modules/.prisma/client/edge.js
generated
vendored
59
node_modules/.prisma/client/edge.js
generated
vendored
File diff suppressed because one or more lines are too long
32
node_modules/.prisma/client/index-browser.js
generated
vendored
32
node_modules/.prisma/client/index-browser.js
generated
vendored
@ -117,27 +117,20 @@ exports.Prisma.TransactionIsolationLevel = makeStrictEnum({
|
||||
Serializable: 'Serializable'
|
||||
});
|
||||
|
||||
exports.Prisma.CalendarScalarFieldEnum = {
|
||||
id: 'id',
|
||||
name: 'name',
|
||||
color: 'color',
|
||||
description: 'description',
|
||||
userId: 'userId',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt'
|
||||
};
|
||||
|
||||
exports.Prisma.EventScalarFieldEnum = {
|
||||
exports.Prisma.NewsScalarFieldEnum = {
|
||||
id: 'id',
|
||||
title: 'title',
|
||||
url: 'url',
|
||||
date: 'date',
|
||||
source: 'source',
|
||||
content: 'content',
|
||||
sentiment_score: 'sentiment_score',
|
||||
sentiment: 'sentiment',
|
||||
symbols: 'symbols',
|
||||
symbol: 'symbol',
|
||||
processed_at: 'processed_at',
|
||||
description: 'description',
|
||||
start: 'start',
|
||||
end: 'end',
|
||||
location: 'location',
|
||||
isAllDay: 'isAllDay',
|
||||
calendarId: 'calendarId',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt'
|
||||
category: 'category'
|
||||
};
|
||||
|
||||
exports.Prisma.SortOrder = {
|
||||
@ -157,8 +150,7 @@ exports.Prisma.NullsOrder = {
|
||||
|
||||
|
||||
exports.Prisma.ModelName = {
|
||||
Calendar: 'Calendar',
|
||||
Event: 'Event'
|
||||
News: 'News'
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
3403
node_modules/.prisma/client/index.d.ts
generated
vendored
3403
node_modules/.prisma/client/index.d.ts
generated
vendored
File diff suppressed because it is too large
Load Diff
59
node_modules/.prisma/client/index.js
generated
vendored
59
node_modules/.prisma/client/index.js
generated
vendored
File diff suppressed because one or more lines are too long
2
node_modules/.prisma/client/package.json
generated
vendored
2
node_modules/.prisma/client/package.json
generated
vendored
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "prisma-client-a39bf2eb34241f9f263bba0d47613aa7e5863c7141c09c9c46ea39fc56dce086",
|
||||
"name": "prisma-client-eeb846ee0ec87fa2c130414bdb67895badd3ab3283962f9d99affb3454d642b0",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"browser": "index-browser.js",
|
||||
|
||||
45
node_modules/.prisma/client/schema.prisma
generated
vendored
45
node_modules/.prisma/client/schema.prisma
generated
vendored
@ -1,39 +1,30 @@
|
||||
// This is your Prisma schema file for the news database
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
binaryTargets = ["native", "linux-arm64-openssl-3.0.x"]
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
//TODO: Modifier l'url
|
||||
url = "postgresql://enkun:183d9ad665c9257703c2e0703f111d240266a56b33e10df04fb8c565e55e0b94@172.16.32.141:5432/enkun?schema=public"
|
||||
url = env("NEWSDB_URL")
|
||||
}
|
||||
|
||||
model Calendar {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
color String @default("#0082c9")
|
||||
description String?
|
||||
userId String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
events Event[]
|
||||
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
model Event {
|
||||
id String @id @default(cuid())
|
||||
model News {
|
||||
id Int @id @default(autoincrement())
|
||||
title String
|
||||
url String @unique
|
||||
date DateTime
|
||||
source String
|
||||
content String?
|
||||
sentiment_score Float?
|
||||
sentiment String?
|
||||
symbols String[]
|
||||
symbol String?
|
||||
processed_at DateTime @default(now())
|
||||
description String?
|
||||
start DateTime
|
||||
end DateTime
|
||||
location String?
|
||||
isAllDay Boolean @default(false)
|
||||
calendar Calendar @relation(fields: [calendarId], references: [id], onDelete: Cascade)
|
||||
calendarId String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
category String? @db.VarChar(50)
|
||||
|
||||
@@index([calendarId])
|
||||
@@index([start, end])
|
||||
@@index([category])
|
||||
@@index([date])
|
||||
@@index([symbol])
|
||||
}
|
||||
|
||||
32
node_modules/.prisma/client/wasm.js
generated
vendored
32
node_modules/.prisma/client/wasm.js
generated
vendored
@ -117,27 +117,20 @@ exports.Prisma.TransactionIsolationLevel = makeStrictEnum({
|
||||
Serializable: 'Serializable'
|
||||
});
|
||||
|
||||
exports.Prisma.CalendarScalarFieldEnum = {
|
||||
id: 'id',
|
||||
name: 'name',
|
||||
color: 'color',
|
||||
description: 'description',
|
||||
userId: 'userId',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt'
|
||||
};
|
||||
|
||||
exports.Prisma.EventScalarFieldEnum = {
|
||||
exports.Prisma.NewsScalarFieldEnum = {
|
||||
id: 'id',
|
||||
title: 'title',
|
||||
url: 'url',
|
||||
date: 'date',
|
||||
source: 'source',
|
||||
content: 'content',
|
||||
sentiment_score: 'sentiment_score',
|
||||
sentiment: 'sentiment',
|
||||
symbols: 'symbols',
|
||||
symbol: 'symbol',
|
||||
processed_at: 'processed_at',
|
||||
description: 'description',
|
||||
start: 'start',
|
||||
end: 'end',
|
||||
location: 'location',
|
||||
isAllDay: 'isAllDay',
|
||||
calendarId: 'calendarId',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt'
|
||||
category: 'category'
|
||||
};
|
||||
|
||||
exports.Prisma.SortOrder = {
|
||||
@ -157,8 +150,7 @@ exports.Prisma.NullsOrder = {
|
||||
|
||||
|
||||
exports.Prisma.ModelName = {
|
||||
Calendar: 'Calendar',
|
||||
Event: 'Event'
|
||||
News: 'News'
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
30
prisma/news.schema.prisma
Normal file
30
prisma/news.schema.prisma
Normal file
@ -0,0 +1,30 @@
|
||||
// This is your Prisma schema file for the news database
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
binaryTargets = ["native", "linux-arm64-openssl-3.0.x"]
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("NEWSDB_URL")
|
||||
}
|
||||
|
||||
model News {
|
||||
id Int @id @default(autoincrement())
|
||||
title String
|
||||
url String @unique
|
||||
date DateTime
|
||||
source String
|
||||
content String?
|
||||
sentiment_score Float?
|
||||
sentiment String?
|
||||
symbols String[]
|
||||
symbol String?
|
||||
processed_at DateTime @default(now())
|
||||
description String?
|
||||
category String? @db.VarChar(50)
|
||||
|
||||
@@index([category])
|
||||
@@index([date])
|
||||
@@index([symbol])
|
||||
}
|
||||
@ -11,11 +11,6 @@ datasource db {
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
datasource newsdb {
|
||||
provider = "postgresql"
|
||||
url = env("NEWSDB_URL")
|
||||
}
|
||||
|
||||
model Calendar {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
@ -46,23 +41,3 @@ model Event {
|
||||
@@index([calendarId])
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
model News {
|
||||
id Int @id @default(autoincrement())
|
||||
title String
|
||||
url String @unique
|
||||
date DateTime
|
||||
source String
|
||||
content String?
|
||||
sentiment_score Float?
|
||||
sentiment String?
|
||||
symbols String[]
|
||||
symbol String?
|
||||
processed_at DateTime @default(now())
|
||||
description String?
|
||||
category String? @db.VarChar(50)
|
||||
|
||||
@@index([category])
|
||||
@@index([date])
|
||||
@@index([symbol])
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user