Skip to content

fetch more data - #10

Merged
santoshyadavdev merged 2 commits into
mainfrom
feat-fetch-more-data
Feb 19, 2026
Merged

fetch more data#10
santoshyadavdev merged 2 commits into
mainfrom
feat-fetch-more-data

Conversation

@santoshyadavdev

@santoshyadavdev santoshyadavdev commented Feb 19, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Displays "Member since" year based on your GitHub account.
    • Activity insights now cover your GitHub history dynamically (up to 10 years).
    • Generated stories include account-age and origin-year context.
  • Documentation

    • UI explanatory text updated to describe historical scope ("up to 10 years" or last 4 years for newer accounts).

@coderabbitai

coderabbitai Bot commented Feb 19, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Adds optional GitHub account creation date across models, session and server; threads createdAt through GitHub aggregation and story generation; dashboard displays "Member since" and uses createdAt to compute dynamic activity years (up to 10 years) for aggregation and narratives.

Changes

Cohort / File(s) Summary
Models & Types
yourstory/src/app/core/models/activity.models.ts, yourstory/src/types/session.d.ts
Added optional created_at?: string to UserProfile and session user typings.
GitHub aggregation service
yourstory/src/app/core/services/github.service.ts
getAggregatedActivity now accepts createdAt?: string and computes a dynamic year range from account creation (capped to 10 years) instead of a fixed 4-year window.
Story service & request shape
yourstory/src/app/core/services/story.service.ts
Added createdAt?: string to StoryRequest and to generateStory signature; request payload now includes createdAt.
Dashboard (UI + state)
yourstory/src/app/pages/dashboard/dashboard.component.ts
Introduced memberSinceYear signal and constructor effect deriving it from authService.user()?.created_at; updated generation flow to pass createdAt and render conditional "Member since" card.
Server & prompts
yourstory/src/server.ts
OAuth/user session now carries created_at; /api/stories/generate accepts optional createdAt; server computes account age text/origin year and injects it into system/user prompts with fallbacks.
UI text
yourstory/src/app/pages/login/login.component.ts
Updated descriptive text to state aggregation covers "up to 10 years" (falls back to last 4 years for newer accounts).

Sequence Diagram

sequenceDiagram
    participant User
    participant Dashboard
    participant Auth as Auth Service
    participant GitHub as GitHub API
    participant GitHubSvc as GitHub Service
    participant StorySvc as Story Service
    participant Server as Server API
    participant LLM as External LLM

    User->>Auth: Login with GitHub
    Auth->>GitHub: OAuth callback
    GitHub-->>Auth: user data + created_at
    Auth-->>Dashboard: user signal (includes created_at)
    Dashboard->>Dashboard: derive memberSinceYear from created_at

    User->>Dashboard: Click "Generate Story"
    Dashboard->>GitHubSvc: getAggregatedActivity(createdAt)
    GitHubSvc->>GitHub: fetch contributions for computed year range
    GitHub-->>GitHubSvc: aggregated activity
    Dashboard->>StorySvc: generateStory(genre, activity, createdAt)
    StorySvc->>Server: POST /api/stories/generate (includes createdAt)
    Server->>Server: compute accountAgeText / origin year
    Server->>LLM: request story with account age context
    LLM-->>Server: generated story
    Server-->>StorySvc: story content
    StorySvc-->>Dashboard: story result
    Dashboard->>User: display story + "Member since"
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Feat add GitHub auth #2: Extends the auth/session surface this PR augments (adds created_at through same flows).
  • Feat redo UI #6: Modifies GitHubService.getAggregatedActivity and dashboard generation flow that this change further adapts to use createdAt.
  • chore: add storz section #4: Implements story-generation endpoints/services that this PR extends with createdAt context in prompts and requests.

Poem

🐇 I hopped through commits, nose in the log,
Found when devs joined the GitHub bog.
From origin year to present day,
Stories now know how long you’ve stayed—
Member since cards dance in the fog! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fetch more data' is vague and generic, lacking specificity about what data is being fetched or what functionality is being added. Consider using a more descriptive title that clarifies the main change, such as 'Add account creation date tracking to GitHub activity analysis' or 'Support user account age in activity aggregation and story generation'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-fetch-more-data

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added the enhancement New feature or request label Feb 19, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
yourstory/src/server.ts (1)

379-446: ⚠️ Potential issue | 🟡 Minor

Validate createdAt and use UTC years to avoid NaN/off-by-one in prompts.

The createdAt parameter from the request body is not validated before use at line 406. Additionally, the code calls getFullYear() instead of getUTCFullYear(), which can shift the year by one for UTC timestamps depending on server timezone. The date is also parsed repeatedly (lines 409, 433, 444, 446) instead of once.

🛠️ Suggested fix
-  const { genre, activity, createdAt } = req.body as {
+  const { genre, activity, createdAt } = req.body as {
     genre?: unknown;
     activity?: unknown;
     createdAt?: string;
   };
+  const createdAtValue = typeof createdAt === 'string' ? createdAt : undefined;
@@
-    const memberSince = createdAt ?? req.session.user.created_at;
-    let accountAgeText = '';
-    if (memberSince) {
-      const creationYear = new Date(memberSince).getFullYear();
-      const currentYear = new Date().getFullYear();
-      const yearsOnGitHub = currentYear - creationYear;
-      accountAgeText = yearsOnGitHub > 0
-        ? `a developer who has been on their coding journey for ${yearsOnGitHub} year${yearsOnGitHub !== 1 ? 's' : ''} since ${creationYear}`
-        : `a developer who joined GitHub in ${creationYear}`;
-    } else {
-      accountAgeText = 'a passionate developer';
-    }
+    const memberSince = createdAtValue ?? req.session.user.created_at;
+    const memberSinceDate = memberSince ? new Date(memberSince) : null;
+    const memberSinceYear =
+      memberSinceDate && !Number.isNaN(memberSinceDate.getTime())
+        ? memberSinceDate.getUTCFullYear()
+        : undefined;
+    const currentYear = new Date().getUTCFullYear();
+    let accountAgeText = '';
+    if (memberSinceYear !== undefined) {
+      const yearsOnGitHub = Math.max(0, currentYear - memberSinceYear);
+      accountAgeText = yearsOnGitHub > 0
+        ? `a developer who has been on their coding journey for ${yearsOnGitHub} year${yearsOnGitHub !== 1 ? 's' : ''} since ${memberSinceYear}`
+        : `a developer who joined GitHub in ${memberSinceYear}`;
+    } else {
+      accountAgeText = 'a passionate developer';
+    }
@@
-      `Their journey began in ${memberSince ? new Date(memberSince).getFullYear() : 'the past'} — weave this origin into the narrative.`,
+      `Their journey began in ${memberSinceYear ?? 'the past'} — weave this origin into the narrative.`,
@@
-      `${accountAgeText.charAt(0).toUpperCase() + accountAgeText.slice(1)}, they joined GitHub in ${memberSince ? new Date(memberSince).getFullYear() : 'the past'}.`,
+      `${accountAgeText.charAt(0).toUpperCase() + accountAgeText.slice(1)}, they joined GitHub in ${memberSinceYear ?? 'the past'}.`,
@@
-      `- Member since: ${memberSince ? new Date(memberSince).getFullYear() : 'unknown'}`,
+      `- Member since: ${memberSinceYear ?? 'unknown'}`,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@yourstory/src/server.ts` around lines 379 - 446, Validate and parse the
incoming createdAt value once and reuse the parsed Date (e.g., replace the
ad-hoc uses of new Date(memberSince) in accountAgeText, systemInstruction, and
userPrompt with a single parsed variable); ensure you check that the parsed Date
is valid (Date.parse or isNaN(date.getTime())) and reject the request with 400
if invalid, and when extracting the year use getUTCFullYear() instead of
getFullYear() to avoid timezone shifts; update references to createdAt,
memberSince, accountAgeText, systemInstruction, and userPrompt to use the single
validated Date/year variable and a safe fallback when no valid date is provided.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@yourstory/src/app/core/services/github.service.ts`:
- Around line 62-86: In getAggregatedActivity, validate and parse createdAt
using Date, switch from getFullYear() to getUTCFullYear(), and clamp the
resulting creationYear to the range [currentYear - (MAX_YEARS - 1),
currentYear]; if parsing fails or createdAt is in the future, fall back to the
original 4-year start (currentYear - 3). Concretely, replace the creationYear
assignment with a guarded parse that checks isFinite(date.valueOf()), uses
date.getUTCFullYear(), and then computes startYear = Math.max(parsedYear,
currentYear - MAX_YEARS + 1) and startYear = Math.min(startYear, currentYear)
(or fall back to currentYear - 3 when invalid) so years[] is never empty or NaN.

In `@yourstory/src/app/pages/dashboard/dashboard.component.ts`:
- Around line 16-19: The current heading and paragraph ("Your GitHub Story" and
the paragraph starting with "Generate a career-spanning story...") are
misleading because the service aggregates only the last 10 years; update the
copy in dashboard.component (the template that contains the "Your GitHub Story"
h2 and its descriptive p) to explicitly state the 10-year cap (e.g., replace
"career-spanning" with "up to the last 10 years" and add a short clause noting
the 10-year aggregation limit) so users understand the timeframe constraint.
- Around line 150-159: The effect that derives memberSinceYear should validate
the created_at value, clear the signal when missing/invalid, and use UTC year to
avoid local‑TZ drift: inside the effect read
this.authService.user()?.created_at, attempt to parse it into a Date, if the
parse results in an invalid date call this.memberSinceYear.set(null), otherwise
call this.memberSinceYear.set(parsedDate.getUTCFullYear()); ensure the path that
handles undefined created_at also sets the signal to null to avoid retaining
stale values.

In `@yourstory/src/app/pages/login/login.component.ts`:
- Around line 226-229: The heading and paragraph in the LoginComponent template
("View Your Stats" and the paragraph text) overstate the data range by implying
a full GitHub history; update the copy in the template (the <h3 class="font-bold
text-xl mb-2 text-white"> and the following <p class="text-gray-400 text-sm
leading-relaxed">) to indicate that stats cover up to 10 years (with a 4‑year
fallback) instead of "entire GitHub journey" — e.g., mention "up to the last 10
years (fallback 4 years)" or similar concise phrasing so users aren't misled.
Ensure the change is made inside LoginComponent's template where those elements
are defined.

---

Outside diff comments:
In `@yourstory/src/server.ts`:
- Around line 379-446: Validate and parse the incoming createdAt value once and
reuse the parsed Date (e.g., replace the ad-hoc uses of new Date(memberSince) in
accountAgeText, systemInstruction, and userPrompt with a single parsed
variable); ensure you check that the parsed Date is valid (Date.parse or
isNaN(date.getTime())) and reject the request with 400 if invalid, and when
extracting the year use getUTCFullYear() instead of getFullYear() to avoid
timezone shifts; update references to createdAt, memberSince, accountAgeText,
systemInstruction, and userPrompt to use the single validated Date/year variable
and a safe fallback when no valid date is provided.

Comment on lines +62 to +86
* Fetches contributions from the user's account creation year to the current year,
* capped at a maximum of 10 years, then aggregates the numeric fields by summing them.
* Discussion counts are included once — they are already lifetime totals.
*
* @param createdAt - ISO 8601 date string of the GitHub account creation date.
* Falls back to the last 4 years when not provided.
*/
getAggregatedActivity(): Observable<ActivitySummary> {
getAggregatedActivity(createdAt?: string): Observable<ActivitySummary> {
const currentYear = new Date().getFullYear();
const years = [currentYear, currentYear - 1, currentYear - 2, currentYear - 3];
const MAX_YEARS = 10;

let startYear: number;
if (createdAt) {
const creationYear = new Date(createdAt).getFullYear();
// Clamp to at most MAX_YEARS in the past
startYear = Math.max(creationYear, currentYear - MAX_YEARS + 1);
} else {
// Fallback: last 4 years (original behaviour)
startYear = currentYear - 3;
}

const years: number[] = [];
for (let y = startYear; y <= currentYear; y++) {
years.push(y);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

find . -name "github.service.ts" -type f

Repository: santoshyadavdev/commitstory

Length of output: 122


🏁 Script executed:

cat -n ./yourstory/src/app/core/services/github.service.ts | head -100

Repository: santoshyadavdev/commitstory

Length of output: 4448


🏁 Script executed:

cat -n ./yourstory/src/app/core/services/github.service.ts | tail -20

Repository: santoshyadavdev/commitstory

Length of output: 1048


🌐 Web query:

GitHub API user created_at field format ISO 8601

💡 Result:

In the GitHub REST API, a user’s created_at field is a UTC timestamp string in ISO 8601 format, e.g. "2008-01-14T04:33:35Z" (the trailing Z means UTC). [1], [2]


🏁 Script executed:

# Check if there are any tests for the getAggregatedActivity method
find . -name "*.spec.ts" -type f | xargs grep -l "getAggregatedActivity" 2>/dev/null | head -5

Repository: santoshyadavdev/commitstory

Length of output: 53


🏁 Script executed:

# Check how createdAt is used - look for where this method is called
rg "getAggregatedActivity" --type ts -B 2 -A 2

Repository: santoshyadavdev/commitstory

Length of output: 1040


🏁 Script executed:

# Let's test the actual behavior of new Date() with ISO strings and timezone handling
python3 << 'EOF'
from datetime import datetime
import json

# Test case: GitHub's typical ISO 8601 format with Z suffix (UTC)
test_dates = [
    "2008-01-14T04:33:35Z",  # Valid GitHub date
    "invalid-date",           # Invalid
    "2099-01-01T00:00:00Z",   # Future date
]

print("Testing JavaScript Date behavior simulation:")
print("=" * 60)

for date_str in test_dates:
    try:
        # Parse as ISO 8601
        if date_str.endswith('Z'):
            dt = datetime.fromisoformat(date_str.replace('Z', '+00:00'))
            year_utc = dt.year
            print(f"\nDate string: {date_str}")
            print(f"  Parsed as UTC: {dt}")
            print(f"  UTC Year: {year_utc}")
            print(f"  Note: getFullYear() in JS would depend on local timezone")
            
            # Simulate timezone offset (e.g., UTC-8 for Pacific Time)
            import datetime as dt_module
            utc_offset = -8 * 60  # UTC-8 in minutes
            local_dt = dt.astimezone()
            print(f"  Local time (system TZ): {local_dt}")
            print(f"  Local year would be: {local_dt.year}")
        else:
            print(f"\nDate string: {date_str}")
            print(f"  Invalid - would return NaN in JavaScript")
    except Exception as e:
        print(f"\nDate string: {date_str}")
        print(f"  Error: {e}")

print("\n" + "=" * 60)
print("Summary:")
print("- ISO strings with 'Z' are UTC, but getFullYear() uses local time")
print("- This can cause year boundary issues in non-UTC timezones")
print("- getUTCFullYear() would return the correct UTC year")
EOF

Repository: santoshyadavdev/commitstory

Length of output: 963


🏁 Script executed:

# Let's verify the timezone drift issue with a specific example at year boundary
python3 << 'EOF'
# Simulate JavaScript Date behavior with different timezones
import datetime

# Scenario: Date at year boundary in UTC
utc_date_str = "2008-01-01T04:33:35Z"  # Start of 2008 in UTC

# Parse as UTC
dt_utc = datetime.datetime(2008, 1, 1, 4, 33, 35, tzinfo=datetime.timezone.utc)

print("Timezone Drift Example:")
print("=" * 60)
print(f"Original UTC timestamp: {utc_date_str}")
print(f"UTC Year: {dt_utc.year}")

# Simulate different timezones
timezones = {
    "UTC+0": datetime.timezone(datetime.timedelta(hours=0)),
    "UTC-8 (Pacific)": datetime.timezone(datetime.timedelta(hours=-8)),
    "UTC+5:30 (India)": datetime.timezone(datetime.timedelta(hours=5, minutes=30)),
}

print("\nYear in different timezones:")
for tz_name, tz in timezones.items():
    local_time = dt_utc.astimezone(tz)
    print(f"  {tz_name}: {local_time.year} (local time: {local_time.strftime('%Y-%m-%d %H:%M:%S')})")

print("\n" + "=" * 60)
print("Issue: getFullYear() uses local timezone, but GitHub provides UTC.")
print("Using getUTCFullYear() ensures consistency across all timezones.")
EOF

Repository: santoshyadavdev/commitstory

Length of output: 604


🏁 Script executed:

# Test invalid date and NaN handling in JavaScript-like scenarios
python3 << 'EOF'
# Simulate JavaScript Date behavior for edge cases

print("Edge Case Testing:")
print("=" * 60)

# Case 1: Invalid date
print("\n1. Invalid date string:")
try:
    invalid_date = "not-a-date"
    # In JavaScript, new Date("not-a-date").getFullYear() returns NaN
    print(f"   Input: '{invalid_date}'")
    print(f"   new Date('{invalid_date}').getFullYear() = NaN")
    print(f"   This causes startYear = Math.max(NaN, currentYear - MAX_YEARS + 1)")
    print(f"   Result: startYear = NaN (because any comparison with NaN is false)")
    print(f"   Then in loop: for (let y = NaN; y <= currentYear; y++)")
    print(f"   The loop never executes → years array is EMPTY")
except Exception as e:
    print(f"   Error: {e}")

# Case 2: Future date beyond MAX_YEARS
print("\n2. Future date (beyond MAX_YEARS cap):")
current_year = 2026
max_years = 10
future_year = 2035
print(f"   Current year: {current_year}")
print(f"   MAX_YEARS: {max_years}")
print(f"   Future createdAt year: {future_year}")
print(f"   creationYear = {future_year}")
print(f"   startYear = Math.max({future_year}, {current_year - max_years + 1})")
print(f"   startYear = {max(future_year, current_year - max_years + 1)}")
print(f"   Since startYear > currentYear, loop doesn't execute → empty years array")

# Case 3: Date in the future but within MAX_YEARS
print("\n3. Future date within MAX_YEARS:")
future_year_near = 2027
print(f"   creationYear = {future_year_near}")
print(f"   startYear = Math.max({future_year_near}, {current_year - max_years + 1})")
print(f"   startYear = {max(future_year_near, current_year - max_years + 1)}")
print(f"   Since {future_year_near} > {current_year}, startYear > currentYear")
print(f"   Loop condition (y = {future_year_near}; y <= {current_year}) fails → empty array")

print("\n" + "=" * 60)
print("Summary of edge cases:")
print("✗ Invalid date → NaN → empty years array")
print("✗ Future date → startYear > currentYear → empty years array")
print("✗ Timezone drift → wrong year extracted from UTC timestamp")
EOF

Repository: santoshyadavdev/commitstory

Length of output: 1220


Use getUTCFullYear() and validate createdAt to prevent timezone drift and edge-case failures.

new Date(createdAt).getFullYear() uses local time and shifts the year for users in timezones behind UTC (e.g., UTC-8 yields 2007 for "2008-01-01T04:33:35Z"). Invalid or future createdAt values cause startYear to become NaN or exceed currentYear, resulting in an empty years array and failed aggregation. Validate the date, use UTC year extraction, and clamp against future dates.

🛠️ Suggested fix
     let startYear: number;
     if (createdAt) {
-      const creationYear = new Date(createdAt).getFullYear();
-      // Clamp to at most MAX_YEARS in the past
-      startYear = Math.max(creationYear, currentYear - MAX_YEARS + 1);
+      const createdDate = new Date(createdAt);
+      const creationYear = !Number.isNaN(createdDate.getTime())
+        ? createdDate.getUTCFullYear()
+        : undefined;
+      if (creationYear !== undefined) {
+        // Clamp to valid bounds and at most MAX_YEARS in the past
+        startYear = Math.max(
+          Math.min(creationYear, currentYear),
+          currentYear - MAX_YEARS + 1
+        );
+      } else {
+        startYear = currentYear - 3;
+      }
     } else {
       // Fallback: last 4 years (original behaviour)
       startYear = currentYear - 3;
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@yourstory/src/app/core/services/github.service.ts` around lines 62 - 86, In
getAggregatedActivity, validate and parse createdAt using Date, switch from
getFullYear() to getUTCFullYear(), and clamp the resulting creationYear to the
range [currentYear - (MAX_YEARS - 1), currentYear]; if parsing fails or
createdAt is in the future, fall back to the original 4-year start (currentYear
- 3). Concretely, replace the creationYear assignment with a guarded parse that
checks isFinite(date.valueOf()), uses date.getUTCFullYear(), and then computes
startYear = Math.max(parsedYear, currentYear - MAX_YEARS + 1) and startYear =
Math.min(startYear, currentYear) (or fall back to currentYear - 3 when invalid)
so years[] is never empty or NaN.

Comment on lines 16 to 19
<h2 class="text-3xl font-bold mb-4">Your GitHub Story</h2>
<p class="text-gray-400 mb-8">
Generate a career-spanning story based on your GitHub contributions across the last 4 years.
Generate a career-spanning story based on your GitHub contributions since you joined.
Choose a genre and let AI craft your unique developer narrative.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Copy should reflect the 10‑year aggregation cap.

“Career‑spanning” can be misleading if the account is older than the 10‑year window. Consider tightening the wording.

✏️ Suggested copy tweak
-          Generate a career-spanning story based on your GitHub contributions since you joined.
+          Generate a story based on up to 10 years of GitHub contributions since you joined.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@yourstory/src/app/pages/dashboard/dashboard.component.ts` around lines 16 -
19, The current heading and paragraph ("Your GitHub Story" and the paragraph
starting with "Generate a career-spanning story...") are misleading because the
service aggregates only the last 10 years; update the copy in
dashboard.component (the template that contains the "Your GitHub Story" h2 and
its descriptive p) to explicitly state the 10-year cap (e.g., replace
"career-spanning" with "up to the last 10 years" and add a short clause noting
the 10-year aggregation limit) so users understand the timeframe constraint.

Comment on lines +150 to +159
readonly memberSinceYear = signal<number | null>(null);

constructor() {
// Eagerly derive the "Member since" year from the authenticated user profile.
effect(() => {
const createdAt = this.authService.user()?.created_at;
if (createdAt) {
this.memberSinceYear.set(new Date(createdAt).getFullYear());
}
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

cd yourstory && find . -name "dashboard.component.ts" -type f

Repository: santoshyadavdev/commitstory

Length of output: 119


🏁 Script executed:

cd yourstory && sed -n '145,165p' ./src/app/pages/dashboard/dashboard.component.ts

Repository: santoshyadavdev/commitstory

Length of output: 825


🏁 Script executed:

cd yourstory && rg "authService" ./src/app/pages/dashboard/dashboard.component.ts -A 2 -B 2 | head -30

Repository: santoshyadavdev/commitstory

Length of output: 659


🏁 Script executed:

cd yourstory && find . -name "*.ts" -type f | xargs rg "class AuthService|interface.*User|created_at" | grep -E "(service|interface|type)" | head -20

Repository: santoshyadavdev/commitstory

Length of output: 257


🏁 Script executed:

cd yourstory && cat -n ./src/types/session.d.ts

Repository: santoshyadavdev/commitstory

Length of output: 525


🏁 Script executed:

cd yourstory && cat -n ./src/app/core/auth/auth.service.ts

Repository: santoshyadavdev/commitstory

Length of output: 3061


🏁 Script executed:

cd yourstory && cat -n ./src/app/core/models/activity.models.ts

Repository: santoshyadavdev/commitstory

Length of output: 897


🏁 Script executed:

cd yourstory && rg "created_at" ./src --type ts -B 2 -A 2 | head -50

Repository: santoshyadavdev/commitstory

Length of output: 2108


🏁 Script executed:

cd yourstory && sed -n '1,100p' ./src/server.ts | grep -A 10 -B 10 "created_at\|memberSince"

Repository: santoshyadavdev/commitstory

Length of output: 53


🏁 Script executed:

cd yourstory && cat -n ./src/server.ts | head -150

Repository: santoshyadavdev/commitstory

Length of output: 5193


🏁 Script executed:

cd yourstory && sed -n '150,250p' ./src/server.ts

Repository: santoshyadavdev/commitstory

Length of output: 2719


🏁 Script executed:

cd yourstory && rg "memberSince|getFullYear|getUTCFullYear" ./src --type ts -B 3 -A 3

Repository: santoshyadavdev/commitstory

Length of output: 5606


Clear stale memberSinceYear and avoid local‑TZ year drift.

If created_at is missing or invalid, the signal retains the previous value. Also, getFullYear() uses local time and can shift the year for UTC timestamps near year boundaries. Validate the date, use getUTCFullYear(), and reset to null on invalid input.

🛠️ Suggested fix
     effect(() => {
       const createdAt = this.authService.user()?.created_at;
-      if (createdAt) {
-        this.memberSinceYear.set(new Date(createdAt).getFullYear());
-      }
+      if (createdAt) {
+        const createdDate = new Date(createdAt);
+        if (!Number.isNaN(createdDate.getTime())) {
+          this.memberSinceYear.set(createdDate.getUTCFullYear());
+          return;
+        }
+      }
+      this.memberSinceYear.set(null);
     });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@yourstory/src/app/pages/dashboard/dashboard.component.ts` around lines 150 -
159, The effect that derives memberSinceYear should validate the created_at
value, clear the signal when missing/invalid, and use UTC year to avoid local‑TZ
drift: inside the effect read this.authService.user()?.created_at, attempt to
parse it into a Date, if the parse results in an invalid date call
this.memberSinceYear.set(null), otherwise call
this.memberSinceYear.set(parsedDate.getUTCFullYear()); ensure the path that
handles undefined created_at also sets the signal to null to avoid retaining
stale values.

Comment thread yourstory/src/app/pages/login/login.component.ts
@santoshyadavdev
santoshyadavdev merged commit bb8e0a5 into main Feb 19, 2026
1 of 2 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant