Move Gitea feed from frontend to backend with cached GraphQL proxy
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 4m39s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 4m39s
Replaces direct browser-to-Gitea API calls with a backend service that proxies and caches the feed (1-min TTL), served via the existing GraphQL HomeData query. Commit message parsing now happens server-side. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,59 +1,36 @@
|
||||
<script setup>
|
||||
import axios from "axios";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useHomeDataStore } from "@/stores/homeData";
|
||||
import { storeToRefs } from "pinia";
|
||||
import Header from "@/components/text/Header.vue";
|
||||
|
||||
const url = "/gitea/api/v1/users/adamf/activities/feeds?limit=1";
|
||||
|
||||
const feed = ref(null);
|
||||
const isLoading = ref(true);
|
||||
const hasError = ref(false);
|
||||
|
||||
async function checkFeed() {
|
||||
try {
|
||||
const res = await axios.get(url);
|
||||
feed.value = res.data[0] || null;
|
||||
hasError.value = false;
|
||||
} catch (err) {
|
||||
hasError.value = true;
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
checkFeed();
|
||||
});
|
||||
const homeData = useHomeDataStore();
|
||||
const { gitFeed: feed, loaded } = storeToRefs(homeData);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col text-center h-full">
|
||||
<Header class="text-left">Commits</Header>
|
||||
|
||||
<div v-if="isLoading" class="flex-1 overflow-y-auto">
|
||||
<div v-if="!loaded" class="flex-1 overflow-y-auto">
|
||||
<p>Loading latest activity...</p>
|
||||
</div>
|
||||
|
||||
<div v-else-if="hasError" class="flex-1 overflow-y-auto">
|
||||
<p>Could not fetch feed. Please try again later.</p>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-else-if="feed"
|
||||
class="flex-1 flex flex-col justify-center overflow-y-auto"
|
||||
>
|
||||
<h3>Last git activity</h3>
|
||||
<img
|
||||
:src="feed.act_user.avatar_url"
|
||||
:src="feed.avatarUrl"
|
||||
alt="User avatar"
|
||||
class="avatar"
|
||||
/>
|
||||
<a :href="feed.repo.html_url">
|
||||
<h3>repo: {{ feed.repo.full_name }}</h3>
|
||||
<a :href="feed.repoUrl">
|
||||
<h3>repo: {{ feed.repoName }}</h3>
|
||||
</a>
|
||||
<p>Action: {{ feed.op_type }}</p>
|
||||
<p>Message: {{ JSON.parse(feed.content).Commits[0].Message }}</p>
|
||||
<small> {{ new Date(feed.created).toLocaleString() }}</small>
|
||||
<p>Action: {{ feed.opType }}</p>
|
||||
<p>Message: {{ feed.commitMessage }}</p>
|
||||
<small> {{ new Date(feed.createdAt).toLocaleString() }}</small>
|
||||
</div>
|
||||
|
||||
<div v-else class="flex-1 overflow-y-auto">
|
||||
|
||||
@@ -26,10 +26,10 @@ export const useHomeDataStore = defineStore("homeData", () => {
|
||||
activities { id type name link createdAt }
|
||||
spotifyRecent { track { name album { name images { url } } artists { name } } playedAt }
|
||||
rowingSessions { id date time distance timePer500m calories }
|
||||
giteaFeed { avatarUrl repoUrl repoName opType commitMessage createdAt }
|
||||
me { id username admin }
|
||||
}
|
||||
`),
|
||||
fetchGitFeed(),
|
||||
fetchRadioStatus(),
|
||||
]);
|
||||
posts.value = data.posts;
|
||||
@@ -37,6 +37,7 @@ export const useHomeDataStore = defineStore("homeData", () => {
|
||||
activities.value = data.activities;
|
||||
spotifyRecent.value = data.spotifyRecent;
|
||||
rowingSessions.value = data.rowingSessions;
|
||||
gitFeed.value = data.giteaFeed || null;
|
||||
me.value = data.me || null;
|
||||
loaded.value = true;
|
||||
} catch (err) {
|
||||
@@ -45,15 +46,6 @@ export const useHomeDataStore = defineStore("homeData", () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchGitFeed() {
|
||||
try {
|
||||
const res = await axios.get("/gitea/api/v1/users/adamf/activities/feeds?limit=1");
|
||||
gitFeed.value = res.data[0] || null;
|
||||
} catch {
|
||||
gitFeed.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchRadioStatus() {
|
||||
try {
|
||||
await axios.head("/radio/stream");
|
||||
|
||||
Reference in New Issue
Block a user