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_ID=espace.slm-lab.net
|
||||||
NEXTCLOUD_CLIENT_SECRET=YHLVMGpu0nGRaP7gMDpSjRr1ia6HiSr1
|
NEXTCLOUD_CLIENT_SECRET=YHLVMGpu0nGRaP7gMDpSjRr1ia6HiSr1
|
||||||
|
|
||||||
|
# Agenda/Calendar database (Prisma)
|
||||||
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/calendar_db?schema=public"
|
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/calendar_db?schema=public"
|
||||||
|
|
||||||
# Sidebar iframes
|
# Sidebar iframes
|
||||||
@ -46,5 +47,12 @@ ROCKET_CHAT_TOKEN=w91TYgkH-Z67Oz72usYdkW5TZLLRwnre7qyAhp7aHJB
|
|||||||
ROCKET_CHAT_USER_ID=Tpuww59PJKsrGNQJB
|
ROCKET_CHAT_USER_ID=Tpuww59PJKsrGNQJB
|
||||||
LEANTIME_TOKEN=lt_lsdShQdoYHaPUWuL07XZR1Rf3GeySsIs_UDlll3VJPk5EwAuILpMC4BwzJ9MZFRrb
|
LEANTIME_TOKEN=lt_lsdShQdoYHaPUWuL07XZR1Rf3GeySsIs_UDlll3VJPk5EwAuILpMC4BwzJ9MZFRrb
|
||||||
LEANTIME_API_URL=https://agilite.slm-lab.net
|
LEANTIME_API_URL=https://agilite.slm-lab.net
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
NEWSDB_URL=postgresql://alma:Sict33711###@cube.governance-labs.com/rivacube
|
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 { 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() {
|
export async function GET() {
|
||||||
try {
|
try {
|
||||||
const news = await prisma.news.findMany({
|
const client = await pool.connect();
|
||||||
orderBy: {
|
try {
|
||||||
date: 'desc'
|
const result = await client.query(
|
||||||
},
|
`SELECT id, title, date, source, description, category, url
|
||||||
take: 5,
|
FROM news
|
||||||
select: {
|
ORDER BY date DESC
|
||||||
id: true,
|
LIMIT 5`
|
||||||
title: true,
|
);
|
||||||
date: true,
|
|
||||||
source: true,
|
|
||||||
description: true,
|
|
||||||
category: true,
|
|
||||||
url: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return NextResponse.json(news);
|
return NextResponse.json(result.rows);
|
||||||
|
} finally {
|
||||||
|
client.release();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching news:', error);
|
console.error('Error fetching news:', error);
|
||||||
return NextResponse.json(
|
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'
|
Serializable: 'Serializable'
|
||||||
});
|
});
|
||||||
|
|
||||||
exports.Prisma.CalendarScalarFieldEnum = {
|
exports.Prisma.NewsScalarFieldEnum = {
|
||||||
id: 'id',
|
|
||||||
name: 'name',
|
|
||||||
color: 'color',
|
|
||||||
description: 'description',
|
|
||||||
userId: 'userId',
|
|
||||||
createdAt: 'createdAt',
|
|
||||||
updatedAt: 'updatedAt'
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.Prisma.EventScalarFieldEnum = {
|
|
||||||
id: 'id',
|
id: 'id',
|
||||||
title: 'title',
|
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',
|
description: 'description',
|
||||||
start: 'start',
|
category: 'category'
|
||||||
end: 'end',
|
|
||||||
location: 'location',
|
|
||||||
isAllDay: 'isAllDay',
|
|
||||||
calendarId: 'calendarId',
|
|
||||||
createdAt: 'createdAt',
|
|
||||||
updatedAt: 'updatedAt'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.Prisma.SortOrder = {
|
exports.Prisma.SortOrder = {
|
||||||
@ -157,8 +150,7 @@ exports.Prisma.NullsOrder = {
|
|||||||
|
|
||||||
|
|
||||||
exports.Prisma.ModelName = {
|
exports.Prisma.ModelName = {
|
||||||
Calendar: 'Calendar',
|
News: 'News'
|
||||||
Event: 'Event'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
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",
|
"main": "index.js",
|
||||||
"types": "index.d.ts",
|
"types": "index.d.ts",
|
||||||
"browser": "index-browser.js",
|
"browser": "index-browser.js",
|
||||||
|
|||||||
51
node_modules/.prisma/client/schema.prisma
generated
vendored
51
node_modules/.prisma/client/schema.prisma
generated
vendored
@ -1,39 +1,30 @@
|
|||||||
|
// This is your Prisma schema file for the news database
|
||||||
generator client {
|
generator client {
|
||||||
provider = "prisma-client-js"
|
provider = "prisma-client-js"
|
||||||
|
binaryTargets = ["native", "linux-arm64-openssl-3.0.x"]
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
provider = "postgresql"
|
provider = "postgresql"
|
||||||
//TODO: Modifier l'url
|
url = env("NEWSDB_URL")
|
||||||
url = "postgresql://enkun:183d9ad665c9257703c2e0703f111d240266a56b33e10df04fb8c565e55e0b94@172.16.32.141:5432/enkun?schema=public"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
model Calendar {
|
model News {
|
||||||
id String @id @default(cuid())
|
id Int @id @default(autoincrement())
|
||||||
name String
|
title String
|
||||||
color String @default("#0082c9")
|
url String @unique
|
||||||
description String?
|
date DateTime
|
||||||
userId String
|
source String
|
||||||
createdAt DateTime @default(now())
|
content String?
|
||||||
updatedAt DateTime @updatedAt
|
sentiment_score Float?
|
||||||
events Event[]
|
sentiment String?
|
||||||
|
symbols String[]
|
||||||
|
symbol String?
|
||||||
|
processed_at DateTime @default(now())
|
||||||
|
description String?
|
||||||
|
category String? @db.VarChar(50)
|
||||||
|
|
||||||
@@index([userId])
|
@@index([category])
|
||||||
}
|
@@index([date])
|
||||||
|
@@index([symbol])
|
||||||
model Event {
|
|
||||||
id String @id @default(cuid())
|
|
||||||
title String
|
|
||||||
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
|
|
||||||
|
|
||||||
@@index([calendarId])
|
|
||||||
@@index([start, end])
|
|
||||||
}
|
}
|
||||||
|
|||||||
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'
|
Serializable: 'Serializable'
|
||||||
});
|
});
|
||||||
|
|
||||||
exports.Prisma.CalendarScalarFieldEnum = {
|
exports.Prisma.NewsScalarFieldEnum = {
|
||||||
id: 'id',
|
|
||||||
name: 'name',
|
|
||||||
color: 'color',
|
|
||||||
description: 'description',
|
|
||||||
userId: 'userId',
|
|
||||||
createdAt: 'createdAt',
|
|
||||||
updatedAt: 'updatedAt'
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.Prisma.EventScalarFieldEnum = {
|
|
||||||
id: 'id',
|
id: 'id',
|
||||||
title: 'title',
|
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',
|
description: 'description',
|
||||||
start: 'start',
|
category: 'category'
|
||||||
end: 'end',
|
|
||||||
location: 'location',
|
|
||||||
isAllDay: 'isAllDay',
|
|
||||||
calendarId: 'calendarId',
|
|
||||||
createdAt: 'createdAt',
|
|
||||||
updatedAt: 'updatedAt'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.Prisma.SortOrder = {
|
exports.Prisma.SortOrder = {
|
||||||
@ -157,8 +150,7 @@ exports.Prisma.NullsOrder = {
|
|||||||
|
|
||||||
|
|
||||||
exports.Prisma.ModelName = {
|
exports.Prisma.ModelName = {
|
||||||
Calendar: 'Calendar',
|
News: 'News'
|
||||||
Event: 'Event'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
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")
|
url = env("DATABASE_URL")
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource newsdb {
|
|
||||||
provider = "postgresql"
|
|
||||||
url = env("NEWSDB_URL")
|
|
||||||
}
|
|
||||||
|
|
||||||
model Calendar {
|
model Calendar {
|
||||||
id String @id @default(uuid())
|
id String @id @default(uuid())
|
||||||
name String
|
name String
|
||||||
@ -46,23 +41,3 @@ model Event {
|
|||||||
@@index([calendarId])
|
@@index([calendarId])
|
||||||
@@index([userId])
|
@@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