Skip to content

added summary part #1321

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

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 5 additions & 0 deletions backend/apps/owasp/graphql/nodes/snapshot.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ class SnapshotNode(GenericEntityNode):
"""Snapshot node."""

key = graphene.String()
summary = graphene.String() # ✅ Added to expose summary
new_chapters = graphene.List(ChapterNode)
new_issues = graphene.List(IssueNode)
new_projects = graphene.List(ProjectNode)
@@ -36,6 +37,10 @@ def resolve_key(self, info):
"""Resolve key."""
return self.key

def resolve_summary(self, info):
"""Resolve generated summary of the snapshot."""
return self.generate_summary()

def resolve_new_chapters(self, info):
"""Resolve new chapters."""
return self.new_chapters.all()
19 changes: 19 additions & 0 deletions backend/apps/owasp/models/snapshot.py
Original file line number Diff line number Diff line change
@@ -51,3 +51,22 @@ def save(self, *args, **kwargs):
self.key = now().strftime("%Y-%m")

super().save(*args, **kwargs)

def generate_summary(self):
"""Generate a brief summary of the snapshot contents."""
parts = []

if self.new_chapters.exists():
parts.append(f"{self.new_chapters.count()} chapters")
if self.new_issues.exists():
parts.append(f"{self.new_issues.count()} issues")
if self.new_projects.exists():
parts.append(f"{self.new_projects.count()} projects")
if self.new_releases.exists():
parts.append(f"{self.new_releases.count()} releases")
if self.new_users.exists():
parts.append(f"{self.new_users.count()} users")

if parts:
return "Added: " + ", ".join(parts)
return "No new entities added in this snapshot."
9 changes: 8 additions & 1 deletion frontend/src/components/SnapshotCard.tsx
Original file line number Diff line number Diff line change
@@ -4,12 +4,19 @@ import { Button } from '@heroui/button'
import { SnapshotCardProps } from 'types/card'
import { formatDate } from 'utils/dateFormatter'

const SnapshotCard = ({ title, button, startAt, endAt }: SnapshotCardProps) => {
const SnapshotCard = ({ title, button, startAt, endAt, summary }: SnapshotCardProps) => {
return (
<Button
onClick={button.onclick}
className="group flex h-40 w-full flex-col items-center rounded-lg bg-white p-6 text-left shadow-lg transition-transform duration-500 hover:scale-105 hover:shadow-xl dark:bg-gray-800 dark:shadow-gray-900/30"
>
{/* Snapshot Summary */}
{summary && (
<div className="mb-2 w-full text-xs text-gray-500 dark:text-gray-300 text-center">
{summary}
</div>
)}

<div className="text-center">
<h3 className="max-w-[250px] text-balance text-lg font-semibold text-gray-900 group-hover:text-blue-400 dark:text-white sm:text-xl">
<p>{title}</p>
1 change: 1 addition & 0 deletions frontend/src/types/card.ts
Original file line number Diff line number Diff line change
@@ -67,4 +67,5 @@ export interface SnapshotCardProps {
endAt: string
title: string
button: ButtonType
summary: string
}
1 change: 1 addition & 0 deletions frontend/src/types/snapshot.ts
Original file line number Diff line number Diff line change
@@ -23,4 +23,5 @@ export interface Snapshots {
key: string
startAt: string
title: string
summary: string
}