Skip to content
Draft
Show file tree
Hide file tree
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
17 changes: 16 additions & 1 deletion .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,15 @@ jobs:
name: database.json
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ steps.get_id.outputs.previous_run_id }}
continue-on-error: true
continue-on-error: true

- name: Download previous metrics artifact
uses: actions/download-artifact@v8
with:
name: metrics.sqlite
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ steps.get_id.outputs.previous_run_id }}
continue-on-error: true

- name: Call RescueGroups API
env:
Expand All @@ -92,6 +100,13 @@ jobs:
path: database.json
retention-days: 1
archive: false

- name: Upload metrics artifact
uses: actions/upload-artifact@v7
with:
path: metrics.sqlite
retention-days: 1
archive: false

- name: Upload Log artifact
if: '!cancelled()' #This ensures this step runs even if the previous steps failed only if manually cancelled it doesnt run
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ jobs:
name: database.json
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ steps.get_id.outputs.previous_run_id }}
continue-on-error: true
continue-on-error: true

- name: Download previous metrics artifact
uses: actions/download-artifact@v8
with:
name: metrics.sqlite
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ steps.get_id.outputs.previous_run_id }}
continue-on-error: true

- name: Call RescueGroups API
env:
Expand All @@ -73,6 +81,13 @@ jobs:
retention-days: 14
archive: false

- name: Upload metrics artifact
uses: actions/upload-artifact@v7
with:
path: metrics.sqlite
retention-days: 14
archive: false

- name: Upload API Log artifact
if: '!cancelled()' #This ensures this step runs even if the previous steps failed only if manually cancelled it doesnt run
uses: actions/upload-artifact@v7
Expand Down
32 changes: 32 additions & 0 deletions abstractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,35 @@ def format_post(self, pet: AdoptablePet) -> Post:
pet.breed.lower().replace(" ", ""),
],
)


# =============================================================================
# Engagement Metric Collector Interface
# =============================================================================


@dataclass
class PostMetrics:
"""Point-in-time engagement counts for a published post."""

collected_at: str
likes: int | None = None
reposts: int | None = None
comments: int | None = None


class MetricCollector(ABC):
"""Interface for collecting engagement metrics from a social platform."""

@property
@abstractmethod
def platform_name(self) -> str:
"""Return the platform name used in persisted post records."""
...

@abstractmethod
def fetch_metrics(
self, post_id: str, post_url: str | None = None
) -> PostMetrics | None:
"""Return a metric snapshot, or None when the post cannot be read."""
...
271 changes: 271 additions & 0 deletions docs/specs/metric-collector.md

Large diffs are not rendered by default.

Loading
Loading