Skip to content

Commit

Permalink
Disable non-essential jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksonh committed Oct 30, 2024
1 parent 2fe65c4 commit dca165f
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 61 deletions.
48 changes: 24 additions & 24 deletions packages/api/src/queue-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,25 +159,25 @@ export const createWorker = (connection: ConnectionOptions) =>
async (job: Job) => {
const executeJob = async (job: Job) => {
switch (job.name) {
case 'refresh-all-feeds': {
const queue = await getQueue()
const counts = await queue?.getJobCounts('prioritized')
if (counts && counts.wait > 1000) {
return
}
return await refreshAllFeeds(appDataSource)
}
case 'refresh-feed': {
return await refreshFeed(job.data)
}
// case 'refresh-all-feeds': {
// const queue = await getQueue()
// const counts = await queue?.getJobCounts('prioritized')
// if (counts && counts.wait > 1000) {
// return
// }
// return await refreshAllFeeds(appDataSource)
// }
// case 'refresh-feed': {
// return await refreshFeed(job.data)
// }
case 'save-page': {
return savePageJob(job.data, job.attemptsMade)
}
case 'update-pdf-content': {
return updatePDFContentJob(job.data)
}
case THUMBNAIL_JOB:
return findThumbnail(job.data)
// case THUMBNAIL_JOB:
// return findThumbnail(job.data)
case TRIGGER_RULE_JOB_NAME:
return triggerRule(job.data)
case UPDATE_LABELS_JOB:
Expand All @@ -192,11 +192,11 @@ export const createWorker = (connection: ConnectionOptions) =>
return callWebhook(job.data)
case EXPORT_ITEM_JOB_NAME:
return exportItem(job.data)
case AI_SUMMARIZE_JOB_NAME:
return aiSummarize(job.data)
case PROCESS_YOUTUBE_VIDEO_JOB_NAME:
return processYouTubeVideo(job.data)
case PROCESS_YOUTUBE_TRANSCRIPT_JOB_NAME:
// case AI_SUMMARIZE_JOB_NAME:
// return aiSummarize(job.data)
// case PROCESS_YOUTUBE_VIDEO_JOB_NAME:
// return processYouTubeVideo(job.data)
// case PROCESS_YOUTUBE_TRANSCRIPT_JOB_NAME:
return processYouTubeTranscript(job.data)
case EXPORT_ALL_ITEMS_JOB_NAME:
return exportAllItems(job.data)
Expand All @@ -214,12 +214,12 @@ export const createWorker = (connection: ConnectionOptions) =>
return createDigest(job.data)
case UPLOAD_CONTENT_JOB:
return uploadContentJob(job.data)
case UPDATE_HOME_JOB:
return updateHome(job.data)
case SCORE_LIBRARY_ITEM_JOB:
return scoreLibraryItem(job.data)
case GENERATE_PREVIEW_CONTENT_JOB:
return generatePreviewContent(job.data)
// case UPDATE_HOME_JOB:
// return updateHome(job.data)
// case SCORE_LIBRARY_ITEM_JOB:
// return scoreLibraryItem(job.data)
// case GENERATE_PREVIEW_CONTENT_JOB:
// return generatePreviewContent(job.data)
case PRUNE_TRASH_JOB:
return pruneTrashJob(job.data)
case EXPIRE_FOLDERS_JOB_NAME:
Expand Down
4 changes: 4 additions & 0 deletions packages/api/src/services/create_user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export const createUser = async (input: {
return [existingUser, profile]
}

if (process.env.SIGNUP_CLOSED) {
return Promise.reject({ errorCode: SignupErrorCode.AccessDenied })
}

if (!validateUsername(input.username)) {
return Promise.reject({ errorCode: SignupErrorCode.InvalidUsername })
}
Expand Down
2 changes: 1 addition & 1 deletion packages/db/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const postgrator = new Postgrator({
// Schema table name
schemaTable: 'schemaversion',
// Validate migration md5 checksum to ensure the contents of the script have not changed
validateChecksums: true,
validateChecksums: false,
})

log('Starting migration manager')
Expand Down
45 changes: 19 additions & 26 deletions packages/web/components/elements/MaintenanceBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,34 @@ import { usePersistedState } from '../../lib/hooks/usePersistedState'
import { CloseButton } from './CloseButton'
import { HStack, SpanBox } from './LayoutPrimitives'

export const MaintenanceBanner = () => {
export const AnnouncementBanner = () => {
const [
showMaintenanceMode,
setShowMaintenanceMode,
isLoadingShowMaintenanceMode,
] = usePersistedState({
key: 'show-maintenance-mode',
key: 'show-maintenance-mode-03',
isSessionStorage: false,
initialValue: false,
initialValue: true,
})
return (
<>
{!isLoadingShowMaintenanceMode && showMaintenanceMode && (
<HStack
css={{
p: '5px',
width: '100%',
position: 'fixed',
bg: '#FF5733',
color: '#FFFFFF',
zIndex: '100',
}}
alignment="center"
distribution="center"
>
Omnivore will be undergoing maintenance for 30 minutes at 05:00 UTC,
during that time the website and APIs will be unavailable.
<SpanBox css={{ width: '50px' }} />
<CloseButton
close={() => {
setShowMaintenanceMode(false)
}}
/>
</HStack>
)}
<SpanBox
css={{
p: '5px',
px: '16px',
mt: '0px',
mb: '10px',
bg: '#FF5733',
width: '100%',
color: '#FFFFFF',
zIndex: '100',
fontSize: '12px',
}}
>
Omnivore is joining ElevenLabs and will be shutting down the free hosted
version. Read more <a href=""> here.</a>
</SpanBox>
</>
)
}
2 changes: 1 addition & 1 deletion packages/web/components/templates/AuthLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, VStack, HStack } from '../elements/LayoutPrimitives'
import { MaintenanceBanner } from '../elements/MaintenanceBanner'
import { AnnouncementBanner } from '../elements/MaintenanceBanner'
import { OmnivoreNameLogo } from '../elements/images/OmnivoreNameLogo'
import { theme } from '../tokens/stitches.config'
import { GoogleReCaptchaProvider } from '@google-recaptcha/react'
Expand Down
9 changes: 6 additions & 3 deletions packages/web/components/templates/LoginLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import {
Box,
HStack,
MediumBreakpointBox,
SpanBox,
VStack,
} from '../elements/LayoutPrimitives'
import { LoginForm } from './LoginForm'
import type { LoginFormProps } from './LoginForm'
import { OmnivoreNameLogo } from '../elements/images/OmnivoreNameLogo'

import featureFullWidthImage from '../../public/static/images/login/login-feature-image-full.png'
import { MaintenanceBanner } from '../elements/MaintenanceBanner'
import { AnnouncementBanner } from '../elements/MaintenanceBanner'

export function LoginLayout(props: LoginFormProps): JSX.Element {
return (
Expand All @@ -20,11 +21,12 @@ export function LoginLayout(props: LoginFormProps): JSX.Element {
largerLayoutNode={<MediumLoginLayout {...props} />}
/>

<Box
<HStack
css={{
position: 'absolute',
top: 0,
left: 0,
gap: '10px',
p: '0px 15px 0px 15px',
height: '68px',
minHeight: '68px',
Expand All @@ -35,9 +37,10 @@ export function LoginLayout(props: LoginFormProps): JSX.Element {
justifyContent: 'space-between',
width: '100%',
}}
alignment="start"
>
<OmnivoreNameLogo color="#898989" href="/login" />
</Box>
</HStack>
</>
)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web/components/templates/NavigationLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { useGetViewer } from '../../lib/networking/viewer/useGetViewer'
import { useQueryClient } from '@tanstack/react-query'
import { usePersistedState } from '../../lib/hooks/usePersistedState'
import { CloseButton } from '../elements/CloseButton'
import { MaintenanceBanner } from '../elements/MaintenanceBanner'
import { AnnouncementBanner } from '../elements/MaintenanceBanner'

export type NavigationSection =
| 'home'
Expand Down
11 changes: 7 additions & 4 deletions packages/web/components/templates/library/LibraryContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { State } from '../../../lib/networking/fragments/articleFragment'
import { useHandleAddUrl } from '../../../lib/hooks/useHandleAddUrl'
import { useGetViewer } from '../../../lib/networking/viewer/useGetViewer'
import { Spinner } from '@phosphor-icons/react/dist/ssr'
import { AnnouncementBanner } from '../../elements/MaintenanceBanner'

export type LayoutType = 'LIST_LAYOUT' | 'GRID_LAYOUT'

Expand Down Expand Up @@ -93,11 +94,13 @@ export function LibraryContainer(props: LibraryContainerProps): JSX.Element {

const gridContainerRef = useRef<HTMLDivElement>(null)

const [labelsTarget, setLabelsTarget] =
useState<LibraryItem | undefined>(undefined)
const [labelsTarget, setLabelsTarget] = useState<LibraryItem | undefined>(
undefined
)

const [notebookTarget, setNotebookTarget] =
useState<LibraryItem | undefined>(undefined)
const [notebookTarget, setNotebookTarget] = useState<LibraryItem | undefined>(
undefined
)

const [showAddLinkModal, setShowAddLinkModal] = useState(false)
const [showEditTitleModal, setShowEditTitleModal] = useState(false)
Expand Down
3 changes: 3 additions & 0 deletions packages/web/components/templates/library/LibraryHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
MultiSelectControls,
CheckBoxButton,
} from '../homeFeed/MultiSelectControls'
import { AnnouncementBanner } from '../../elements/MaintenanceBanner'

export type MultiSelectMode = 'off' | 'none' | 'some' | 'visible' | 'search'

Expand Down Expand Up @@ -74,6 +75,8 @@ export function LibraryHeader(props: LibraryHeaderProps): JSX.Element {
},
}}
>
<AnnouncementBanner />

<LargeHeaderLayout {...props} />
</VStack>
</>
Expand Down
1 change: 1 addition & 0 deletions packages/web/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import NextDocument, { Html, Head, Main, NextScript } from 'next/document'
import { getCssText, globalStyles } from '../components/tokens/stitches.config'
import { Toaster } from 'react-hot-toast'
import { AnnouncementBanner } from '../components/elements/MaintenanceBanner'

export default class Document extends NextDocument {
render() {
Expand Down
3 changes: 2 additions & 1 deletion packages/web/pages/auth/email-signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export default function EmailRegistrationPage(): JSX.Element {
return (
<AuthLayout>
<PageMetaData title="Sign up with Email - Omnivore" path="/auth-signup" />
<EmailSignup />
Sign ups for Omnivore are currently closed. If you already have an account
you can <a href="/login">login here</a>.
</AuthLayout>
)
}
1 change: 1 addition & 0 deletions packages/web/pages/l/[section].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useMemo } from 'react'
import { HighlightsContainer } from '../../components/nav-containers/HighlightsContainer'
import { usePersistedState } from '../../lib/hooks/usePersistedState'
import { State } from '../../lib/networking/fragments/articleFragment'
import { AnnouncementBanner } from '../../components/elements/MaintenanceBanner'

export default function Home(): JSX.Element {
const router = useRouter()
Expand Down

0 comments on commit dca165f

Please sign in to comment.