mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 15:51:01 +08:00
Compare commits
3 Commits
2527056e85
...
ddec31401e
Author | SHA1 | Date | |
---|---|---|---|
ddec31401e | |||
378689da87 | |||
25760cf0d1 |
@ -1,4 +1,4 @@
|
||||
name: Build and Push Docker Image
|
||||
name: Build and Push Beta Image
|
||||
|
||||
on:
|
||||
push:
|
||||
|
2
.github/workflows/build_docker_image.yml
vendored
2
.github/workflows/build_docker_image.yml
vendored
@ -1,4 +1,4 @@
|
||||
name: Build and Push Docker Image
|
||||
name: Build and Push Latest Image
|
||||
|
||||
on:
|
||||
push:
|
||||
|
@ -82,7 +82,9 @@ const aiSummary = async () => {
|
||||
activateAiSummary.value = true;
|
||||
isGenerating.value = true;
|
||||
try {
|
||||
const req = await fetch(`/api/ai/summarize/${slug}?lang=${String(locale)}`);
|
||||
const req = await fetch(
|
||||
`/api/ai/summarize/${slug}?lang=${String(locale.value)}`,
|
||||
);
|
||||
const reader = req.body?.getReader();
|
||||
const decoder = new TextDecoder();
|
||||
while (reader) {
|
||||
|
@ -33,6 +33,13 @@ if (error === null) {
|
||||
errorMsg.value = error.value;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (data.length === 0) {
|
||||
eerrrroorr.value = true;
|
||||
errorMsg.value = "No data returned.";
|
||||
}
|
||||
});
|
||||
|
||||
async function getImageSource(image: string) {
|
||||
console.log(image);
|
||||
if (!image || image === "#") {
|
||||
|
@ -51,6 +51,15 @@ const createSources = await sql`
|
||||
)
|
||||
`;
|
||||
|
||||
const createArticlesArchive = await sql`
|
||||
create table if not exists news_articles (
|
||||
uuid text primary key,
|
||||
article_id text primary key,
|
||||
jsondata json not null,
|
||||
archive_timestamp timestamp default CURRENT_TIMESTAMP,
|
||||
)
|
||||
`;
|
||||
|
||||
console.log("Creation Complete");
|
||||
console.log(
|
||||
"If the script still does not quit after 2 seconds after the 'Creation Complete' message, please stop it by using Ctrl + C or on mac Control + C",
|
||||
|
@ -1,5 +1,6 @@
|
||||
import lineToday from "~/server/scrape/line_today";
|
||||
import sql from "~/server/components/postgres";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
interface CacheItems {
|
||||
title: string;
|
||||
@ -36,6 +37,23 @@ function cleanUpSlug(orgslug: string) {
|
||||
return slug;
|
||||
}
|
||||
|
||||
// Archive articles. For future use?
|
||||
async function storeArticlesIfItDoesNotExists(data, RequestId) {
|
||||
const checkDataIsInDatabase = await sql`
|
||||
SELECT * FROM news_articles
|
||||
WHERE jsondata = ${data}
|
||||
`;
|
||||
if (checkDataIsInDatabase.length === 0) {
|
||||
return;
|
||||
}
|
||||
const storeData = await sql`
|
||||
INSERT INTO news_articles (uuid, article_id, jsondata)
|
||||
VALUES (${uuidv4()}, ${RequestId}, ${data})
|
||||
`;
|
||||
console.log(storeData);
|
||||
return;
|
||||
}
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const translateQuery = getQuery(event).translate;
|
||||
const translate = translateQuery === "true" ? true : false;
|
||||
@ -54,6 +72,7 @@ export default defineEventHandler(async (event) => {
|
||||
|
||||
try {
|
||||
const data = await lineToday(cleanSlug);
|
||||
storeArticlesIfItDoesNotExists(data, cleanSlug);
|
||||
cache[cleanSlug] = {
|
||||
...data,
|
||||
timestamp: Date.now(),
|
||||
|
@ -1,11 +1,17 @@
|
||||
import getUserTokenMinusSQLInjection from "~/server/components/getUserToken";
|
||||
import sql from "~/server/components/postgres";
|
||||
export default defineEventHandler(async (event) => {
|
||||
const userToken = await getUserTokenMinusSQLInjection(event);
|
||||
if (userToken.error.length !== 0) {
|
||||
return {
|
||||
error: userToken.error,
|
||||
};
|
||||
}
|
||||
const getData = await sql`
|
||||
SELECT * FROM user_other_data
|
||||
WHERE username = ${userToken.user}
|
||||
`;
|
||||
return {
|
||||
items: [
|
||||
{
|
||||
name: "dfasdfa",
|
||||
article_link: "49redjvicjwsd",
|
||||
favTime: "2024-12-12",
|
||||
},
|
||||
],
|
||||
items: getData[0].starred_news,
|
||||
};
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user