-
Notifications
You must be signed in to change notification settings - Fork 1
Feat/mocks for demo #836
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
Open
talyguryn
wants to merge
44
commits into
master
Choose a base branch
from
feat/mocks-for-demo
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/mocks for demo #836
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
4c326d2
Add demo mode with API mocks and enablement logic
talyguryn 11ad11f
remove demo user
talyguryn e2bb138
Update .nvmrc
talyguryn a4bea5b
Update main.ts
talyguryn bd626b1
Update EventsList.vue
talyguryn 34e7193
Update index.ts
talyguryn c10df9e
Update .nvmrc
talyguryn 2d10b07
Update EventsList.vue
talyguryn 445b011
Update main.ts
talyguryn 2be3421
Add demo mode, mock DB and API mocks
talyguryn fb999e8
Centralize demo mocks and enhance withMockDemo
talyguryn 1c2ebfb
Add time utils and tighten mock types
talyguryn 0935337
Code style cleanup and small refactors
talyguryn 3a12786
Use absolute mock paths and improve resolver
talyguryn 3757741
Add demo composable and refactor demo mock loading
talyguryn 4fde36e
Use @hawk.so/types and seconds-based timestamps
talyguryn 2c98ecd
Add demo-banner and refactor demo mode handling
talyguryn 7eee912
Fix i18n locale assignment and tidy events module
talyguryn ca5ac7b
Update index.js
talyguryn f28db0c
Use void to ignore returned promises
talyguryn a5c5e1d
Make demo composable shared and update usages
talyguryn 99640f5
Refactor demo mode handling and i18n setup
talyguryn e44ad5e
Handle demo-mode and notification errors
talyguryn 06838cb
Update index.js
talyguryn ab3cf38
chore(app-shell): improve demo-banner component
neSpecc 63f9cd3
Use i18n for demo-mode unavailable message
talyguryn 92586ce
Add notification mocks and wrap API with mocks
talyguryn 80c8c24
Support filtering/sorting/search in mock events
talyguryn bd154b6
Add demo mocks and demo-mode API wrappers
talyguryn c9d1e64
Rename withMockDemo to withDemoMock
talyguryn e519d2f
Mock: generate chart data from DEMO_EVENTS
talyguryn 26cb90b
Support multiple demo projects in mocks
talyguryn c467ffb
Update utils.ts
talyguryn b53a89c
Update router.ts
talyguryn 2f89ab6
Update ru.json
talyguryn 6cfcaca
Update getBusinessOperations.mock.ts
talyguryn dd0c5a3
Expose computed isDemoActive from useDemo
talyguryn e15bc90
Update useDemo.ts
talyguryn 6e25595
Update index.ts
talyguryn 02c1d40
Export demo tokens and centralize usage
talyguryn a5ce864
Update index.ts
talyguryn e251671
Export getBalance and remove demo mock
talyguryn a1e2bf6
Update getAllWorkspacesWithProjects.mock.ts
talyguryn a5cbce6
Export real getPlans and remove demo mock
talyguryn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import type { BusinessOperation } from '@/types/business-operation'; | ||
| import { DEMO_WORKSPACE_ID, DEMO_BUSINESS_OPERATIONS } from '@/api/mock-db'; | ||
|
|
||
| /** | ||
| * Mock: getBusinessOperations | ||
| * | ||
| * Returns demo business operations (payment history) for specified workspace IDs | ||
| */ | ||
| export default function mockGetBusinessOperations(ids: string[]): BusinessOperation[] { | ||
| // Return demo operations if requesting for demo workspace | ||
| if (ids.includes(DEMO_WORKSPACE_ID)) { | ||
| return DEMO_BUSINESS_OPERATIONS; | ||
| } | ||
| return []; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { getDemoEventsByProjectId } from '@/api/mock-db'; | ||
| import type { ChartLine } from '@hawk.so/types'; | ||
|
|
||
| const SECONDS_IN_MINUTE = 60; | ||
| const SECONDS_IN_DAY = 24 * 60 * 60; | ||
|
|
||
| function alignToDay(timestamp: number, timezoneOffset = 0): number { | ||
| const shiftedTimestamp = timestamp - timezoneOffset * SECONDS_IN_MINUTE; | ||
|
|
||
| return Math.floor(shiftedTimestamp / SECONDS_IN_DAY) * SECONDS_IN_DAY + timezoneOffset * SECONDS_IN_MINUTE; | ||
| } | ||
|
|
||
| /** | ||
| * Mock: fetchChartData (events) | ||
| * | ||
| * Returns chart data from mock-db | ||
| */ | ||
| export default function mockFetchChartData( | ||
| projectId: string, | ||
| originalEventId: string, | ||
| days = 14, | ||
| timezoneOffset = 0 | ||
| ): ChartLine[] { | ||
| const nowSeconds = Math.floor(Date.now() / 1000); | ||
| const fromTimestamp = nowSeconds - Math.max(1, days) * SECONDS_IN_DAY; | ||
| const buckets = new Map<number, number>(); | ||
|
|
||
| for (let day = 0; day <= days; day++) { | ||
| const dayTimestamp = alignToDay(fromTimestamp + day * SECONDS_IN_DAY, timezoneOffset); | ||
|
|
||
| buckets.set(dayTimestamp, 0); | ||
| } | ||
|
|
||
| const projectEvents = getDemoEventsByProjectId(projectId); | ||
| const anchorEvent = projectEvents.find(event => event.originalEventId === originalEventId); | ||
|
|
||
| const relatedEvents = projectEvents.filter((event) => { | ||
| if (event.timestamp < fromTimestamp || event.timestamp > nowSeconds) { | ||
| return false; | ||
| } | ||
|
|
||
| if (event.originalEventId === originalEventId) { | ||
| return true; | ||
| } | ||
|
|
||
| if (anchorEvent && event.payload.title === anchorEvent.payload.title) { | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| }); | ||
|
|
||
| relatedEvents.forEach((event) => { | ||
| const dayBucket = alignToDay(event.timestamp, timezoneOffset); | ||
|
|
||
| buckets.set(dayBucket, (buckets.get(dayBucket) || 0) + event.totalCount); | ||
| }); | ||
|
|
||
| return [ | ||
| { | ||
| label: 'accepted', | ||
| data: Array.from(buckets.entries()).map(([timestamp, count]) => ({ | ||
| timestamp, | ||
| count, | ||
| })), | ||
| }, | ||
| ]; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mock hard-codes the demo workspace id string. Since
DEMO_WORKSPACE_IDis already defined in@/api/mock-db, using the shared constant here would prevent drift if the demo ids ever change.