Skip to content

Conversation

@corwintines
Copy link
Member

Create a data layer
Refactor codebase to use data layer

…ntegrating blog feeds into daily data retrieval
…ng and processing for improved data handling
…ons for calendar events, attestant posts, and blog feeds
…cing utility functions and streamlining API integration
…ion utility and removing deprecated fetch function
…new extraction utilities and enhance error handling
…n utilities, replacing deprecated methods and enhancing data handling
…n utilities, enhancing data handling and integrating launch dates into the network page
…hancing layer-2 data handling and improving network page functionality
…lities, enhancing framework data integration and improving local environment page functionality
…ted methods with new extraction utilities, enhancing overall data handling and integration
…ock data files for improved data handling and integration
…port paths and enhancing error handling, improving overall data integration across various pages
@netlify
Copy link

netlify bot commented Nov 7, 2025

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 5483b59
🔍 Latest deploy log https://app.netlify.com/projects/ethereumorg/deploys/6916958bff7aae00089e2aa4
😎 Deploy Preview https://deploy-preview-16631--ethereumorg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 45 (🔴 down 8 from production)
Accessibility: 94 (no change from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 92 (no change from production)
PWA: 59 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added config ⚙️ Changes to configuration files dependencies 📦 Changes related to project dependencies tooling 🔧 Changes related to tooling of the project labels Nov 7, 2025
@corwintines corwintines marked this pull request as draft November 7, 2025 03:41
@corwintines corwintines marked this pull request as ready for review November 10, 2025 21:52
Copy link
Member

@pettinarip pettinarip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, @corwintines! I’ve left a few observations. I haven’t tested it yet, so this is more of a general code review.

Minor: it would be great to add some basic documentation explaining how to consume data using the data layer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this handler?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, had a local commit I hadnt pushed up

// Note: unstable_cache creates a new cached function each time, but Next.js manages
// the cache entries based on the keyParts, so this is efficient
try {
const cachedFetch = unstable_cache(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit unsure about this implementation since getExternalData creates a new function on each call, it likely won't be cached. The unstable_cache should instead wrap the exported function.

That said, I don't think the unstable_cache belongs at this level. It should be applied within each storage client implementation (eg getRedisData), since each client might use a different caching approach. For example, redis requires unstable_cache but a service using the native fetch API wouldn't need it. By placing the cache here, we're effectively locking ourselves into a specific caching strategy.

Copy link
Member Author

@corwintines corwintines Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for feedback. Pushed up refactor here around this that I believe addresses your points. Good point on making it service level, my bad.


// Build the data map
const dataMap = results.reduce((acc, { key, data }) => {
if (data !== null && data !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make sure we always return one value per key, even if it’s null or undefined, since those might be meaningful to the consumer. Or is that impossible to happen with current logic?

Im in favor of delegating error handling or custom logic to consumers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For organization purposes, would recommend placing all storage vendor files in a separate folder like data/clients.


return {
value: data,
timestamp: Date.now(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be handled by the fetchExternalData function? I think we should separate this strict return type from the fetcher functions.

We could do this automatically inside fetchExternalData:

const result = await service.function()
return { key: service.key, data: { value: result, timestamp: Date.now() } }

That way we simplify the usage of the data layer and we garantee that all the calls with have the same data structure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like an extra layer or glue code just to retrieve external data, and I think it could be simplified.

const [gfissuesResponse] = await getExternalData(["gfissues"], every("day"))
const { data: gfissues, timestamp, etc } = gfissuesResponse

The data you receive here depends entirely on what you return from your fetcher function. I'd still recommend keeping this logic inside each user-defined fetcher instead. That way, interacting with the data layer becomes simpler and more straightforward.

{
protocol: "https",
hostname: "avatars.githubusercontent.com",
hostname: "avatars*.githubusercontent.com",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to double check if this is a desired change. Asking because it looks a bit out of context.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting issues with these images coming back from avatars1, avatars2, avatars3, or avatars4.githubusercontent.com, so I had just put this in here for now. I could make a separate PR for this too, but was running into it while developing this.


if (upstashUrl && upstashToken) {
try {
const { Redis } = await import("@upstash/redis")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we import this dep like this?

would prefer to do as the docs:

import { Redis } from "@upstash/redis"

const redis = new Redis({
  url: <UPSTASH_REDIS_REST_URL>,
  token: <UPSTASH_REDIS_REST_TOKEN>,
})


if (supabaseUrl && supabaseAnonKey) {
try {
const { createClient } = await import("@supabase/supabase-js")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, imports at the top of the file.

…configuration and improving caching strategies for Redis and Supabase
…sted keys in the data map, improving clarity on key presence and handling of null/undefined values
…moving deprecated files to streamline data fetching utilities
…s instead of wrapped objects, enhancing clarity and consistency across the API
…consolidating response handling and removing deprecated extraction utilities, enhancing code clarity and maintainability
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config ⚙️ Changes to configuration files dependencies 📦 Changes related to project dependencies tooling 🔧 Changes related to tooling of the project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants