-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Longer bulk categorize #257
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
Merged
Merged
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
fcd0611
extract action to its own function
elie222 282cc83
Create bulk categorize endpoint that runs for longer with api call ch…
elie222 8d0c125
Update turbo env
elie222 2744554
Merge branch 'main' into bulk-categorize
elie222 f304d18
Merge branch 'main' into bulk-categorize
elie222 e5c8cbd
Start multi page categorization
elie222 9a02b72
Merge branch 'main' into bulk-categorize
elie222 d8c9713
Smaller batches for bulk categorize
elie222 f6a50a9
Use Qstash for categorization
elie222 450d0a0
Store categorization progress in redis
elie222 e2e831b
Add webhook url env var
elie222 8371899
categorize progress bar
elie222 c245e6c
Categorization progress panel
elie222 b8747d7
Move categorize functions into their own file
elie222 8693465
Refactor categorize senders
elie222 b95dce4
Add user email ai type
elie222 e1d6793
Clean up validate
elie222 15a50ef
move trigger file
elie222 896758e
Move categorize email to its own file
elie222 be36a5e
Update user count
elie222 839a579
Clean up user validation
elie222 d3c0977
Add scoped logger
elie222 07547ad
Adjust logging
elie222 35b6660
Simplify action logging
elie222 73ba7a4
Code clean up
elie222 2c3582a
Add error middleware for GET
elie222 ca48bcc
Fallback to work even if qstash token not set
elie222 7b9e99b
Merge branch 'main' into bulk-categorize
elie222 db12705
expire redis categorization progress in seconds
elie222 dbff85f
Fixes to categorization progress
elie222 2787dc4
Set biome as default formatter
elie222 58487ef
Fix progress expire
elie222 fda649a
Fix completion step
elie222 fa25644
Remove fast categorize. Add bulk button to top bar
elie222 f4b6fec
Date range for bulk categorize
elie222 d7a91b5
Add migration
elie222 66ce32b
Put back next auth url
elie222 b58a533
Merge branch 'main' into bulk-categorize
elie222 f02c066
Merge branch 'main' into bulk-categorize
elie222 aa4bcd0
Move getUncategorizedSenders into its own file
elie222 edc893c
Updated bulk categorize sender
elie222 d5631e2
Merge branch 'main' into bulk-categorize
elie222 de95d60
Fix build
elie222 abccc38
Revert to simple logger
elie222 f2ae8e7
Merge branch 'main' into bulk-categorize
elie222 3162f42
Merge branch 'main' into bulk-categorize
elie222 5ed610d
Fix logger
elie222 09513c6
Fix build
elie222 0cd956c
Show if no more senders to categorize
elie222 6665ce8
Make ai assistant the default screen
elie222 44e5b76
Remove old file
elie222 52be6c3
Send batches to qstash
elie222 0065be3
Remove old code
elie222 f0d8d3e
Fix log
elie222 140b828
Categorization progress
elie222 fadbe8f
Fix categorization progress
elie222 e61fdd5
useeffect timeout cleanup
elie222 e19ca4a
Update copy
elie222 3b5cc4e
Fix NaN bug
elie222 f856c0f
remove auto archive on approve
elie222 d607c85
Max iterations for while loop
elie222 5dac6ec
Remove TS !
elie222 5902340
structured logging
elie222 a3006e0
Categorize uncategorized
elie222 b62a30b
Add commented out recategorize code
elie222 8e2dc7c
Better validation and env examples
elie222 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
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
59 changes: 59 additions & 0 deletions
59
apps/web/app/(app)/smart-categories/CategorizeProgress.tsx
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,59 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect } from "react"; | ||
| import { atom, useAtom } from "jotai"; | ||
| import useSWR from "swr"; | ||
| import { ProgressPanel } from "@/components/ProgressPanel"; | ||
| import type { CategorizeProgress } from "@/app/api/user/categorize/senders/progress/route"; | ||
|
|
||
| const isCategorizeInProgressAtom = atom(false); | ||
|
|
||
| export function useCategorizeProgress() { | ||
| const [isBulkCategorizing, setIsBulkCategorizing] = useAtom( | ||
| isCategorizeInProgressAtom, | ||
| ); | ||
| return { isBulkCategorizing, setIsBulkCategorizing }; | ||
| } | ||
|
|
||
| export function CategorizeSendersProgress({ | ||
| refresh = false, | ||
| }: { | ||
| refresh: boolean; | ||
| }) { | ||
| const { isBulkCategorizing } = useCategorizeProgress(); | ||
| const { data } = useSWR<CategorizeProgress>( | ||
| "/api/user/categorize/senders/progress", | ||
| { | ||
| refreshInterval: refresh || isBulkCategorizing ? 1_000 : undefined, | ||
| }, | ||
| ); | ||
|
|
||
| // If the categorization is complete, wait 3 seconds and then set isBulkCategorizing to false | ||
| const { setIsBulkCategorizing } = useCategorizeProgress(); | ||
| useEffect(() => { | ||
| let timeoutId: NodeJS.Timeout | undefined; | ||
| if (data?.completedItems === data?.totalItems) { | ||
| timeoutId = setTimeout(() => { | ||
| setIsBulkCategorizing(false); | ||
| }, 3_000); | ||
| } | ||
| return () => { | ||
| if (timeoutId) clearTimeout(timeoutId); | ||
| }; | ||
| }, [data?.completedItems, data?.totalItems, setIsBulkCategorizing]); | ||
|
|
||
| if (!data) return null; | ||
|
|
||
| const totalItems = data.totalItems || 0; | ||
| const completedItems = data.completedItems || 0; | ||
|
|
||
| return ( | ||
| <ProgressPanel | ||
| totalItems={totalItems} | ||
| remainingItems={totalItems - completedItems} | ||
| inProgressText={`Categorizing senders... ${completedItems} categorized`} | ||
| completedText={`Categorization complete! ${completedItems} categorized!`} | ||
| itemLabel="senders" | ||
| /> | ||
| ); | ||
| } |
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
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.
Security concern: Bypassing access control
The hook is initialized with
hasUnsubscribeAccess: true, which bypasses access control checks. This could allow unauthorized users to perform auto-archive operations.Consider using the actual access control value:
📝 Committable suggestion