mirror of
https://github.com/MODSetter/SurfSense.git
synced 2025-09-01 10:09:08 +00:00
Merge pull request #261 from CREDO23/feature-google-calendar-connector/allow-indexing-future-events
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
[Improvement] Google calendar connector | Allow indexing for future events (dates
This commit is contained in:
commit
c6921a4083
4 changed files with 61 additions and 24 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
Revision ID: 4
|
Revision ID: 4
|
||||||
Revises: 3
|
Revises: 3
|
||||||
|
Create Date: 2025-08-13
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
|
@ -17,31 +17,29 @@ depends_on: str | Sequence[str] | None = None
|
||||||
|
|
||||||
|
|
||||||
def upgrade() -> None:
|
def upgrade() -> None:
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# Add enum value only if it doesn't already exist.
|
||||||
|
# Postgres will no-op with a NOTICE when the value is present.
|
||||||
# Manually add the command to add the enum value
|
op.execute(
|
||||||
op.execute("ALTER TYPE searchsourceconnectortype ADD VALUE 'LINKUP_API'")
|
"ALTER TYPE searchsourceconnectortype ADD VALUE IF NOT EXISTS 'LINKUP_API'"
|
||||||
|
)
|
||||||
# Pass for the rest, as autogenerate didn't run to add other schema details
|
|
||||||
pass
|
|
||||||
# ### end Alembic commands ###
|
|
||||||
|
|
||||||
|
|
||||||
def downgrade() -> None:
|
def downgrade() -> None:
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# To "remove" an enum value in Postgres, we must recreate the type
|
||||||
|
# without that value, migrate the column, then drop the old type.
|
||||||
# Downgrading removal of an enum value requires recreating the type
|
|
||||||
op.execute(
|
op.execute(
|
||||||
"ALTER TYPE searchsourceconnectortype RENAME TO searchsourceconnectortype_old"
|
"ALTER TYPE searchsourceconnectortype RENAME TO searchsourceconnectortype_old"
|
||||||
)
|
)
|
||||||
op.execute(
|
op.execute(
|
||||||
"CREATE TYPE searchsourceconnectortype AS ENUM('SERPER_API', 'TAVILY_API', 'SLACK_CONNECTOR', 'NOTION_CONNECTOR', 'GITHUB_CONNECTOR', 'LINEAR_CONNECTOR')"
|
"CREATE TYPE searchsourceconnectortype AS ENUM("
|
||||||
|
"'SERPER_API', 'TAVILY_API', 'SLACK_CONNECTOR', "
|
||||||
|
"'NOTION_CONNECTOR', 'GITHUB_CONNECTOR', 'LINEAR_CONNECTOR'"
|
||||||
|
")"
|
||||||
)
|
)
|
||||||
op.execute(
|
op.execute(
|
||||||
"ALTER TABLE search_source_connectors ALTER COLUMN connector_type TYPE searchsourceconnectortype USING "
|
"ALTER TABLE search_source_connectors "
|
||||||
"connector_type::text::searchsourceconnectortype"
|
"ALTER COLUMN connector_type "
|
||||||
|
"TYPE searchsourceconnectortype "
|
||||||
|
"USING connector_type::text::searchsourceconnectortype"
|
||||||
)
|
)
|
||||||
op.execute("DROP TYPE searchsourceconnectortype_old")
|
op.execute("DROP TYPE searchsourceconnectortype_old")
|
||||||
|
|
||||||
pass
|
|
||||||
# ### end Alembic commands ###
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ import {
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@/components/ui/table";
|
} from "@/components/ui/table";
|
||||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
||||||
|
import { EnumConnectorName } from "@/contracts/enums/connector";
|
||||||
import { useSearchSourceConnectors } from "@/hooks/useSearchSourceConnectors";
|
import { useSearchSourceConnectors } from "@/hooks/useSearchSourceConnectors";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
@ -61,6 +62,7 @@ export default function ConnectorsPage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const searchSpaceId = params.search_space_id as string;
|
const searchSpaceId = params.search_space_id as string;
|
||||||
|
const today = new Date();
|
||||||
|
|
||||||
const { connectors, isLoading, error, deleteConnector, indexConnector } =
|
const { connectors, isLoading, error, deleteConnector, indexConnector } =
|
||||||
useSearchSourceConnectors();
|
useSearchSourceConnectors();
|
||||||
|
@ -139,6 +141,28 @@ export default function ConnectorsPage() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getDisabledEndDates = (date: Date) => {
|
||||||
|
const connector = connectors.find((c) => c.id === selectedConnectorForIndexing);
|
||||||
|
|
||||||
|
switch (connector?.connector_type) {
|
||||||
|
case EnumConnectorName.GOOGLE_CALENDAR_CONNECTOR:
|
||||||
|
return startDate ? date < startDate : false;
|
||||||
|
default:
|
||||||
|
return date > today || (startDate ? date < startDate : false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getDisabledStartDates = (date: Date) => {
|
||||||
|
const connector = connectors.find((c) => c.id === selectedConnectorForIndexing);
|
||||||
|
|
||||||
|
switch (connector?.connector_type) {
|
||||||
|
case EnumConnectorName.GOOGLE_CALENDAR_CONNECTOR:
|
||||||
|
return endDate ? date > endDate : false;
|
||||||
|
default:
|
||||||
|
return date > today || (endDate ? date > endDate : false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container mx-auto py-8 max-w-6xl">
|
<div className="container mx-auto py-8 max-w-6xl">
|
||||||
<motion.div
|
<motion.div
|
||||||
|
@ -342,7 +366,7 @@ export default function ConnectorsPage() {
|
||||||
mode="single"
|
mode="single"
|
||||||
selected={startDate}
|
selected={startDate}
|
||||||
onSelect={setStartDate}
|
onSelect={setStartDate}
|
||||||
disabled={(date) => date > new Date() || (endDate ? date > endDate : false)}
|
disabled={getDisabledStartDates}
|
||||||
initialFocus
|
initialFocus
|
||||||
/>
|
/>
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
|
@ -369,9 +393,7 @@ export default function ConnectorsPage() {
|
||||||
mode="single"
|
mode="single"
|
||||||
selected={endDate}
|
selected={endDate}
|
||||||
onSelect={setEndDate}
|
onSelect={setEndDate}
|
||||||
disabled={(date) =>
|
disabled={getDisabledEndDates}
|
||||||
date > new Date() || (startDate ? date < startDate : false)
|
|
||||||
}
|
|
||||||
initialFocus
|
initialFocus
|
||||||
/>
|
/>
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
|
@ -393,7 +415,6 @@ export default function ConnectorsPage() {
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const today = new Date();
|
|
||||||
const thirtyDaysAgo = new Date(today);
|
const thirtyDaysAgo = new Date(today);
|
||||||
thirtyDaysAgo.setDate(today.getDate() - 30);
|
thirtyDaysAgo.setDate(today.getDate() - 30);
|
||||||
setStartDate(thirtyDaysAgo);
|
setStartDate(thirtyDaysAgo);
|
||||||
|
@ -406,7 +427,6 @@ export default function ConnectorsPage() {
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const today = new Date();
|
|
||||||
const yearAgo = new Date(today);
|
const yearAgo = new Date(today);
|
||||||
yearAgo.setFullYear(today.getFullYear() - 1);
|
yearAgo.setFullYear(today.getFullYear() - 1);
|
||||||
setStartDate(yearAgo);
|
setStartDate(yearAgo);
|
||||||
|
|
15
surfsense_web/contracts/enums/connector.ts
Normal file
15
surfsense_web/contracts/enums/connector.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
export enum EnumConnectorName {
|
||||||
|
SERPER_API = "SERPER_API",
|
||||||
|
TAVILY_API = "TAVILY_API",
|
||||||
|
LINKUP_API = "LINKUP_API",
|
||||||
|
SLACK_CONNECTOR = "SLACK_CONNECTOR",
|
||||||
|
NOTION_CONNECTOR = "NOTION_CONNECTOR",
|
||||||
|
GITHUB_CONNECTOR = "GITHUB_CONNECTOR",
|
||||||
|
LINEAR_CONNECTOR = "LINEAR_CONNECTOR",
|
||||||
|
JIRA_CONNECTOR = "JIRA_CONNECTOR",
|
||||||
|
DISCORD_CONNECTOR = "DISCORD_CONNECTOR",
|
||||||
|
CONFLUENCE_CONNECTOR = "CONFLUENCE_CONNECTOR",
|
||||||
|
CLICKUP_CONNECTOR = "CLICKUP_CONNECTOR",
|
||||||
|
GOOGLE_CALENDAR_CONNECTOR = "GOOGLE_CALENDAR_CONNECTOR",
|
||||||
|
GOOGLE_GMAIL_CONNECTOR = "GOOGLE_GMAIL_CONNECTOR",
|
||||||
|
}
|
|
@ -10,6 +10,10 @@ export const getConnectorTypeDisplay = (type: string): string => {
|
||||||
JIRA_CONNECTOR: "Jira",
|
JIRA_CONNECTOR: "Jira",
|
||||||
DISCORD_CONNECTOR: "Discord",
|
DISCORD_CONNECTOR: "Discord",
|
||||||
LINKUP_API: "Linkup",
|
LINKUP_API: "Linkup",
|
||||||
|
CONFLUENCE_CONNECTOR: "Confluence",
|
||||||
|
CLICKUP_CONNECTOR: "ClickUp",
|
||||||
|
GOOGLE_CALENDAR_CONNECTOR: "Google Calendar",
|
||||||
|
GOOGLE_GMAIL_CONNECTOR: "Google Gmail",
|
||||||
};
|
};
|
||||||
return typeMap[type] || type;
|
return typeMap[type] || type;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue