diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 64012baa..36edb285 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,15 +1,11 @@ FROM mcr.microsoft.com/devcontainers/go:1 RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends ffmpeg python3 python3-pip \ + && apt-get -y install --no-install-recommends ffmpeg \ && apt-get clean -y && rm -rf /var/lib/apt/lists/* -RUN pip3 install --no-cache --upgrade --break-system-packages pip streamlink chat-downloader - WORKDIR /tmp -RUN wget https://github.com/rsms/inter/releases/download/v4.0-beta7/Inter-4.0-beta7.zip && unzip Inter-4.0-beta7.zip && mkdir -p /usr/share/fonts/opentype/inter/ && cp /tmp/Desktop/Inter-*.otf /usr/share/fonts/opentype/inter/ && fc-cache -f -v +RUN wget https://github.com/rsms/inter/releases/download/v4.1/Inter-4.1.zip && unzip Inter-4.1.zip && mkdir -p /usr/share/fonts/opentype/inter/ && cp /tmp/extras/otf/Inter-*.otf /usr/share/fonts/opentype/inter/ && fc-cache -f -v RUN wget https://github.com/lay295/TwitchDownloader/releases/download/1.55.0/TwitchDownloaderCLI-1.55.0-Linux-x64.zip && unzip TwitchDownloaderCLI-1.55.0-Linux-x64.zip && mv TwitchDownloaderCLI /usr/local/bin/ && chmod +x /usr/local/bin/TwitchDownloaderCLI && rm TwitchDownloaderCLI-1.55.0-Linux-x64.zip - -RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.1 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 723a72cf..cad03227 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,7 +3,10 @@ "features": { "ghcr.io/jungaretti/features/make:1": {}, "ghcr.io/devcontainers/features/github-cli:1": {}, - "ghcr.io/devcontainers/features/docker-in-docker:2": {} + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers/features/node:1": {}, + "ghcr.io/guiyomh/features/golangci-lint:0": {}, + "ghcr.io/devcontainers/features/python:1": {} }, "customizations": { "vscode": { @@ -11,8 +14,13 @@ "dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "eamodio.gitlens", - "github.copilot", - "yzhang.markdown-all-in-one" + "yzhang.markdown-all-in-one", + "esbenp.prettier-vscode", + "naumovs.color-highlight", + "ms-vscode-remote.remote-containers", + "burkeholland.simple-react-snippets", + "vunguyentuan.vscode-css-variables", + "vunguyentuan.vscode-postcss" ] } }, @@ -20,22 +28,28 @@ "appPort": ["0.0.0.0:4000:4000"], "mounts": [ { - "source": "${localWorkspaceFolder}/dev/vods", - "target": "/vods", + "source": "${localWorkspaceFolder}/dev/videos", + "target": "/data/videos", "type": "bind" }, { - "source": "${localWorkspaceFolder}/dev/data", - "target": "/data", + "source": "${localWorkspaceFolder}/dev/temp", + "target": "/data/temp", "type": "bind" }, { "source": "${localWorkspaceFolder}/dev/logs", - "target": "/logs", + "target": "/data/logs", + "type": "bind" + }, + { + "source": "${localWorkspaceFolder}/dev/config", + "target": "/data/config", "type": "bind" } ], "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached", "workspaceFolder": "/workspace", + "postCreateCommand": "pip install streamlink chat-downloader --break-system-packages", "postAttachCommand": "sudo chown -R vscode:vscode /go && make dev_setup" } diff --git a/.dockerignore b/.dockerignore index 65c8dae4..f03e0998 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,22 @@ .github dev tmp -bin \ No newline at end of file +bin +/frontend/node_modules +/frontend/.pnp +/frontend/.pnp.* +/frontend/.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/versions +/coverage +/frontend/.next/ +/out/ +/build +/frontend/npm-debug.log* +/frontend/yarn-debug.log* +/frontend/yarn-error.log* +/frontend/.env* +/frontend/*.tsbuildinfo +/frontend/next-env.d.ts diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 2d4b3c1b..e3ab2aeb 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -9,9 +9,7 @@ on: branches: ["main"] env: - # Use docker.io for Docker Hub if empty REGISTRY: ghcr.io - # github.repository as / IMAGE_NAME: ${{ github.repository }} jobs: @@ -60,3 +58,8 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} context: . + # cache builds in github actions + cache-from: type=gha + cache-to: type=gha,mode=max + # better compression + outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true diff --git a/.gitignore b/.gitignore index 89e69333..c9f64f44 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,3 @@ -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs and plugins *.exe *.exe~ *.dll @@ -14,9 +10,6 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out -# Dependency directories (remove the comment below to include it) -# vendor/ - # Go workspace file go.work @@ -26,4 +19,36 @@ go.work dev tmp **/__debug -__debug* \ No newline at end of file +__debug* + +# dependencies +/frontend/node_modules +/frontend/.pnp +/frontend/.pnp.* +/frontend/.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/versions + +# testing +/coverage + +# next.js +/frontend/.next/ +/out/ + +# production +/build + +# debug +/frontend/npm-debug.log* +/frontend/yarn-debug.log* +/frontend/yarn-error.log* + +# env files (can opt-in for committing if needed) +/frontend/.env* + +# typescript +/frontend/*.tsbuildinfo +/frontend/next-env.d.ts diff --git a/.server.air.toml b/.server.air.toml index b397b8fb..c0dfaa12 100644 --- a/.server.air.toml +++ b/.server.air.toml @@ -7,7 +7,7 @@ tmp_dir = "tmp" bin = "./tmp/server" cmd = "make build_dev_server" delay = 1000 - exclude_dir = ["tmp", "dev"] + exclude_dir = ["tmp", "dev", "frontend"] exclude_file = [] exclude_regex = ["_test.go"] exclude_unchanged = false diff --git a/.worker.air.toml b/.worker.air.toml index 3e8b8ef7..3a7be27f 100644 --- a/.worker.air.toml +++ b/.worker.air.toml @@ -7,7 +7,7 @@ tmp_dir = "tmp" bin = "./tmp/worker" cmd = "make build_dev_worker" delay = 1000 - exclude_dir = ["tmp", "dev"] + exclude_dir = ["tmp", "dev", "frontend"] exclude_file = [] exclude_regex = ["_test.go"] exclude_unchanged = false diff --git a/Dockerfile b/Dockerfile index d44f1e1c..5e98d817 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,21 @@ ARG TWITCHDOWNLOADER_VERSION="1.55.0" -# Build stage -FROM golang:1.22-bookworm AS build +# +# API Build +# +FROM golang:1.23-bookworm AS build-api WORKDIR /app COPY . . RUN make build_server build_worker -# Tools stage +# +# API Tools +# FROM debian:bookworm-slim AS tools WORKDIR /tmp RUN apt-get update && apt-get install -y --no-install-recommends \ -unzip git ca-certificates curl \ -&& rm -rf /var/lib/apt/lists/* + unzip git ca-certificates curl \ + && rm -rf /var/lib/apt/lists/* # Download TwitchDownloader for the correct platform ARG TWITCHDOWNLOADER_VERSION @@ -19,7 +23,7 @@ ENV TWITCHDOWNLOADER_URL=https://github.com/lay295/TwitchDownloader/releases/dow RUN if [ "$(uname -m)" = "aarch64" ]; then \ -TWITCHDOWNLOADER_URL=https://github.com/lay295/TwitchDownloader/releases/download/${TWITCHDOWNLOADER_VERSION}/TwitchDownloaderCLI-${TWITCHDOWNLOADER_VERSION}-LinuxArm64.zip; \ + TWITCHDOWNLOADER_URL=https://github.com/lay295/TwitchDownloader/releases/download/${TWITCHDOWNLOADER_VERSION}/TwitchDownloaderCLI-${TWITCHDOWNLOADER_VERSION}-LinuxArm64.zip; \ fi && \ echo "Download URL: $TWITCHDOWNLOADER_URL" && \ curl -L $TWITCHDOWNLOADER_URL -o twitchdownloader.zip && \ @@ -28,13 +32,48 @@ TWITCHDOWNLOADER_URL=https://github.com/lay295/TwitchDownloader/releases/downloa RUN git clone --depth 1 https://github.com/xenova/chat-downloader.git +# +# Frontend base +# +FROM node:22-alpine AS base-frontend + +# Install dependencies only when needed +FROM node:22-alpine AS deps +RUN apk add --no-cache libc6-compat +WORKDIR /app + +COPY frontend/package.json frontend/package-lock.json* ./ +RUN \ + if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ + elif [ -f package-lock.json ]; then npm ci --force; \ + elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ + else echo "Lockfile not found." && exit 1; \ + fi + +# +# Frontend build +# +FROM node:22-alpine AS build-frontend +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY frontend/. . + +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN \ + if [ -f yarn.lock ]; then yarn run build; \ + elif [ -f package-lock.json ]; then npm run build; \ + elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \ + else echo "Lockfile not found." && exit 1; \ + fi + # Production stage FROM debian:bookworm-slim WORKDIR /opt/app # Install dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ - python3 python3-pip fontconfig ffmpeg tzdata procps \ + python3 python3-pip fontconfig ffmpeg tzdata procps supervisor \ fonts-noto-core fonts-noto-cjk fonts-noto-extra fonts-inter \ curl \ && rm -rf /var/lib/apt/lists/* \ @@ -48,6 +87,20 @@ RUN curl -LO https://github.com/tianon/gosu/releases/latest/download/gosu-$(dpkg && chmod 0755 gosu-$(dpkg --print-architecture | awk -F- '{ print $NF }') \ && mv gosu-$(dpkg --print-architecture | awk -F- '{ print $NF }') /usr/local/bin/gosu +# Install node for frontend +ENV NODE_VERSION=22.x \ + DEBIAN_FRONTEND=noninteractive + +# Install required packages, add NodeSource repository, and install Node.js +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl \ + ca-certificates \ + gnupg \ + && curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - \ + && apt-get install -y --no-install-recommends nodejs \ + && apt-get clean && rm -rf /var/lib/apt/lists/* +RUN node --version && npm --version + # Setup user RUN useradd -u 911 -d /data abc && usermod -a -G users abc @@ -62,13 +115,30 @@ RUN chmod 644 /usr/share/fonts/* && chmod -R a+rX /usr/share/fonts COPY --from=tools /tmp/TwitchDownloaderCLI /usr/local/bin/ RUN chmod +x /usr/local/bin/TwitchDownloaderCLI -# Copy application files -COPY --from=build /app/ganymede-api . -COPY --from=build /app/ganymede-worker . +# Copy api and worker builds +COPY --from=build-api /app/ganymede-api . +COPY --from=build-api /app/ganymede-worker . + +# Setup frontend +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +COPY --from=build-frontend /app/public ./public + +RUN mkdir .next +RUN chown nextjs:nodejs .next + +COPY --from=build-frontend --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=build-frontend --chown=nextjs:nodejs /app/.next/static ./.next/static +ENV HOSTNAME="0.0.0.0" + # Setup entrypoint COPY entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/entrypoint.sh +COPY supervisord.conf /opt/app/supervisord.conf EXPOSE 4000 ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/Makefile b/Makefile index 5601adde..216910c0 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ dev_setup: go install github.com/joho/godotenv/cmd/godotenv@latest go install github.com/air-verse/air@latest + cd frontend && npm install --force build_server: go build -ldflags='-X github.com/zibbp/ganymede/internal/utils.Commit=$(shell git rev-parse HEAD) -X github.com/zibbp/ganymede/internal/utils.BuildTime=$(shell date -u "+%Y-%m-%d_%H:%M:%S")' -o ganymede-api cmd/server/main.go @@ -22,9 +23,16 @@ dev_worker: rm -f ./tmp/worker air -c ./.worker.air.toml +dev_web: + cd frontend && npm run dev + ent_generate: go run -mod=mod entgo.io/ent/cmd/ent generate --feature sql/upsert ./ent/schema +ent_new_schema: + @read -p "Enter schema name:" schema; \ + go run -mod=mod entgo.io/ent/cmd/ent new $$schema + go_update_packages: go get -u ./... && go mod tidy diff --git a/README.md b/README.md index ef052d11..387abe75 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@

Ganymede

- Twitch VOD and Live Stream archiving platform with a real-time and rendered chat experience. Files are saved in a friendly format allowing for use without Ganymede. + Ganymede is a Twitch VOD and Live Stream archiving platform with a real-time chat experience. Every archive includes a rendered chat for viewing outside of Ganymede. Files are saved in a friendly format allowing for use without Ganymede.

@@ -15,9 +15,9 @@ ## Screenshot -![ganymede-readme_landing](https://user-images.githubusercontent.com/21207065/203620886-f40b82f6-317c-4ded-afdc-733d1658f6ca.jpg) +![ganymede-readme_landing](https://github.com/user-attachments/assets/b1c024f5-f5ad-4611-84db-42d599364a74) -https://user-images.githubusercontent.com/21207065/203620893-41a6a3a0-339a-4c62-8df8-0f66ec68327d.mp4 +https://github.com/user-attachments/assets/184451f1-e3ce-4329-8516-a9842648c01b ## About @@ -28,13 +28,14 @@ Ganymede allows archiving of past streams (VODs) and live streams with a real-ti - Realtime Chat Playback - SSO / OAuth authentication ([wiki](https://github.com/Zibbp/ganymede/wiki/SSO---OpenID-Connect)) - Light/dark mode toggle. -- 'Watched channels' - watch channels for videos and live streams. +- 'Watched channels' + - Allows watching channels for archiving past broadcasts and live streams. Includes advanced filtering options. - Twitch VOD/Livestream support. - Full VOD, Channel, and User management. - Custom post-download video FFmpeg parameters. - Custom chat render parameters. - Webhook notifications. -- Simple file structure for long-term archival that will outlas Ganymede. +- Simple file structure for long-term archival that will outlast Ganymede. - Recoverable queue system. - Playback / progress saving. - Playlists. @@ -59,16 +60,14 @@ Visit the [docs](https://github.com/Zibbp/ganymede/tree/master/docs) folder for ### Installation -Ganymede consists of four docker containers: +Ganymede consists of two docker containers: -1. API -2. Frontend -3. Postgres Database -4. Nginx +1. Server +2. Postgres Database -Feel free to use an existing Postgres database container and Nginx container if you don't want to spin new ones up. +Feel free to use an existing Postgres database container if you don't want to spin new ones up. -1. Download a copy of the `docker-compose.yml` file and `nginx.conf`. +1. Download a copy of the `docker-compose.yml` file. 2. Edit the `docker-compose.yml` file modifying the environment variables, see [environment variables](https://github.com/Zibbp/ganymede#environment-variables) for more information. 3. Run `docker compose up -d`. 4. Visit the address and port you specified for the frontend and login with username: `admin` password: `ganymede`. @@ -82,51 +81,40 @@ Note: On startup the container will `chown` the config, temp, and logs directory ### Environment Variables -The `docker-compose.yml` file has comments for each environment variable. The `*_URL` envionrment variables _must_ be the 'public' URLs (e.g. `https://ganymedem.domain.com`) it cannot be a URL to just the docker service. - -##### API - -| ENV Name | Description | -| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `DEBUG` | Enable debug logging `true` or `false`. | -| `VIDEOS_DIR` | Path inside the container to the videos directory. Default: `/data/videos`. | -| `TEMP_DIR` | Path inside the container where temporary files are stored during archiving. Default: `/data/temp`. | -| `LOGS_DIR` | Path inside the container where log files are stored. Default: `/data/logs`. | -| `CONFIG_DIR` | Path inside the container where the config is stored. Default: `/data/config`. | -| `PATH_MIGRATION_ENABLED` | Enable path migration at startup. Default: `true`. | -| `TZ` | Timezone. | -| `DB_HOST` | Host of the database. | -| `DB_PORT` | Port of the database. | -| `DB_USER` | Username for the database. | -| `DB_PASS` | Password for the database. | -| `DB_NAME` | Name of the database. | -| `DB_SSL` | Whether to use SSL. Default: `disable`. See [DB SSL](https://github.com/Zibbp/ganymede/wiki/DB-SSL) for more information. | -| `DB_SSL_ROOT_CERT` | _Optional_ Path to DB SSL root certificate. See [DB SSL](https://github.com/Zibbp/ganymede/wiki/DB-SSL) for more information. | -| `JWT_SECRET` | Secret for JWT tokens. This should be a long random string. | -| `JWT_REFRESH_SECRET` | Secret for JWT refresh tokens. This should be a long random string. | -| `TWITCH_CLIENT_ID` | Twitch application client ID. | -| `TWITCH_CLIENT_SECRET` | Twitch application client secret. | -| `FRONTEND_HOST` | Host of the frontend, used for CORS. Example: `http://192.168.1.2:4801` | -| `COOKIE_DOMAIN` | _Optional_ Domain the cookie is valid for. This is used with a reverse proxy and should be the top level domain (e.g. `domain.com`). You may need to tinker with this variable depending how your reverse proxy is setup. Typically it is the root where ganymede is or the level up-one. | -| `OAUTH_ENABLED` | _Optional_ Wheter OAuth is enabled `true` or `false`. Must have the other OAuth variables set if this is enabled. | -| `OAUTH_PROVIDER_URL` | _Optional_ OAuth provider URL. See https://github.com/Zibbp/ganymede/wiki/SSO---OpenID-Connect | -| `OAUTH_CLIENT_ID` | _Optional_ OAuth client ID. | -| `OAUTH_CLIENT_SECRET` | _Optional_ OAuth client secret. | -| `OAUTH_REDIRECT_URL` | _Optional_ OAuth redirect URL, points to the API. Example: `http://localhost:4000/api/v1/auth/oauth/callback`. | -| `MAX_CHAT_DOWNLOAD_EXECUTIONS` | Maximum number of chat downloads that can be running at once. Live streams bypass this limit. | -| `MAX_CHAT_RENDER_EXECUTIONS` | Maximum number of chat renders that can be running at once. | -| `MAX_VIDEO_DOWNLOAD_EXECUTIONS` | Maximum number of video downloads that can be running at once. Live streams bypass this limit. | -| `MAX_VIDEO_CONVERT_EXECUTIONS` | Maximum number of video conversions that can be running at once. | - -##### Frontend - -| ENV Name | Description | -| ----------------------- | ---------------------------------------------------------------------- | -| `API_URL` | Host for the API. Example: `http://192.168.1.2:4800`. | -| `CDN_URL` | Host for the Nginx serivce. Example: `http://197.148.1.2:4802`. | -| `SHOW_SSO_LOGIN_BUTTON` | `true/false` Show a "login via sso" button on the login page. | -| `FORCE_SSO_AUTH` | `true/false` Force users to login via SSO by bypassing the login page. | -| `REQUIRE_LOGIN` | `true/false` Require users to be logged in to view videos. | +The `docker-compose.yml` file has comments for each environment variable. Below is a list of all environment variables and their descriptions. + +##### Server + +| ENV Name | Description | +| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | +| `DEBUG` | Enable debug logging `true` or `false`. | +| `VIDEOS_DIR` | Path inside the container to the videos directory. Default: `/data/videos`. | +| `TEMP_DIR` | Path inside the container where temporary files are stored during archiving. Default: `/data/temp`. | +| `LOGS_DIR` | Path inside the container where log files are stored. Default: `/data/logs`. | +| `CONFIG_DIR` | Path inside the container where the config is stored. Default: `/data/config`. | +| `PATH_MIGRATION_ENABLED` | Enable path migration at startup. Default: `true`. | +| `TZ` | Timezone. | +| `DB_HOST` | Host of the database. | +| `DB_PORT` | Port of the database. | +| `DB_USER` | Username for the database. | +| `DB_PASS` | Password for the database. | +| `DB_NAME` | Name of the database. | +| `DB_SSL` | Whether to use SSL. Default: `disable`. See [DB SSL](https://github.com/Zibbp/ganymede/wiki/DB-SSL) for more information. | +| `DB_SSL_ROOT_CERT` | _Optional_ Path to DB SSL root certificate. See [DB SSL](https://github.com/Zibbp/ganymede/wiki/DB-SSL) for more information. | +| `TWITCH_CLIENT_ID` | Twitch application client ID. | +| `TWITCH_CLIENT_SECRET` | Twitch application client secret. | +| `OAUTH_ENABLED` | _Optional_ Wheter OAuth is enabled `true` or `false`. Must have the other OAuth variables set if this is enabled. | +| `OAUTH_PROVIDER_URL` | _Optional_ OAuth provider URL. See https://github.com/Zibbp/ganymede/wiki/SSO---OpenID-Connect | +| `OAUTH_CLIENT_ID` | _Optional_ OAuth client ID. | +| `OAUTH_CLIENT_SECRET` | _Optional_ OAuth client secret. | +| `OAUTH_REDIRECT_URL` | _Optional_ OAuth redirect URL, points to the API. Example: `http://localhost:4000/api/v1/auth/oauth/callback`. | +| `MAX_CHAT_DOWNLOAD_EXECUTIONS` | Maximum number of chat downloads that can be running at once. Live streams bypass this limit. | +| `MAX_CHAT_RENDER_EXECUTIONS` | Maximum number of chat renders that can be running at once. | +| `MAX_VIDEO_DOWNLOAD_EXECUTIONS` | Maximum number of video downloads that can be running at once. Live streams bypass this limit. | +| `MAX_VIDEO_CONVERT_EXECUTIONS` | Maximum number of video conversions that can be running at once. | +| `SHOW_SSO_LOGIN_BUTTON` | Frontend: `true/false` Show a "login via sso" button on the login page. | +| `FORCE_SSO_AUTH` | Frontend: `true/false` Force users to login via SSO by bypassing the login page. | +| `REQUIRE_LOGIN` | Frontend: `true/false` Require users to be logged in to view videos. | ##### DB @@ -149,13 +137,6 @@ The `docker-compose.yml` file has comments for each environment variable. The `* | `/data/temp` | Mount to store temporay files during the archive process. This is mounted to the host so files are recoverable in the event of a crash. This **must** match the `TEMP_DIR` environment variable. | `./temp:/data/temp` | | `/data/config` | Mount to store the config. This **must** match the `CONFIG_DIR` environment variable. | `./config:/data/config` | -##### Nginx - -| Volume | Description | Example | -| -------------------------- | ---------------------------------------------------------- | ---------------------------------------------- | -| `/data/videos` | Mount for video storage, same as the API container volume. | `/mnt/nas/vods:/data/videos` | -| `/etc/nginx/nginx.conf:ro` | Path to the Nginx conf file. | `/path/to/nginx.conf:/etc/nginx/nginx.conf:ro` | - ## Acknowledgements - [TwitchDownloader](https://github.com/lay295/TwitchDownloader) diff --git a/cmd/server/main.go b/cmd/server/main.go index 8bdec376..45e8eb33 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -14,7 +14,7 @@ import ( func main() { ctx := context.Background() - if os.Getenv("ENV") == "dev" { + if os.Getenv("DEVELOPMENT") == "true" { log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) } log.Info().Str("commit", utils.Commit).Str("build_time", utils.BuildTime).Msg("starting server") diff --git a/cmd/worker/main.go b/cmd/worker/main.go index b46e0c60..2db28a0b 100644 --- a/cmd/worker/main.go +++ b/cmd/worker/main.go @@ -34,7 +34,7 @@ func main() { log.Panic().Err(err).Msg("Error initializing server config") } - if os.Getenv("ENV") == "dev" { + if os.Getenv("DEVELOPMENT") == "true" { log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) } diff --git a/docker-compose.yml b/docker-compose.yml index 9977b61a..186d5602 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: "3.3" services: - ganymede-api: - container_name: ganymede-api + ganymede: + container_name: ganymede image: ghcr.io/zibbp/ganymede:latest restart: unless-stopped depends_on: @@ -21,13 +21,9 @@ services: - DB_PASS=PASSWORD - DB_NAME=ganymede-prd - DB_SSL=disable - #- DB_SSL_ROOT_CERT= # path to cert in the container if DB_SSL is not disabled - - JWT_SECRET=SECRET # set as a random string - - JWT_REFRESH_SECRET=SECRET # set as a random string + # - DB_SSL_ROOT_CERT= # path to cert in the container if DB_SSL is not disabled - TWITCH_CLIENT_ID= # from your twitch application - TWITCH_CLIENT_SECRET= # from your twitch application - - FRONTEND_HOST=http://IP:PORT # URL to the frontend service. Needs to be the 'public' url that you visit. - #- COOKIE_DOMAIN= # Optional domain that the cookies will be set to. Should be the top level domain with a reverse proxy (e.g. `domain.com`). # Worker settings. Max number of tasks to run in parallel per type. - MAX_CHAT_DOWNLOAD_EXECUTIONS=3 - MAX_CHAT_RENDER_EXECUTIONS=2 @@ -39,6 +35,10 @@ services: # - OAUTH_CLIENT_ID= # - OAUTH_CLIENT_SECRET= # - OAUTH_REDIRECT_URL=http://IP:PORT/api/v1/auth/oauth/callback # Points to the API service + # Optional Frontend settings + - SHOW_SSO_LOGIN_BUTTON=true + - FORCE_SSO_AUTH=false + - REQUIRE_LOGIN=false volumes: - /path/to/vod/storage:/data/videos # update VIDEOS_DIR env var - ./temp:/data/temp # update TEMP_DIR env var @@ -46,18 +46,12 @@ services: - ./config:/data/config # config and other miscellaneous files ports: - 4800:4000 - ganymede-frontend: - container_name: ganymede-frontend - image: ghcr.io/zibbp/ganymede-frontend:latest - restart: unless-stopped - environment: - - API_URL=http://IP:PORT # Points to the API service; the container must be able to access this URL internally - - CDN_URL=http://IP:PORT # Can point to your nginx service, or set same as API_URL if nginx is not used - - SHOW_SSO_LOGIN_BUTTON=true # show/hide SSO login button on login page - - FORCE_SSO_AUTH=false # force SSO auth for all users (bypasses login page and redirects to SSO) - - REQUIRE_LOGIN=false # require login to view videos - ports: - - 4801:3000 + healthcheck: + test: curl --fail http://localhost:4000/health || exit 1 + interval: 60s + retries: 5 + start_period: 60s + timeout: 10s ganymede-db: container_name: ganymede-db image: postgres:14 @@ -68,20 +62,11 @@ services: - POSTGRES_USER=ganymede - POSTGRES_DB=ganymede-prd ports: - - 4803:5432 - # Nginx is not really required, it provides nice-to-have caching. The API container will serve the VIDEO_DIR env var path if you want to use that instead (e.g. VIDEOS_DIR=/data/videos would be served at IP:4800/data/videos/channel/channel.jpg). - ganymede-nginx: - container_name: ganymede-nginx - image: nginx - volumes: - - /path/to/nginx.conf:/etc/nginx/nginx.conf:ro - - /pah/to/vod/stoage:/data/videos - ports: - - 4802:8080 - # River UI is a frontend for the task system that Ganymede uses. This provides a more in-depth look at the task queue. - ganymede-river-ui: - image: ghcr.io/riverqueue/riverui:0.3 - environment: - - DATABASE_URL=postgres://ganymede:DB_PASSWORD@ganymede-db:5432/ganymede-prd # update with env settings from the ganymede-db container. If you're using the default database settings then just update the DB_PASSWORD env var. - ports: - - 4804:8080 + - 4801:5432 + restart: unless-stopped + healthcheck: + test: ["CMD-SHELL", "pg_isready", "-d", "{{ ganymede_db_name }}"] + interval: 30s + timeout: 60s + retries: 5 + start_period: 60s \ No newline at end of file diff --git a/ent/client.go b/ent/client.go index e7534a9b..4d32a21f 100644 --- a/ent/client.go +++ b/ent/client.go @@ -27,6 +27,7 @@ import ( "github.com/zibbp/ganymede/ent/playback" "github.com/zibbp/ganymede/ent/playlist" "github.com/zibbp/ganymede/ent/queue" + "github.com/zibbp/ganymede/ent/sessions" "github.com/zibbp/ganymede/ent/twitchcategory" "github.com/zibbp/ganymede/ent/user" "github.com/zibbp/ganymede/ent/vod" @@ -59,6 +60,8 @@ type Client struct { Playlist *PlaylistClient // Queue is the client for interacting with the Queue builders. Queue *QueueClient + // Sessions is the client for interacting with the Sessions builders. + Sessions *SessionsClient // TwitchCategory is the client for interacting with the TwitchCategory builders. TwitchCategory *TwitchCategoryClient // User is the client for interacting with the User builders. @@ -87,6 +90,7 @@ func (c *Client) init() { c.Playback = NewPlaybackClient(c.config) c.Playlist = NewPlaylistClient(c.config) c.Queue = NewQueueClient(c.config) + c.Sessions = NewSessionsClient(c.config) c.TwitchCategory = NewTwitchCategoryClient(c.config) c.User = NewUserClient(c.config) c.Vod = NewVodClient(c.config) @@ -193,6 +197,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { Playback: NewPlaybackClient(cfg), Playlist: NewPlaylistClient(cfg), Queue: NewQueueClient(cfg), + Sessions: NewSessionsClient(cfg), TwitchCategory: NewTwitchCategoryClient(cfg), User: NewUserClient(cfg), Vod: NewVodClient(cfg), @@ -226,6 +231,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) Playback: NewPlaybackClient(cfg), Playlist: NewPlaylistClient(cfg), Queue: NewQueueClient(cfg), + Sessions: NewSessionsClient(cfg), TwitchCategory: NewTwitchCategoryClient(cfg), User: NewUserClient(cfg), Vod: NewVodClient(cfg), @@ -259,7 +265,7 @@ func (c *Client) Close() error { func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ c.BlockedVideos, c.Channel, c.Chapter, c.Live, c.LiveCategory, c.LiveTitleRegex, - c.MultistreamInfo, c.MutedSegment, c.Playback, c.Playlist, c.Queue, + c.MultistreamInfo, c.MutedSegment, c.Playback, c.Playlist, c.Queue, c.Sessions, c.TwitchCategory, c.User, c.Vod, } { n.Use(hooks...) @@ -271,7 +277,7 @@ func (c *Client) Use(hooks ...Hook) { func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ c.BlockedVideos, c.Channel, c.Chapter, c.Live, c.LiveCategory, c.LiveTitleRegex, - c.MultistreamInfo, c.MutedSegment, c.Playback, c.Playlist, c.Queue, + c.MultistreamInfo, c.MutedSegment, c.Playback, c.Playlist, c.Queue, c.Sessions, c.TwitchCategory, c.User, c.Vod, } { n.Intercept(interceptors...) @@ -303,6 +309,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.Playlist.mutate(ctx, m) case *QueueMutation: return c.Queue.mutate(ctx, m) + case *SessionsMutation: + return c.Sessions.mutate(ctx, m) case *TwitchCategoryMutation: return c.TwitchCategory.mutate(ctx, m) case *UserMutation: @@ -2001,6 +2009,139 @@ func (c *QueueClient) mutate(ctx context.Context, m *QueueMutation) (Value, erro } } +// SessionsClient is a client for the Sessions schema. +type SessionsClient struct { + config +} + +// NewSessionsClient returns a client for the Sessions from the given config. +func NewSessionsClient(c config) *SessionsClient { + return &SessionsClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `sessions.Hooks(f(g(h())))`. +func (c *SessionsClient) Use(hooks ...Hook) { + c.hooks.Sessions = append(c.hooks.Sessions, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `sessions.Intercept(f(g(h())))`. +func (c *SessionsClient) Intercept(interceptors ...Interceptor) { + c.inters.Sessions = append(c.inters.Sessions, interceptors...) +} + +// Create returns a builder for creating a Sessions entity. +func (c *SessionsClient) Create() *SessionsCreate { + mutation := newSessionsMutation(c.config, OpCreate) + return &SessionsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Sessions entities. +func (c *SessionsClient) CreateBulk(builders ...*SessionsCreate) *SessionsCreateBulk { + return &SessionsCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *SessionsClient) MapCreateBulk(slice any, setFunc func(*SessionsCreate, int)) *SessionsCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &SessionsCreateBulk{err: fmt.Errorf("calling to SessionsClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*SessionsCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &SessionsCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Sessions. +func (c *SessionsClient) Update() *SessionsUpdate { + mutation := newSessionsMutation(c.config, OpUpdate) + return &SessionsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *SessionsClient) UpdateOne(s *Sessions) *SessionsUpdateOne { + mutation := newSessionsMutation(c.config, OpUpdateOne, withSessions(s)) + return &SessionsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *SessionsClient) UpdateOneID(id int) *SessionsUpdateOne { + mutation := newSessionsMutation(c.config, OpUpdateOne, withSessionsID(id)) + return &SessionsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Sessions. +func (c *SessionsClient) Delete() *SessionsDelete { + mutation := newSessionsMutation(c.config, OpDelete) + return &SessionsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *SessionsClient) DeleteOne(s *Sessions) *SessionsDeleteOne { + return c.DeleteOneID(s.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *SessionsClient) DeleteOneID(id int) *SessionsDeleteOne { + builder := c.Delete().Where(sessions.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &SessionsDeleteOne{builder} +} + +// Query returns a query builder for Sessions. +func (c *SessionsClient) Query() *SessionsQuery { + return &SessionsQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeSessions}, + inters: c.Interceptors(), + } +} + +// Get returns a Sessions entity by its id. +func (c *SessionsClient) Get(ctx context.Context, id int) (*Sessions, error) { + return c.Query().Where(sessions.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *SessionsClient) GetX(ctx context.Context, id int) *Sessions { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *SessionsClient) Hooks() []Hook { + return c.hooks.Sessions +} + +// Interceptors returns the client interceptors. +func (c *SessionsClient) Interceptors() []Interceptor { + return c.inters.Sessions +} + +func (c *SessionsClient) mutate(ctx context.Context, m *SessionsMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&SessionsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&SessionsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&SessionsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&SessionsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Sessions mutation op: %q", m.Op()) + } +} + // TwitchCategoryClient is a client for the TwitchCategory schema. type TwitchCategoryClient struct { config @@ -2500,12 +2641,12 @@ func (c *VodClient) mutate(ctx context.Context, m *VodMutation) (Value, error) { type ( hooks struct { BlockedVideos, Channel, Chapter, Live, LiveCategory, LiveTitleRegex, - MultistreamInfo, MutedSegment, Playback, Playlist, Queue, TwitchCategory, User, - Vod []ent.Hook + MultistreamInfo, MutedSegment, Playback, Playlist, Queue, Sessions, + TwitchCategory, User, Vod []ent.Hook } inters struct { BlockedVideos, Channel, Chapter, Live, LiveCategory, LiveTitleRegex, - MultistreamInfo, MutedSegment, Playback, Playlist, Queue, TwitchCategory, User, - Vod []ent.Interceptor + MultistreamInfo, MutedSegment, Playback, Playlist, Queue, Sessions, + TwitchCategory, User, Vod []ent.Interceptor } ) diff --git a/ent/ent.go b/ent/ent.go index a7a3fc26..8ebe3d1c 100644 --- a/ent/ent.go +++ b/ent/ent.go @@ -23,6 +23,7 @@ import ( "github.com/zibbp/ganymede/ent/playback" "github.com/zibbp/ganymede/ent/playlist" "github.com/zibbp/ganymede/ent/queue" + "github.com/zibbp/ganymede/ent/sessions" "github.com/zibbp/ganymede/ent/twitchcategory" "github.com/zibbp/ganymede/ent/user" "github.com/zibbp/ganymede/ent/vod" @@ -97,6 +98,7 @@ func checkColumn(table, column string) error { playback.Table: playback.ValidColumn, playlist.Table: playlist.ValidColumn, queue.Table: queue.ValidColumn, + sessions.Table: sessions.ValidColumn, twitchcategory.Table: twitchcategory.ValidColumn, user.Table: user.ValidColumn, vod.Table: vod.ValidColumn, diff --git a/ent/hook/hook.go b/ent/hook/hook.go index 986901f8..522b5c4a 100644 --- a/ent/hook/hook.go +++ b/ent/hook/hook.go @@ -141,6 +141,18 @@ func (f QueueFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.QueueMutation", m) } +// The SessionsFunc type is an adapter to allow the use of ordinary +// function as Sessions mutator. +type SessionsFunc func(context.Context, *ent.SessionsMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f SessionsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.SessionsMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SessionsMutation", m) +} + // The TwitchCategoryFunc type is an adapter to allow the use of ordinary // function as TwitchCategory mutator. type TwitchCategoryFunc func(context.Context, *ent.TwitchCategoryMutation) (ent.Value, error) diff --git a/ent/live.go b/ent/live.go index 495a0799..0e658dce 100644 --- a/ent/live.go +++ b/ent/live.go @@ -18,37 +18,45 @@ import ( type Live struct { config `json:"-"` // ID of the ent. - ID uuid.UUID `json:"id,omitempty"` + ID uuid.UUID `json:"id"` // Watch live streams - WatchLive bool `json:"watch_live,omitempty"` + WatchLive bool `json:"watch_live"` // Watch new VODs - WatchVod bool `json:"watch_vod,omitempty"` + WatchVod bool `json:"watch_vod"` // Download archives - DownloadArchives bool `json:"download_archives,omitempty"` + DownloadArchives bool `json:"download_archives"` // Download highlights - DownloadHighlights bool `json:"download_highlights,omitempty"` + DownloadHighlights bool `json:"download_highlights"` // Download uploads - DownloadUploads bool `json:"download_uploads,omitempty"` + DownloadUploads bool `json:"download_uploads"` // Download sub only VODs - DownloadSubOnly bool `json:"download_sub_only,omitempty"` + DownloadSubOnly bool `json:"download_sub_only"` // Whether the channel is currently live. - IsLive bool `json:"is_live,omitempty"` + IsLive bool `json:"is_live"` // Whether the chat archive is enabled. - ArchiveChat bool `json:"archive_chat,omitempty"` + ArchiveChat bool `json:"archive_chat"` // Resolution holds the value of the "resolution" field. - Resolution string `json:"resolution,omitempty"` + Resolution string `json:"resolution"` // The time the channel last went live. - LastLive time.Time `json:"last_live,omitempty"` + LastLive time.Time `json:"last_live"` // Whether the chat should be rendered. - RenderChat bool `json:"render_chat,omitempty"` + RenderChat bool `json:"render_chat"` // Restrict fetching videos to a certain age. - VideoAge int64 `json:"video_age,omitempty"` + VideoAge int64 `json:"video_age"` // Whether the categories should be applied to livestreams. - ApplyCategoriesToLive bool `json:"apply_categories_to_live,omitempty"` + ApplyCategoriesToLive bool `json:"apply_categories_to_live"` + // Whether to download clips on a schedule. + WatchClips bool `json:"watch_clips"` + // The number of clips to archive. + ClipsLimit int `json:"clips_limit"` + // How often channel should be checked for clips to archive in days. + ClipsIntervalDays int `json:"clips_interval_days"` + // Time when clips were last checked. + ClipsLastChecked time.Time `json:"clips_last_checked"` // UpdatedAt holds the value of the "updated_at" field. - UpdatedAt time.Time `json:"updated_at,omitempty"` + UpdatedAt time.Time `json:"updated_at"` // CreatedAt holds the value of the "created_at" field. - CreatedAt time.Time `json:"created_at,omitempty"` + CreatedAt time.Time `json:"created_at"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the LiveQuery when eager-loading is set. Edges LiveEdges `json:"edges"` @@ -103,13 +111,13 @@ func (*Live) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case live.FieldWatchLive, live.FieldWatchVod, live.FieldDownloadArchives, live.FieldDownloadHighlights, live.FieldDownloadUploads, live.FieldDownloadSubOnly, live.FieldIsLive, live.FieldArchiveChat, live.FieldRenderChat, live.FieldApplyCategoriesToLive: + case live.FieldWatchLive, live.FieldWatchVod, live.FieldDownloadArchives, live.FieldDownloadHighlights, live.FieldDownloadUploads, live.FieldDownloadSubOnly, live.FieldIsLive, live.FieldArchiveChat, live.FieldRenderChat, live.FieldApplyCategoriesToLive, live.FieldWatchClips: values[i] = new(sql.NullBool) - case live.FieldVideoAge: + case live.FieldVideoAge, live.FieldClipsLimit, live.FieldClipsIntervalDays: values[i] = new(sql.NullInt64) case live.FieldResolution: values[i] = new(sql.NullString) - case live.FieldLastLive, live.FieldUpdatedAt, live.FieldCreatedAt: + case live.FieldLastLive, live.FieldClipsLastChecked, live.FieldUpdatedAt, live.FieldCreatedAt: values[i] = new(sql.NullTime) case live.FieldID: values[i] = new(uuid.UUID) @@ -214,6 +222,30 @@ func (l *Live) assignValues(columns []string, values []any) error { } else if value.Valid { l.ApplyCategoriesToLive = value.Bool } + case live.FieldWatchClips: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field watch_clips", values[i]) + } else if value.Valid { + l.WatchClips = value.Bool + } + case live.FieldClipsLimit: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field clips_limit", values[i]) + } else if value.Valid { + l.ClipsLimit = int(value.Int64) + } + case live.FieldClipsIntervalDays: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field clips_interval_days", values[i]) + } else if value.Valid { + l.ClipsIntervalDays = int(value.Int64) + } + case live.FieldClipsLastChecked: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field clips_last_checked", values[i]) + } else if value.Valid { + l.ClipsLastChecked = value.Time + } case live.FieldUpdatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field updated_at", values[i]) @@ -323,6 +355,18 @@ func (l *Live) String() string { builder.WriteString("apply_categories_to_live=") builder.WriteString(fmt.Sprintf("%v", l.ApplyCategoriesToLive)) builder.WriteString(", ") + builder.WriteString("watch_clips=") + builder.WriteString(fmt.Sprintf("%v", l.WatchClips)) + builder.WriteString(", ") + builder.WriteString("clips_limit=") + builder.WriteString(fmt.Sprintf("%v", l.ClipsLimit)) + builder.WriteString(", ") + builder.WriteString("clips_interval_days=") + builder.WriteString(fmt.Sprintf("%v", l.ClipsIntervalDays)) + builder.WriteString(", ") + builder.WriteString("clips_last_checked=") + builder.WriteString(l.ClipsLastChecked.Format(time.ANSIC)) + builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(l.UpdatedAt.Format(time.ANSIC)) builder.WriteString(", ") diff --git a/ent/live/live.go b/ent/live/live.go index a1de2ca0..35d29dab 100644 --- a/ent/live/live.go +++ b/ent/live/live.go @@ -41,6 +41,14 @@ const ( FieldVideoAge = "video_age" // FieldApplyCategoriesToLive holds the string denoting the apply_categories_to_live field in the database. FieldApplyCategoriesToLive = "apply_categories_to_live" + // FieldWatchClips holds the string denoting the watch_clips field in the database. + FieldWatchClips = "watch_clips" + // FieldClipsLimit holds the string denoting the clips_limit field in the database. + FieldClipsLimit = "clips_limit" + // FieldClipsIntervalDays holds the string denoting the clips_interval_days field in the database. + FieldClipsIntervalDays = "clips_interval_days" + // FieldClipsLastChecked holds the string denoting the clips_last_checked field in the database. + FieldClipsLastChecked = "clips_last_checked" // FieldUpdatedAt holds the string denoting the updated_at field in the database. FieldUpdatedAt = "updated_at" // FieldCreatedAt holds the string denoting the created_at field in the database. @@ -92,6 +100,10 @@ var Columns = []string{ FieldRenderChat, FieldVideoAge, FieldApplyCategoriesToLive, + FieldWatchClips, + FieldClipsLimit, + FieldClipsIntervalDays, + FieldClipsLastChecked, FieldUpdatedAt, FieldCreatedAt, } @@ -144,6 +156,12 @@ var ( DefaultVideoAge int64 // DefaultApplyCategoriesToLive holds the default value on creation for the "apply_categories_to_live" field. DefaultApplyCategoriesToLive bool + // DefaultWatchClips holds the default value on creation for the "watch_clips" field. + DefaultWatchClips bool + // DefaultClipsLimit holds the default value on creation for the "clips_limit" field. + DefaultClipsLimit int + // DefaultClipsIntervalDays holds the default value on creation for the "clips_interval_days" field. + DefaultClipsIntervalDays int // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. DefaultUpdatedAt func() time.Time // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. @@ -227,6 +245,26 @@ func ByApplyCategoriesToLive(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldApplyCategoriesToLive, opts...).ToFunc() } +// ByWatchClips orders the results by the watch_clips field. +func ByWatchClips(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldWatchClips, opts...).ToFunc() +} + +// ByClipsLimit orders the results by the clips_limit field. +func ByClipsLimit(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldClipsLimit, opts...).ToFunc() +} + +// ByClipsIntervalDays orders the results by the clips_interval_days field. +func ByClipsIntervalDays(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldClipsIntervalDays, opts...).ToFunc() +} + +// ByClipsLastChecked orders the results by the clips_last_checked field. +func ByClipsLastChecked(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldClipsLastChecked, opts...).ToFunc() +} + // ByUpdatedAt orders the results by the updated_at field. func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() diff --git a/ent/live/where.go b/ent/live/where.go index 887e620a..ec283913 100644 --- a/ent/live/where.go +++ b/ent/live/where.go @@ -121,6 +121,26 @@ func ApplyCategoriesToLive(v bool) predicate.Live { return predicate.Live(sql.FieldEQ(FieldApplyCategoriesToLive, v)) } +// WatchClips applies equality check predicate on the "watch_clips" field. It's identical to WatchClipsEQ. +func WatchClips(v bool) predicate.Live { + return predicate.Live(sql.FieldEQ(FieldWatchClips, v)) +} + +// ClipsLimit applies equality check predicate on the "clips_limit" field. It's identical to ClipsLimitEQ. +func ClipsLimit(v int) predicate.Live { + return predicate.Live(sql.FieldEQ(FieldClipsLimit, v)) +} + +// ClipsIntervalDays applies equality check predicate on the "clips_interval_days" field. It's identical to ClipsIntervalDaysEQ. +func ClipsIntervalDays(v int) predicate.Live { + return predicate.Live(sql.FieldEQ(FieldClipsIntervalDays, v)) +} + +// ClipsLastChecked applies equality check predicate on the "clips_last_checked" field. It's identical to ClipsLastCheckedEQ. +func ClipsLastChecked(v time.Time) predicate.Live { + return predicate.Live(sql.FieldEQ(FieldClipsLastChecked, v)) +} + // UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. func UpdatedAt(v time.Time) predicate.Live { return predicate.Live(sql.FieldEQ(FieldUpdatedAt, v)) @@ -386,6 +406,146 @@ func ApplyCategoriesToLiveNEQ(v bool) predicate.Live { return predicate.Live(sql.FieldNEQ(FieldApplyCategoriesToLive, v)) } +// WatchClipsEQ applies the EQ predicate on the "watch_clips" field. +func WatchClipsEQ(v bool) predicate.Live { + return predicate.Live(sql.FieldEQ(FieldWatchClips, v)) +} + +// WatchClipsNEQ applies the NEQ predicate on the "watch_clips" field. +func WatchClipsNEQ(v bool) predicate.Live { + return predicate.Live(sql.FieldNEQ(FieldWatchClips, v)) +} + +// ClipsLimitEQ applies the EQ predicate on the "clips_limit" field. +func ClipsLimitEQ(v int) predicate.Live { + return predicate.Live(sql.FieldEQ(FieldClipsLimit, v)) +} + +// ClipsLimitNEQ applies the NEQ predicate on the "clips_limit" field. +func ClipsLimitNEQ(v int) predicate.Live { + return predicate.Live(sql.FieldNEQ(FieldClipsLimit, v)) +} + +// ClipsLimitIn applies the In predicate on the "clips_limit" field. +func ClipsLimitIn(vs ...int) predicate.Live { + return predicate.Live(sql.FieldIn(FieldClipsLimit, vs...)) +} + +// ClipsLimitNotIn applies the NotIn predicate on the "clips_limit" field. +func ClipsLimitNotIn(vs ...int) predicate.Live { + return predicate.Live(sql.FieldNotIn(FieldClipsLimit, vs...)) +} + +// ClipsLimitGT applies the GT predicate on the "clips_limit" field. +func ClipsLimitGT(v int) predicate.Live { + return predicate.Live(sql.FieldGT(FieldClipsLimit, v)) +} + +// ClipsLimitGTE applies the GTE predicate on the "clips_limit" field. +func ClipsLimitGTE(v int) predicate.Live { + return predicate.Live(sql.FieldGTE(FieldClipsLimit, v)) +} + +// ClipsLimitLT applies the LT predicate on the "clips_limit" field. +func ClipsLimitLT(v int) predicate.Live { + return predicate.Live(sql.FieldLT(FieldClipsLimit, v)) +} + +// ClipsLimitLTE applies the LTE predicate on the "clips_limit" field. +func ClipsLimitLTE(v int) predicate.Live { + return predicate.Live(sql.FieldLTE(FieldClipsLimit, v)) +} + +// ClipsIntervalDaysEQ applies the EQ predicate on the "clips_interval_days" field. +func ClipsIntervalDaysEQ(v int) predicate.Live { + return predicate.Live(sql.FieldEQ(FieldClipsIntervalDays, v)) +} + +// ClipsIntervalDaysNEQ applies the NEQ predicate on the "clips_interval_days" field. +func ClipsIntervalDaysNEQ(v int) predicate.Live { + return predicate.Live(sql.FieldNEQ(FieldClipsIntervalDays, v)) +} + +// ClipsIntervalDaysIn applies the In predicate on the "clips_interval_days" field. +func ClipsIntervalDaysIn(vs ...int) predicate.Live { + return predicate.Live(sql.FieldIn(FieldClipsIntervalDays, vs...)) +} + +// ClipsIntervalDaysNotIn applies the NotIn predicate on the "clips_interval_days" field. +func ClipsIntervalDaysNotIn(vs ...int) predicate.Live { + return predicate.Live(sql.FieldNotIn(FieldClipsIntervalDays, vs...)) +} + +// ClipsIntervalDaysGT applies the GT predicate on the "clips_interval_days" field. +func ClipsIntervalDaysGT(v int) predicate.Live { + return predicate.Live(sql.FieldGT(FieldClipsIntervalDays, v)) +} + +// ClipsIntervalDaysGTE applies the GTE predicate on the "clips_interval_days" field. +func ClipsIntervalDaysGTE(v int) predicate.Live { + return predicate.Live(sql.FieldGTE(FieldClipsIntervalDays, v)) +} + +// ClipsIntervalDaysLT applies the LT predicate on the "clips_interval_days" field. +func ClipsIntervalDaysLT(v int) predicate.Live { + return predicate.Live(sql.FieldLT(FieldClipsIntervalDays, v)) +} + +// ClipsIntervalDaysLTE applies the LTE predicate on the "clips_interval_days" field. +func ClipsIntervalDaysLTE(v int) predicate.Live { + return predicate.Live(sql.FieldLTE(FieldClipsIntervalDays, v)) +} + +// ClipsLastCheckedEQ applies the EQ predicate on the "clips_last_checked" field. +func ClipsLastCheckedEQ(v time.Time) predicate.Live { + return predicate.Live(sql.FieldEQ(FieldClipsLastChecked, v)) +} + +// ClipsLastCheckedNEQ applies the NEQ predicate on the "clips_last_checked" field. +func ClipsLastCheckedNEQ(v time.Time) predicate.Live { + return predicate.Live(sql.FieldNEQ(FieldClipsLastChecked, v)) +} + +// ClipsLastCheckedIn applies the In predicate on the "clips_last_checked" field. +func ClipsLastCheckedIn(vs ...time.Time) predicate.Live { + return predicate.Live(sql.FieldIn(FieldClipsLastChecked, vs...)) +} + +// ClipsLastCheckedNotIn applies the NotIn predicate on the "clips_last_checked" field. +func ClipsLastCheckedNotIn(vs ...time.Time) predicate.Live { + return predicate.Live(sql.FieldNotIn(FieldClipsLastChecked, vs...)) +} + +// ClipsLastCheckedGT applies the GT predicate on the "clips_last_checked" field. +func ClipsLastCheckedGT(v time.Time) predicate.Live { + return predicate.Live(sql.FieldGT(FieldClipsLastChecked, v)) +} + +// ClipsLastCheckedGTE applies the GTE predicate on the "clips_last_checked" field. +func ClipsLastCheckedGTE(v time.Time) predicate.Live { + return predicate.Live(sql.FieldGTE(FieldClipsLastChecked, v)) +} + +// ClipsLastCheckedLT applies the LT predicate on the "clips_last_checked" field. +func ClipsLastCheckedLT(v time.Time) predicate.Live { + return predicate.Live(sql.FieldLT(FieldClipsLastChecked, v)) +} + +// ClipsLastCheckedLTE applies the LTE predicate on the "clips_last_checked" field. +func ClipsLastCheckedLTE(v time.Time) predicate.Live { + return predicate.Live(sql.FieldLTE(FieldClipsLastChecked, v)) +} + +// ClipsLastCheckedIsNil applies the IsNil predicate on the "clips_last_checked" field. +func ClipsLastCheckedIsNil() predicate.Live { + return predicate.Live(sql.FieldIsNull(FieldClipsLastChecked)) +} + +// ClipsLastCheckedNotNil applies the NotNil predicate on the "clips_last_checked" field. +func ClipsLastCheckedNotNil() predicate.Live { + return predicate.Live(sql.FieldNotNull(FieldClipsLastChecked)) +} + // UpdatedAtEQ applies the EQ predicate on the "updated_at" field. func UpdatedAtEQ(v time.Time) predicate.Live { return predicate.Live(sql.FieldEQ(FieldUpdatedAt, v)) diff --git a/ent/live_create.go b/ent/live_create.go index d91cc48a..0c5a39a5 100644 --- a/ent/live_create.go +++ b/ent/live_create.go @@ -209,6 +209,62 @@ func (lc *LiveCreate) SetNillableApplyCategoriesToLive(b *bool) *LiveCreate { return lc } +// SetWatchClips sets the "watch_clips" field. +func (lc *LiveCreate) SetWatchClips(b bool) *LiveCreate { + lc.mutation.SetWatchClips(b) + return lc +} + +// SetNillableWatchClips sets the "watch_clips" field if the given value is not nil. +func (lc *LiveCreate) SetNillableWatchClips(b *bool) *LiveCreate { + if b != nil { + lc.SetWatchClips(*b) + } + return lc +} + +// SetClipsLimit sets the "clips_limit" field. +func (lc *LiveCreate) SetClipsLimit(i int) *LiveCreate { + lc.mutation.SetClipsLimit(i) + return lc +} + +// SetNillableClipsLimit sets the "clips_limit" field if the given value is not nil. +func (lc *LiveCreate) SetNillableClipsLimit(i *int) *LiveCreate { + if i != nil { + lc.SetClipsLimit(*i) + } + return lc +} + +// SetClipsIntervalDays sets the "clips_interval_days" field. +func (lc *LiveCreate) SetClipsIntervalDays(i int) *LiveCreate { + lc.mutation.SetClipsIntervalDays(i) + return lc +} + +// SetNillableClipsIntervalDays sets the "clips_interval_days" field if the given value is not nil. +func (lc *LiveCreate) SetNillableClipsIntervalDays(i *int) *LiveCreate { + if i != nil { + lc.SetClipsIntervalDays(*i) + } + return lc +} + +// SetClipsLastChecked sets the "clips_last_checked" field. +func (lc *LiveCreate) SetClipsLastChecked(t time.Time) *LiveCreate { + lc.mutation.SetClipsLastChecked(t) + return lc +} + +// SetNillableClipsLastChecked sets the "clips_last_checked" field if the given value is not nil. +func (lc *LiveCreate) SetNillableClipsLastChecked(t *time.Time) *LiveCreate { + if t != nil { + lc.SetClipsLastChecked(*t) + } + return lc +} + // SetUpdatedAt sets the "updated_at" field. func (lc *LiveCreate) SetUpdatedAt(t time.Time) *LiveCreate { lc.mutation.SetUpdatedAt(t) @@ -379,6 +435,18 @@ func (lc *LiveCreate) defaults() { v := live.DefaultApplyCategoriesToLive lc.mutation.SetApplyCategoriesToLive(v) } + if _, ok := lc.mutation.WatchClips(); !ok { + v := live.DefaultWatchClips + lc.mutation.SetWatchClips(v) + } + if _, ok := lc.mutation.ClipsLimit(); !ok { + v := live.DefaultClipsLimit + lc.mutation.SetClipsLimit(v) + } + if _, ok := lc.mutation.ClipsIntervalDays(); !ok { + v := live.DefaultClipsIntervalDays + lc.mutation.SetClipsIntervalDays(v) + } if _, ok := lc.mutation.UpdatedAt(); !ok { v := live.DefaultUpdatedAt() lc.mutation.SetUpdatedAt(v) @@ -431,6 +499,15 @@ func (lc *LiveCreate) check() error { if _, ok := lc.mutation.ApplyCategoriesToLive(); !ok { return &ValidationError{Name: "apply_categories_to_live", err: errors.New(`ent: missing required field "Live.apply_categories_to_live"`)} } + if _, ok := lc.mutation.WatchClips(); !ok { + return &ValidationError{Name: "watch_clips", err: errors.New(`ent: missing required field "Live.watch_clips"`)} + } + if _, ok := lc.mutation.ClipsLimit(); !ok { + return &ValidationError{Name: "clips_limit", err: errors.New(`ent: missing required field "Live.clips_limit"`)} + } + if _, ok := lc.mutation.ClipsIntervalDays(); !ok { + return &ValidationError{Name: "clips_interval_days", err: errors.New(`ent: missing required field "Live.clips_interval_days"`)} + } if _, ok := lc.mutation.UpdatedAt(); !ok { return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Live.updated_at"`)} } @@ -528,6 +605,22 @@ func (lc *LiveCreate) createSpec() (*Live, *sqlgraph.CreateSpec) { _spec.SetField(live.FieldApplyCategoriesToLive, field.TypeBool, value) _node.ApplyCategoriesToLive = value } + if value, ok := lc.mutation.WatchClips(); ok { + _spec.SetField(live.FieldWatchClips, field.TypeBool, value) + _node.WatchClips = value + } + if value, ok := lc.mutation.ClipsLimit(); ok { + _spec.SetField(live.FieldClipsLimit, field.TypeInt, value) + _node.ClipsLimit = value + } + if value, ok := lc.mutation.ClipsIntervalDays(); ok { + _spec.SetField(live.FieldClipsIntervalDays, field.TypeInt, value) + _node.ClipsIntervalDays = value + } + if value, ok := lc.mutation.ClipsLastChecked(); ok { + _spec.SetField(live.FieldClipsLastChecked, field.TypeTime, value) + _node.ClipsLastChecked = value + } if value, ok := lc.mutation.UpdatedAt(); ok { _spec.SetField(live.FieldUpdatedAt, field.TypeTime, value) _node.UpdatedAt = value @@ -805,6 +898,72 @@ func (u *LiveUpsert) UpdateApplyCategoriesToLive() *LiveUpsert { return u } +// SetWatchClips sets the "watch_clips" field. +func (u *LiveUpsert) SetWatchClips(v bool) *LiveUpsert { + u.Set(live.FieldWatchClips, v) + return u +} + +// UpdateWatchClips sets the "watch_clips" field to the value that was provided on create. +func (u *LiveUpsert) UpdateWatchClips() *LiveUpsert { + u.SetExcluded(live.FieldWatchClips) + return u +} + +// SetClipsLimit sets the "clips_limit" field. +func (u *LiveUpsert) SetClipsLimit(v int) *LiveUpsert { + u.Set(live.FieldClipsLimit, v) + return u +} + +// UpdateClipsLimit sets the "clips_limit" field to the value that was provided on create. +func (u *LiveUpsert) UpdateClipsLimit() *LiveUpsert { + u.SetExcluded(live.FieldClipsLimit) + return u +} + +// AddClipsLimit adds v to the "clips_limit" field. +func (u *LiveUpsert) AddClipsLimit(v int) *LiveUpsert { + u.Add(live.FieldClipsLimit, v) + return u +} + +// SetClipsIntervalDays sets the "clips_interval_days" field. +func (u *LiveUpsert) SetClipsIntervalDays(v int) *LiveUpsert { + u.Set(live.FieldClipsIntervalDays, v) + return u +} + +// UpdateClipsIntervalDays sets the "clips_interval_days" field to the value that was provided on create. +func (u *LiveUpsert) UpdateClipsIntervalDays() *LiveUpsert { + u.SetExcluded(live.FieldClipsIntervalDays) + return u +} + +// AddClipsIntervalDays adds v to the "clips_interval_days" field. +func (u *LiveUpsert) AddClipsIntervalDays(v int) *LiveUpsert { + u.Add(live.FieldClipsIntervalDays, v) + return u +} + +// SetClipsLastChecked sets the "clips_last_checked" field. +func (u *LiveUpsert) SetClipsLastChecked(v time.Time) *LiveUpsert { + u.Set(live.FieldClipsLastChecked, v) + return u +} + +// UpdateClipsLastChecked sets the "clips_last_checked" field to the value that was provided on create. +func (u *LiveUpsert) UpdateClipsLastChecked() *LiveUpsert { + u.SetExcluded(live.FieldClipsLastChecked) + return u +} + +// ClearClipsLastChecked clears the value of the "clips_last_checked" field. +func (u *LiveUpsert) ClearClipsLastChecked() *LiveUpsert { + u.SetNull(live.FieldClipsLastChecked) + return u +} + // SetUpdatedAt sets the "updated_at" field. func (u *LiveUpsert) SetUpdatedAt(v time.Time) *LiveUpsert { u.Set(live.FieldUpdatedAt, v) @@ -1064,6 +1223,83 @@ func (u *LiveUpsertOne) UpdateApplyCategoriesToLive() *LiveUpsertOne { }) } +// SetWatchClips sets the "watch_clips" field. +func (u *LiveUpsertOne) SetWatchClips(v bool) *LiveUpsertOne { + return u.Update(func(s *LiveUpsert) { + s.SetWatchClips(v) + }) +} + +// UpdateWatchClips sets the "watch_clips" field to the value that was provided on create. +func (u *LiveUpsertOne) UpdateWatchClips() *LiveUpsertOne { + return u.Update(func(s *LiveUpsert) { + s.UpdateWatchClips() + }) +} + +// SetClipsLimit sets the "clips_limit" field. +func (u *LiveUpsertOne) SetClipsLimit(v int) *LiveUpsertOne { + return u.Update(func(s *LiveUpsert) { + s.SetClipsLimit(v) + }) +} + +// AddClipsLimit adds v to the "clips_limit" field. +func (u *LiveUpsertOne) AddClipsLimit(v int) *LiveUpsertOne { + return u.Update(func(s *LiveUpsert) { + s.AddClipsLimit(v) + }) +} + +// UpdateClipsLimit sets the "clips_limit" field to the value that was provided on create. +func (u *LiveUpsertOne) UpdateClipsLimit() *LiveUpsertOne { + return u.Update(func(s *LiveUpsert) { + s.UpdateClipsLimit() + }) +} + +// SetClipsIntervalDays sets the "clips_interval_days" field. +func (u *LiveUpsertOne) SetClipsIntervalDays(v int) *LiveUpsertOne { + return u.Update(func(s *LiveUpsert) { + s.SetClipsIntervalDays(v) + }) +} + +// AddClipsIntervalDays adds v to the "clips_interval_days" field. +func (u *LiveUpsertOne) AddClipsIntervalDays(v int) *LiveUpsertOne { + return u.Update(func(s *LiveUpsert) { + s.AddClipsIntervalDays(v) + }) +} + +// UpdateClipsIntervalDays sets the "clips_interval_days" field to the value that was provided on create. +func (u *LiveUpsertOne) UpdateClipsIntervalDays() *LiveUpsertOne { + return u.Update(func(s *LiveUpsert) { + s.UpdateClipsIntervalDays() + }) +} + +// SetClipsLastChecked sets the "clips_last_checked" field. +func (u *LiveUpsertOne) SetClipsLastChecked(v time.Time) *LiveUpsertOne { + return u.Update(func(s *LiveUpsert) { + s.SetClipsLastChecked(v) + }) +} + +// UpdateClipsLastChecked sets the "clips_last_checked" field to the value that was provided on create. +func (u *LiveUpsertOne) UpdateClipsLastChecked() *LiveUpsertOne { + return u.Update(func(s *LiveUpsert) { + s.UpdateClipsLastChecked() + }) +} + +// ClearClipsLastChecked clears the value of the "clips_last_checked" field. +func (u *LiveUpsertOne) ClearClipsLastChecked() *LiveUpsertOne { + return u.Update(func(s *LiveUpsert) { + s.ClearClipsLastChecked() + }) +} + // SetUpdatedAt sets the "updated_at" field. func (u *LiveUpsertOne) SetUpdatedAt(v time.Time) *LiveUpsertOne { return u.Update(func(s *LiveUpsert) { @@ -1492,6 +1728,83 @@ func (u *LiveUpsertBulk) UpdateApplyCategoriesToLive() *LiveUpsertBulk { }) } +// SetWatchClips sets the "watch_clips" field. +func (u *LiveUpsertBulk) SetWatchClips(v bool) *LiveUpsertBulk { + return u.Update(func(s *LiveUpsert) { + s.SetWatchClips(v) + }) +} + +// UpdateWatchClips sets the "watch_clips" field to the value that was provided on create. +func (u *LiveUpsertBulk) UpdateWatchClips() *LiveUpsertBulk { + return u.Update(func(s *LiveUpsert) { + s.UpdateWatchClips() + }) +} + +// SetClipsLimit sets the "clips_limit" field. +func (u *LiveUpsertBulk) SetClipsLimit(v int) *LiveUpsertBulk { + return u.Update(func(s *LiveUpsert) { + s.SetClipsLimit(v) + }) +} + +// AddClipsLimit adds v to the "clips_limit" field. +func (u *LiveUpsertBulk) AddClipsLimit(v int) *LiveUpsertBulk { + return u.Update(func(s *LiveUpsert) { + s.AddClipsLimit(v) + }) +} + +// UpdateClipsLimit sets the "clips_limit" field to the value that was provided on create. +func (u *LiveUpsertBulk) UpdateClipsLimit() *LiveUpsertBulk { + return u.Update(func(s *LiveUpsert) { + s.UpdateClipsLimit() + }) +} + +// SetClipsIntervalDays sets the "clips_interval_days" field. +func (u *LiveUpsertBulk) SetClipsIntervalDays(v int) *LiveUpsertBulk { + return u.Update(func(s *LiveUpsert) { + s.SetClipsIntervalDays(v) + }) +} + +// AddClipsIntervalDays adds v to the "clips_interval_days" field. +func (u *LiveUpsertBulk) AddClipsIntervalDays(v int) *LiveUpsertBulk { + return u.Update(func(s *LiveUpsert) { + s.AddClipsIntervalDays(v) + }) +} + +// UpdateClipsIntervalDays sets the "clips_interval_days" field to the value that was provided on create. +func (u *LiveUpsertBulk) UpdateClipsIntervalDays() *LiveUpsertBulk { + return u.Update(func(s *LiveUpsert) { + s.UpdateClipsIntervalDays() + }) +} + +// SetClipsLastChecked sets the "clips_last_checked" field. +func (u *LiveUpsertBulk) SetClipsLastChecked(v time.Time) *LiveUpsertBulk { + return u.Update(func(s *LiveUpsert) { + s.SetClipsLastChecked(v) + }) +} + +// UpdateClipsLastChecked sets the "clips_last_checked" field to the value that was provided on create. +func (u *LiveUpsertBulk) UpdateClipsLastChecked() *LiveUpsertBulk { + return u.Update(func(s *LiveUpsert) { + s.UpdateClipsLastChecked() + }) +} + +// ClearClipsLastChecked clears the value of the "clips_last_checked" field. +func (u *LiveUpsertBulk) ClearClipsLastChecked() *LiveUpsertBulk { + return u.Update(func(s *LiveUpsert) { + s.ClearClipsLastChecked() + }) +} + // SetUpdatedAt sets the "updated_at" field. func (u *LiveUpsertBulk) SetUpdatedAt(v time.Time) *LiveUpsertBulk { return u.Update(func(s *LiveUpsert) { diff --git a/ent/live_query.go b/ent/live_query.go index 8e66e2cf..8173651c 100644 --- a/ent/live_query.go +++ b/ent/live_query.go @@ -372,7 +372,7 @@ func (lq *LiveQuery) WithTitleRegex(opts ...func(*LiveTitleRegexQuery)) *LiveQue // Example: // // var v []struct { -// WatchLive bool `json:"watch_live,omitempty"` +// WatchLive bool `json:"watch_live"` // Count int `json:"count,omitempty"` // } // @@ -395,7 +395,7 @@ func (lq *LiveQuery) GroupBy(field string, fields ...string) *LiveGroupBy { // Example: // // var v []struct { -// WatchLive bool `json:"watch_live,omitempty"` +// WatchLive bool `json:"watch_live"` // } // // client.Live.Query(). diff --git a/ent/live_update.go b/ent/live_update.go index d58af1cf..7caf38fe 100644 --- a/ent/live_update.go +++ b/ent/live_update.go @@ -227,6 +227,82 @@ func (lu *LiveUpdate) SetNillableApplyCategoriesToLive(b *bool) *LiveUpdate { return lu } +// SetWatchClips sets the "watch_clips" field. +func (lu *LiveUpdate) SetWatchClips(b bool) *LiveUpdate { + lu.mutation.SetWatchClips(b) + return lu +} + +// SetNillableWatchClips sets the "watch_clips" field if the given value is not nil. +func (lu *LiveUpdate) SetNillableWatchClips(b *bool) *LiveUpdate { + if b != nil { + lu.SetWatchClips(*b) + } + return lu +} + +// SetClipsLimit sets the "clips_limit" field. +func (lu *LiveUpdate) SetClipsLimit(i int) *LiveUpdate { + lu.mutation.ResetClipsLimit() + lu.mutation.SetClipsLimit(i) + return lu +} + +// SetNillableClipsLimit sets the "clips_limit" field if the given value is not nil. +func (lu *LiveUpdate) SetNillableClipsLimit(i *int) *LiveUpdate { + if i != nil { + lu.SetClipsLimit(*i) + } + return lu +} + +// AddClipsLimit adds i to the "clips_limit" field. +func (lu *LiveUpdate) AddClipsLimit(i int) *LiveUpdate { + lu.mutation.AddClipsLimit(i) + return lu +} + +// SetClipsIntervalDays sets the "clips_interval_days" field. +func (lu *LiveUpdate) SetClipsIntervalDays(i int) *LiveUpdate { + lu.mutation.ResetClipsIntervalDays() + lu.mutation.SetClipsIntervalDays(i) + return lu +} + +// SetNillableClipsIntervalDays sets the "clips_interval_days" field if the given value is not nil. +func (lu *LiveUpdate) SetNillableClipsIntervalDays(i *int) *LiveUpdate { + if i != nil { + lu.SetClipsIntervalDays(*i) + } + return lu +} + +// AddClipsIntervalDays adds i to the "clips_interval_days" field. +func (lu *LiveUpdate) AddClipsIntervalDays(i int) *LiveUpdate { + lu.mutation.AddClipsIntervalDays(i) + return lu +} + +// SetClipsLastChecked sets the "clips_last_checked" field. +func (lu *LiveUpdate) SetClipsLastChecked(t time.Time) *LiveUpdate { + lu.mutation.SetClipsLastChecked(t) + return lu +} + +// SetNillableClipsLastChecked sets the "clips_last_checked" field if the given value is not nil. +func (lu *LiveUpdate) SetNillableClipsLastChecked(t *time.Time) *LiveUpdate { + if t != nil { + lu.SetClipsLastChecked(*t) + } + return lu +} + +// ClearClipsLastChecked clears the value of the "clips_last_checked" field. +func (lu *LiveUpdate) ClearClipsLastChecked() *LiveUpdate { + lu.mutation.ClearClipsLastChecked() + return lu +} + // SetUpdatedAt sets the "updated_at" field. func (lu *LiveUpdate) SetUpdatedAt(t time.Time) *LiveUpdate { lu.mutation.SetUpdatedAt(t) @@ -428,6 +504,27 @@ func (lu *LiveUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := lu.mutation.ApplyCategoriesToLive(); ok { _spec.SetField(live.FieldApplyCategoriesToLive, field.TypeBool, value) } + if value, ok := lu.mutation.WatchClips(); ok { + _spec.SetField(live.FieldWatchClips, field.TypeBool, value) + } + if value, ok := lu.mutation.ClipsLimit(); ok { + _spec.SetField(live.FieldClipsLimit, field.TypeInt, value) + } + if value, ok := lu.mutation.AddedClipsLimit(); ok { + _spec.AddField(live.FieldClipsLimit, field.TypeInt, value) + } + if value, ok := lu.mutation.ClipsIntervalDays(); ok { + _spec.SetField(live.FieldClipsIntervalDays, field.TypeInt, value) + } + if value, ok := lu.mutation.AddedClipsIntervalDays(); ok { + _spec.AddField(live.FieldClipsIntervalDays, field.TypeInt, value) + } + if value, ok := lu.mutation.ClipsLastChecked(); ok { + _spec.SetField(live.FieldClipsLastChecked, field.TypeTime, value) + } + if lu.mutation.ClipsLastCheckedCleared() { + _spec.ClearField(live.FieldClipsLastChecked, field.TypeTime) + } if value, ok := lu.mutation.UpdatedAt(); ok { _spec.SetField(live.FieldUpdatedAt, field.TypeTime, value) } @@ -765,6 +862,82 @@ func (luo *LiveUpdateOne) SetNillableApplyCategoriesToLive(b *bool) *LiveUpdateO return luo } +// SetWatchClips sets the "watch_clips" field. +func (luo *LiveUpdateOne) SetWatchClips(b bool) *LiveUpdateOne { + luo.mutation.SetWatchClips(b) + return luo +} + +// SetNillableWatchClips sets the "watch_clips" field if the given value is not nil. +func (luo *LiveUpdateOne) SetNillableWatchClips(b *bool) *LiveUpdateOne { + if b != nil { + luo.SetWatchClips(*b) + } + return luo +} + +// SetClipsLimit sets the "clips_limit" field. +func (luo *LiveUpdateOne) SetClipsLimit(i int) *LiveUpdateOne { + luo.mutation.ResetClipsLimit() + luo.mutation.SetClipsLimit(i) + return luo +} + +// SetNillableClipsLimit sets the "clips_limit" field if the given value is not nil. +func (luo *LiveUpdateOne) SetNillableClipsLimit(i *int) *LiveUpdateOne { + if i != nil { + luo.SetClipsLimit(*i) + } + return luo +} + +// AddClipsLimit adds i to the "clips_limit" field. +func (luo *LiveUpdateOne) AddClipsLimit(i int) *LiveUpdateOne { + luo.mutation.AddClipsLimit(i) + return luo +} + +// SetClipsIntervalDays sets the "clips_interval_days" field. +func (luo *LiveUpdateOne) SetClipsIntervalDays(i int) *LiveUpdateOne { + luo.mutation.ResetClipsIntervalDays() + luo.mutation.SetClipsIntervalDays(i) + return luo +} + +// SetNillableClipsIntervalDays sets the "clips_interval_days" field if the given value is not nil. +func (luo *LiveUpdateOne) SetNillableClipsIntervalDays(i *int) *LiveUpdateOne { + if i != nil { + luo.SetClipsIntervalDays(*i) + } + return luo +} + +// AddClipsIntervalDays adds i to the "clips_interval_days" field. +func (luo *LiveUpdateOne) AddClipsIntervalDays(i int) *LiveUpdateOne { + luo.mutation.AddClipsIntervalDays(i) + return luo +} + +// SetClipsLastChecked sets the "clips_last_checked" field. +func (luo *LiveUpdateOne) SetClipsLastChecked(t time.Time) *LiveUpdateOne { + luo.mutation.SetClipsLastChecked(t) + return luo +} + +// SetNillableClipsLastChecked sets the "clips_last_checked" field if the given value is not nil. +func (luo *LiveUpdateOne) SetNillableClipsLastChecked(t *time.Time) *LiveUpdateOne { + if t != nil { + luo.SetClipsLastChecked(*t) + } + return luo +} + +// ClearClipsLastChecked clears the value of the "clips_last_checked" field. +func (luo *LiveUpdateOne) ClearClipsLastChecked() *LiveUpdateOne { + luo.mutation.ClearClipsLastChecked() + return luo +} + // SetUpdatedAt sets the "updated_at" field. func (luo *LiveUpdateOne) SetUpdatedAt(t time.Time) *LiveUpdateOne { luo.mutation.SetUpdatedAt(t) @@ -996,6 +1169,27 @@ func (luo *LiveUpdateOne) sqlSave(ctx context.Context) (_node *Live, err error) if value, ok := luo.mutation.ApplyCategoriesToLive(); ok { _spec.SetField(live.FieldApplyCategoriesToLive, field.TypeBool, value) } + if value, ok := luo.mutation.WatchClips(); ok { + _spec.SetField(live.FieldWatchClips, field.TypeBool, value) + } + if value, ok := luo.mutation.ClipsLimit(); ok { + _spec.SetField(live.FieldClipsLimit, field.TypeInt, value) + } + if value, ok := luo.mutation.AddedClipsLimit(); ok { + _spec.AddField(live.FieldClipsLimit, field.TypeInt, value) + } + if value, ok := luo.mutation.ClipsIntervalDays(); ok { + _spec.SetField(live.FieldClipsIntervalDays, field.TypeInt, value) + } + if value, ok := luo.mutation.AddedClipsIntervalDays(); ok { + _spec.AddField(live.FieldClipsIntervalDays, field.TypeInt, value) + } + if value, ok := luo.mutation.ClipsLastChecked(); ok { + _spec.SetField(live.FieldClipsLastChecked, field.TypeTime, value) + } + if luo.mutation.ClipsLastCheckedCleared() { + _spec.ClearField(live.FieldClipsLastChecked, field.TypeTime) + } if value, ok := luo.mutation.UpdatedAt(); ok { _spec.SetField(live.FieldUpdatedAt, field.TypeTime, value) } diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index fc162561..0fc70aa5 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -76,6 +76,10 @@ var ( {Name: "render_chat", Type: field.TypeBool, Default: true}, {Name: "video_age", Type: field.TypeInt64, Default: 0}, {Name: "apply_categories_to_live", Type: field.TypeBool, Default: false}, + {Name: "watch_clips", Type: field.TypeBool, Default: false}, + {Name: "clips_limit", Type: field.TypeInt, Default: 0}, + {Name: "clips_interval_days", Type: field.TypeInt, Default: 0}, + {Name: "clips_last_checked", Type: field.TypeTime, Nullable: true}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_at", Type: field.TypeTime}, {Name: "channel_live", Type: field.TypeUUID}, @@ -88,7 +92,7 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "lives_channels_live", - Columns: []*schema.Column{LivesColumns[16]}, + Columns: []*schema.Column{LivesColumns[20]}, RefColumns: []*schema.Column{ChannelsColumns[0]}, OnDelete: schema.NoAction, }, @@ -256,6 +260,26 @@ var ( }, }, } + // SessionsColumns holds the columns for the "sessions" table. + SessionsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "token", Type: field.TypeString, Unique: true, Size: 2147483647}, + {Name: "data", Type: field.TypeBytes}, + {Name: "expiry", Type: field.TypeTime}, + } + // SessionsTable holds the schema information for the "sessions" table. + SessionsTable = &schema.Table{ + Name: "sessions", + Columns: SessionsColumns, + PrimaryKey: []*schema.Column{SessionsColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "sessions_expiry", + Unique: false, + Columns: []*schema.Column{SessionsColumns[3]}, + }, + }, + } // TwitchCategoriesColumns holds the columns for the "twitch_categories" table. TwitchCategoriesColumns = []*schema.Column{ {Name: "id", Type: field.TypeString}, @@ -293,11 +317,13 @@ var ( VodsColumns = []*schema.Column{ {Name: "id", Type: field.TypeUUID}, {Name: "ext_id", Type: field.TypeString}, + {Name: "clip_ext_vod_id", Type: field.TypeString, Nullable: true}, {Name: "ext_stream_id", Type: field.TypeString, Nullable: true}, {Name: "platform", Type: field.TypeEnum, Enums: []string{"twitch", "youtube"}, Default: "twitch"}, {Name: "type", Type: field.TypeEnum, Enums: []string{"archive", "live", "highlight", "upload", "clip"}, Default: "archive"}, {Name: "title", Type: field.TypeString}, {Name: "duration", Type: field.TypeInt, Default: 1}, + {Name: "clip_vod_offset", Type: field.TypeInt, Nullable: true}, {Name: "views", Type: field.TypeInt, Default: 1}, {Name: "resolution", Type: field.TypeString, Nullable: true}, {Name: "processing", Type: field.TypeBool, Default: false}, @@ -322,6 +348,13 @@ var ( {Name: "tmp_video_hls_path", Type: field.TypeString, Nullable: true}, {Name: "locked", Type: field.TypeBool, Default: false}, {Name: "local_views", Type: field.TypeInt, Default: 0}, + {Name: "sprite_thumbnails_enabled", Type: field.TypeBool, Default: false}, + {Name: "sprite_thumbnails_images", Type: field.TypeJSON, Nullable: true}, + {Name: "sprite_thumbnails_interval", Type: field.TypeInt, Nullable: true}, + {Name: "sprite_thumbnails_width", Type: field.TypeInt, Nullable: true}, + {Name: "sprite_thumbnails_height", Type: field.TypeInt, Nullable: true}, + {Name: "sprite_thumbnails_rows", Type: field.TypeInt, Nullable: true}, + {Name: "sprite_thumbnails_columns", Type: field.TypeInt, Nullable: true}, {Name: "streamed_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "created_at", Type: field.TypeTime}, @@ -335,7 +368,7 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "vods_channels_vods", - Columns: []*schema.Column{VodsColumns[34]}, + Columns: []*schema.Column{VodsColumns[43]}, RefColumns: []*schema.Column{ChannelsColumns[0]}, OnDelete: schema.NoAction, }, @@ -379,6 +412,7 @@ var ( PlaybacksTable, PlaylistsTable, QueuesTable, + SessionsTable, TwitchCategoriesTable, UsersTable, VodsTable, diff --git a/ent/mutation.go b/ent/mutation.go index caf5ea53..d478c747 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -24,6 +24,7 @@ import ( "github.com/zibbp/ganymede/ent/playlist" "github.com/zibbp/ganymede/ent/predicate" "github.com/zibbp/ganymede/ent/queue" + "github.com/zibbp/ganymede/ent/sessions" "github.com/zibbp/ganymede/ent/twitchcategory" "github.com/zibbp/ganymede/ent/user" "github.com/zibbp/ganymede/ent/vod" @@ -50,6 +51,7 @@ const ( TypePlayback = "Playback" TypePlaylist = "Playlist" TypeQueue = "Queue" + TypeSessions = "Sessions" TypeTwitchCategory = "TwitchCategory" TypeUser = "User" TypeVod = "Vod" @@ -2082,6 +2084,12 @@ type LiveMutation struct { video_age *int64 addvideo_age *int64 apply_categories_to_live *bool + watch_clips *bool + clips_limit *int + addclips_limit *int + clips_interval_days *int + addclips_interval_days *int + clips_last_checked *time.Time updated_at *time.Time created_at *time.Time clearedFields map[string]struct{} @@ -2703,6 +2711,203 @@ func (m *LiveMutation) ResetApplyCategoriesToLive() { m.apply_categories_to_live = nil } +// SetWatchClips sets the "watch_clips" field. +func (m *LiveMutation) SetWatchClips(b bool) { + m.watch_clips = &b +} + +// WatchClips returns the value of the "watch_clips" field in the mutation. +func (m *LiveMutation) WatchClips() (r bool, exists bool) { + v := m.watch_clips + if v == nil { + return + } + return *v, true +} + +// OldWatchClips returns the old "watch_clips" field's value of the Live entity. +// If the Live object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LiveMutation) OldWatchClips(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldWatchClips is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldWatchClips requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWatchClips: %w", err) + } + return oldValue.WatchClips, nil +} + +// ResetWatchClips resets all changes to the "watch_clips" field. +func (m *LiveMutation) ResetWatchClips() { + m.watch_clips = nil +} + +// SetClipsLimit sets the "clips_limit" field. +func (m *LiveMutation) SetClipsLimit(i int) { + m.clips_limit = &i + m.addclips_limit = nil +} + +// ClipsLimit returns the value of the "clips_limit" field in the mutation. +func (m *LiveMutation) ClipsLimit() (r int, exists bool) { + v := m.clips_limit + if v == nil { + return + } + return *v, true +} + +// OldClipsLimit returns the old "clips_limit" field's value of the Live entity. +// If the Live object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LiveMutation) OldClipsLimit(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldClipsLimit is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldClipsLimit requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldClipsLimit: %w", err) + } + return oldValue.ClipsLimit, nil +} + +// AddClipsLimit adds i to the "clips_limit" field. +func (m *LiveMutation) AddClipsLimit(i int) { + if m.addclips_limit != nil { + *m.addclips_limit += i + } else { + m.addclips_limit = &i + } +} + +// AddedClipsLimit returns the value that was added to the "clips_limit" field in this mutation. +func (m *LiveMutation) AddedClipsLimit() (r int, exists bool) { + v := m.addclips_limit + if v == nil { + return + } + return *v, true +} + +// ResetClipsLimit resets all changes to the "clips_limit" field. +func (m *LiveMutation) ResetClipsLimit() { + m.clips_limit = nil + m.addclips_limit = nil +} + +// SetClipsIntervalDays sets the "clips_interval_days" field. +func (m *LiveMutation) SetClipsIntervalDays(i int) { + m.clips_interval_days = &i + m.addclips_interval_days = nil +} + +// ClipsIntervalDays returns the value of the "clips_interval_days" field in the mutation. +func (m *LiveMutation) ClipsIntervalDays() (r int, exists bool) { + v := m.clips_interval_days + if v == nil { + return + } + return *v, true +} + +// OldClipsIntervalDays returns the old "clips_interval_days" field's value of the Live entity. +// If the Live object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LiveMutation) OldClipsIntervalDays(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldClipsIntervalDays is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldClipsIntervalDays requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldClipsIntervalDays: %w", err) + } + return oldValue.ClipsIntervalDays, nil +} + +// AddClipsIntervalDays adds i to the "clips_interval_days" field. +func (m *LiveMutation) AddClipsIntervalDays(i int) { + if m.addclips_interval_days != nil { + *m.addclips_interval_days += i + } else { + m.addclips_interval_days = &i + } +} + +// AddedClipsIntervalDays returns the value that was added to the "clips_interval_days" field in this mutation. +func (m *LiveMutation) AddedClipsIntervalDays() (r int, exists bool) { + v := m.addclips_interval_days + if v == nil { + return + } + return *v, true +} + +// ResetClipsIntervalDays resets all changes to the "clips_interval_days" field. +func (m *LiveMutation) ResetClipsIntervalDays() { + m.clips_interval_days = nil + m.addclips_interval_days = nil +} + +// SetClipsLastChecked sets the "clips_last_checked" field. +func (m *LiveMutation) SetClipsLastChecked(t time.Time) { + m.clips_last_checked = &t +} + +// ClipsLastChecked returns the value of the "clips_last_checked" field in the mutation. +func (m *LiveMutation) ClipsLastChecked() (r time.Time, exists bool) { + v := m.clips_last_checked + if v == nil { + return + } + return *v, true +} + +// OldClipsLastChecked returns the old "clips_last_checked" field's value of the Live entity. +// If the Live object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LiveMutation) OldClipsLastChecked(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldClipsLastChecked is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldClipsLastChecked requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldClipsLastChecked: %w", err) + } + return oldValue.ClipsLastChecked, nil +} + +// ClearClipsLastChecked clears the value of the "clips_last_checked" field. +func (m *LiveMutation) ClearClipsLastChecked() { + m.clips_last_checked = nil + m.clearedFields[live.FieldClipsLastChecked] = struct{}{} +} + +// ClipsLastCheckedCleared returns if the "clips_last_checked" field was cleared in this mutation. +func (m *LiveMutation) ClipsLastCheckedCleared() bool { + _, ok := m.clearedFields[live.FieldClipsLastChecked] + return ok +} + +// ResetClipsLastChecked resets all changes to the "clips_last_checked" field. +func (m *LiveMutation) ResetClipsLastChecked() { + m.clips_last_checked = nil + delete(m.clearedFields, live.FieldClipsLastChecked) +} + // SetUpdatedAt sets the "updated_at" field. func (m *LiveMutation) SetUpdatedAt(t time.Time) { m.updated_at = &t @@ -2956,7 +3161,7 @@ func (m *LiveMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *LiveMutation) Fields() []string { - fields := make([]string, 0, 15) + fields := make([]string, 0, 19) if m.watch_live != nil { fields = append(fields, live.FieldWatchLive) } @@ -2996,6 +3201,18 @@ func (m *LiveMutation) Fields() []string { if m.apply_categories_to_live != nil { fields = append(fields, live.FieldApplyCategoriesToLive) } + if m.watch_clips != nil { + fields = append(fields, live.FieldWatchClips) + } + if m.clips_limit != nil { + fields = append(fields, live.FieldClipsLimit) + } + if m.clips_interval_days != nil { + fields = append(fields, live.FieldClipsIntervalDays) + } + if m.clips_last_checked != nil { + fields = append(fields, live.FieldClipsLastChecked) + } if m.updated_at != nil { fields = append(fields, live.FieldUpdatedAt) } @@ -3036,6 +3253,14 @@ func (m *LiveMutation) Field(name string) (ent.Value, bool) { return m.VideoAge() case live.FieldApplyCategoriesToLive: return m.ApplyCategoriesToLive() + case live.FieldWatchClips: + return m.WatchClips() + case live.FieldClipsLimit: + return m.ClipsLimit() + case live.FieldClipsIntervalDays: + return m.ClipsIntervalDays() + case live.FieldClipsLastChecked: + return m.ClipsLastChecked() case live.FieldUpdatedAt: return m.UpdatedAt() case live.FieldCreatedAt: @@ -3075,6 +3300,14 @@ func (m *LiveMutation) OldField(ctx context.Context, name string) (ent.Value, er return m.OldVideoAge(ctx) case live.FieldApplyCategoriesToLive: return m.OldApplyCategoriesToLive(ctx) + case live.FieldWatchClips: + return m.OldWatchClips(ctx) + case live.FieldClipsLimit: + return m.OldClipsLimit(ctx) + case live.FieldClipsIntervalDays: + return m.OldClipsIntervalDays(ctx) + case live.FieldClipsLastChecked: + return m.OldClipsLastChecked(ctx) case live.FieldUpdatedAt: return m.OldUpdatedAt(ctx) case live.FieldCreatedAt: @@ -3179,6 +3412,34 @@ func (m *LiveMutation) SetField(name string, value ent.Value) error { } m.SetApplyCategoriesToLive(v) return nil + case live.FieldWatchClips: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetWatchClips(v) + return nil + case live.FieldClipsLimit: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetClipsLimit(v) + return nil + case live.FieldClipsIntervalDays: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetClipsIntervalDays(v) + return nil + case live.FieldClipsLastChecked: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetClipsLastChecked(v) + return nil case live.FieldUpdatedAt: v, ok := value.(time.Time) if !ok { @@ -3204,6 +3465,12 @@ func (m *LiveMutation) AddedFields() []string { if m.addvideo_age != nil { fields = append(fields, live.FieldVideoAge) } + if m.addclips_limit != nil { + fields = append(fields, live.FieldClipsLimit) + } + if m.addclips_interval_days != nil { + fields = append(fields, live.FieldClipsIntervalDays) + } return fields } @@ -3214,6 +3481,10 @@ func (m *LiveMutation) AddedField(name string) (ent.Value, bool) { switch name { case live.FieldVideoAge: return m.AddedVideoAge() + case live.FieldClipsLimit: + return m.AddedClipsLimit() + case live.FieldClipsIntervalDays: + return m.AddedClipsIntervalDays() } return nil, false } @@ -3230,6 +3501,20 @@ func (m *LiveMutation) AddField(name string, value ent.Value) error { } m.AddVideoAge(v) return nil + case live.FieldClipsLimit: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddClipsLimit(v) + return nil + case live.FieldClipsIntervalDays: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddClipsIntervalDays(v) + return nil } return fmt.Errorf("unknown Live numeric field %s", name) } @@ -3241,6 +3526,9 @@ func (m *LiveMutation) ClearedFields() []string { if m.FieldCleared(live.FieldResolution) { fields = append(fields, live.FieldResolution) } + if m.FieldCleared(live.FieldClipsLastChecked) { + fields = append(fields, live.FieldClipsLastChecked) + } return fields } @@ -3258,6 +3546,9 @@ func (m *LiveMutation) ClearField(name string) error { case live.FieldResolution: m.ClearResolution() return nil + case live.FieldClipsLastChecked: + m.ClearClipsLastChecked() + return nil } return fmt.Errorf("unknown Live nullable field %s", name) } @@ -3305,6 +3596,18 @@ func (m *LiveMutation) ResetField(name string) error { case live.FieldApplyCategoriesToLive: m.ResetApplyCategoriesToLive() return nil + case live.FieldWatchClips: + m.ResetWatchClips() + return nil + case live.FieldClipsLimit: + m.ResetClipsLimit() + return nil + case live.FieldClipsIntervalDays: + m.ResetClipsIntervalDays() + return nil + case live.FieldClipsLastChecked: + m.ResetClipsLastChecked() + return nil case live.FieldUpdatedAt: m.ResetUpdatedAt() return nil @@ -8628,34 +8931,32 @@ func (m *QueueMutation) ResetEdge(name string) error { return fmt.Errorf("unknown Queue edge %s", name) } -// TwitchCategoryMutation represents an operation that mutates the TwitchCategory nodes in the graph. -type TwitchCategoryMutation struct { +// SessionsMutation represents an operation that mutates the Sessions nodes in the graph. +type SessionsMutation struct { config op Op typ string - id *string - name *string - box_art_url *string - igdb_id *string - updated_at *time.Time - created_at *time.Time + id *int + token *string + data *[]byte + expiry *time.Time clearedFields map[string]struct{} done bool - oldValue func(context.Context) (*TwitchCategory, error) - predicates []predicate.TwitchCategory + oldValue func(context.Context) (*Sessions, error) + predicates []predicate.Sessions } -var _ ent.Mutation = (*TwitchCategoryMutation)(nil) +var _ ent.Mutation = (*SessionsMutation)(nil) -// twitchcategoryOption allows management of the mutation configuration using functional options. -type twitchcategoryOption func(*TwitchCategoryMutation) +// sessionsOption allows management of the mutation configuration using functional options. +type sessionsOption func(*SessionsMutation) -// newTwitchCategoryMutation creates new mutation for the TwitchCategory entity. -func newTwitchCategoryMutation(c config, op Op, opts ...twitchcategoryOption) *TwitchCategoryMutation { - m := &TwitchCategoryMutation{ +// newSessionsMutation creates new mutation for the Sessions entity. +func newSessionsMutation(c config, op Op, opts ...sessionsOption) *SessionsMutation { + m := &SessionsMutation{ config: c, op: op, - typ: TypeTwitchCategory, + typ: TypeSessions, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -8664,20 +8965,20 @@ func newTwitchCategoryMutation(c config, op Op, opts ...twitchcategoryOption) *T return m } -// withTwitchCategoryID sets the ID field of the mutation. -func withTwitchCategoryID(id string) twitchcategoryOption { - return func(m *TwitchCategoryMutation) { +// withSessionsID sets the ID field of the mutation. +func withSessionsID(id int) sessionsOption { + return func(m *SessionsMutation) { var ( err error once sync.Once - value *TwitchCategory + value *Sessions ) - m.oldValue = func(ctx context.Context) (*TwitchCategory, error) { + m.oldValue = func(ctx context.Context) (*Sessions, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().TwitchCategory.Get(ctx, id) + value, err = m.Client().Sessions.Get(ctx, id) } }) return value, err @@ -8686,10 +8987,10 @@ func withTwitchCategoryID(id string) twitchcategoryOption { } } -// withTwitchCategory sets the old TwitchCategory of the mutation. -func withTwitchCategory(node *TwitchCategory) twitchcategoryOption { - return func(m *TwitchCategoryMutation) { - m.oldValue = func(context.Context) (*TwitchCategory, error) { +// withSessions sets the old Sessions of the mutation. +func withSessions(node *Sessions) sessionsOption { + return func(m *SessionsMutation) { + m.oldValue = func(context.Context) (*Sessions, error) { return node, nil } m.id = &node.ID @@ -8698,7 +8999,7 @@ func withTwitchCategory(node *TwitchCategory) twitchcategoryOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m TwitchCategoryMutation) Client() *Client { +func (m SessionsMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -8706,7 +9007,7 @@ func (m TwitchCategoryMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m TwitchCategoryMutation) Tx() (*Tx, error) { +func (m SessionsMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -8715,15 +9016,9 @@ func (m TwitchCategoryMutation) Tx() (*Tx, error) { return tx, nil } -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of TwitchCategory entities. -func (m *TwitchCategoryMutation) SetID(id string) { - m.id = &id -} - // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *TwitchCategoryMutation) ID() (id string, exists bool) { +func (m *SessionsMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -8734,236 +9029,138 @@ func (m *TwitchCategoryMutation) ID() (id string, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *TwitchCategoryMutation) IDs(ctx context.Context) ([]string, error) { +func (m *SessionsMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []string{id}, nil + return []int{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().TwitchCategory.Query().Where(m.predicates...).IDs(ctx) + return m.Client().Sessions.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetName sets the "name" field. -func (m *TwitchCategoryMutation) SetName(s string) { - m.name = &s +// SetToken sets the "token" field. +func (m *SessionsMutation) SetToken(s string) { + m.token = &s } -// Name returns the value of the "name" field in the mutation. -func (m *TwitchCategoryMutation) Name() (r string, exists bool) { - v := m.name +// Token returns the value of the "token" field in the mutation. +func (m *SessionsMutation) Token() (r string, exists bool) { + v := m.token if v == nil { return } return *v, true } -// OldName returns the old "name" field's value of the TwitchCategory entity. -// If the TwitchCategory object wasn't provided to the builder, the object is fetched from the database. +// OldToken returns the old "token" field's value of the Sessions entity. +// If the Sessions object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TwitchCategoryMutation) OldName(ctx context.Context) (v string, err error) { +func (m *SessionsMutation) OldToken(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") + return v, errors.New("OldToken is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") + return v, errors.New("OldToken requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) + return v, fmt.Errorf("querying old value for OldToken: %w", err) } - return oldValue.Name, nil + return oldValue.Token, nil } -// ResetName resets all changes to the "name" field. -func (m *TwitchCategoryMutation) ResetName() { - m.name = nil +// ResetToken resets all changes to the "token" field. +func (m *SessionsMutation) ResetToken() { + m.token = nil } -// SetBoxArtURL sets the "box_art_url" field. -func (m *TwitchCategoryMutation) SetBoxArtURL(s string) { - m.box_art_url = &s +// SetData sets the "data" field. +func (m *SessionsMutation) SetData(b []byte) { + m.data = &b } -// BoxArtURL returns the value of the "box_art_url" field in the mutation. -func (m *TwitchCategoryMutation) BoxArtURL() (r string, exists bool) { - v := m.box_art_url +// Data returns the value of the "data" field in the mutation. +func (m *SessionsMutation) Data() (r []byte, exists bool) { + v := m.data if v == nil { return } return *v, true } -// OldBoxArtURL returns the old "box_art_url" field's value of the TwitchCategory entity. -// If the TwitchCategory object wasn't provided to the builder, the object is fetched from the database. +// OldData returns the old "data" field's value of the Sessions entity. +// If the Sessions object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TwitchCategoryMutation) OldBoxArtURL(ctx context.Context) (v string, err error) { +func (m *SessionsMutation) OldData(ctx context.Context) (v []byte, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldBoxArtURL is only allowed on UpdateOne operations") + return v, errors.New("OldData is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldBoxArtURL requires an ID field in the mutation") + return v, errors.New("OldData requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldBoxArtURL: %w", err) + return v, fmt.Errorf("querying old value for OldData: %w", err) } - return oldValue.BoxArtURL, nil -} - -// ClearBoxArtURL clears the value of the "box_art_url" field. -func (m *TwitchCategoryMutation) ClearBoxArtURL() { - m.box_art_url = nil - m.clearedFields[twitchcategory.FieldBoxArtURL] = struct{}{} -} - -// BoxArtURLCleared returns if the "box_art_url" field was cleared in this mutation. -func (m *TwitchCategoryMutation) BoxArtURLCleared() bool { - _, ok := m.clearedFields[twitchcategory.FieldBoxArtURL] - return ok + return oldValue.Data, nil } -// ResetBoxArtURL resets all changes to the "box_art_url" field. -func (m *TwitchCategoryMutation) ResetBoxArtURL() { - m.box_art_url = nil - delete(m.clearedFields, twitchcategory.FieldBoxArtURL) +// ResetData resets all changes to the "data" field. +func (m *SessionsMutation) ResetData() { + m.data = nil } -// SetIgdbID sets the "igdb_id" field. -func (m *TwitchCategoryMutation) SetIgdbID(s string) { - m.igdb_id = &s +// SetExpiry sets the "expiry" field. +func (m *SessionsMutation) SetExpiry(t time.Time) { + m.expiry = &t } -// IgdbID returns the value of the "igdb_id" field in the mutation. -func (m *TwitchCategoryMutation) IgdbID() (r string, exists bool) { - v := m.igdb_id +// Expiry returns the value of the "expiry" field in the mutation. +func (m *SessionsMutation) Expiry() (r time.Time, exists bool) { + v := m.expiry if v == nil { return } return *v, true } -// OldIgdbID returns the old "igdb_id" field's value of the TwitchCategory entity. -// If the TwitchCategory object wasn't provided to the builder, the object is fetched from the database. +// OldExpiry returns the old "expiry" field's value of the Sessions entity. +// If the Sessions object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TwitchCategoryMutation) OldIgdbID(ctx context.Context) (v string, err error) { +func (m *SessionsMutation) OldExpiry(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIgdbID is only allowed on UpdateOne operations") + return v, errors.New("OldExpiry is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIgdbID requires an ID field in the mutation") + return v, errors.New("OldExpiry requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldIgdbID: %w", err) + return v, fmt.Errorf("querying old value for OldExpiry: %w", err) } - return oldValue.IgdbID, nil + return oldValue.Expiry, nil } -// ClearIgdbID clears the value of the "igdb_id" field. -func (m *TwitchCategoryMutation) ClearIgdbID() { - m.igdb_id = nil - m.clearedFields[twitchcategory.FieldIgdbID] = struct{}{} +// ResetExpiry resets all changes to the "expiry" field. +func (m *SessionsMutation) ResetExpiry() { + m.expiry = nil } -// IgdbIDCleared returns if the "igdb_id" field was cleared in this mutation. -func (m *TwitchCategoryMutation) IgdbIDCleared() bool { - _, ok := m.clearedFields[twitchcategory.FieldIgdbID] - return ok -} - -// ResetIgdbID resets all changes to the "igdb_id" field. -func (m *TwitchCategoryMutation) ResetIgdbID() { - m.igdb_id = nil - delete(m.clearedFields, twitchcategory.FieldIgdbID) -} - -// SetUpdatedAt sets the "updated_at" field. -func (m *TwitchCategoryMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *TwitchCategoryMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true -} - -// OldUpdatedAt returns the old "updated_at" field's value of the TwitchCategory entity. -// If the TwitchCategory object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TwitchCategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *TwitchCategoryMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// SetCreatedAt sets the "created_at" field. -func (m *TwitchCategoryMutation) SetCreatedAt(t time.Time) { - m.created_at = &t -} - -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *TwitchCategoryMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true -} - -// OldCreatedAt returns the old "created_at" field's value of the TwitchCategory entity. -// If the TwitchCategory object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *TwitchCategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) - } - return oldValue.CreatedAt, nil -} - -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *TwitchCategoryMutation) ResetCreatedAt() { - m.created_at = nil -} - -// Where appends a list predicates to the TwitchCategoryMutation builder. -func (m *TwitchCategoryMutation) Where(ps ...predicate.TwitchCategory) { +// Where appends a list predicates to the SessionsMutation builder. +func (m *SessionsMutation) Where(ps ...predicate.Sessions) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the TwitchCategoryMutation builder. Using this method, +// WhereP appends storage-level predicates to the SessionsMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *TwitchCategoryMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.TwitchCategory, len(ps)) +func (m *SessionsMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Sessions, len(ps)) for i := range ps { p[i] = ps[i] } @@ -8971,39 +9168,33 @@ func (m *TwitchCategoryMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *TwitchCategoryMutation) Op() Op { +func (m *SessionsMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *TwitchCategoryMutation) SetOp(op Op) { +func (m *SessionsMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (TwitchCategory). -func (m *TwitchCategoryMutation) Type() string { +// Type returns the node type of this mutation (Sessions). +func (m *SessionsMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *TwitchCategoryMutation) Fields() []string { - fields := make([]string, 0, 5) - if m.name != nil { - fields = append(fields, twitchcategory.FieldName) - } - if m.box_art_url != nil { - fields = append(fields, twitchcategory.FieldBoxArtURL) - } - if m.igdb_id != nil { - fields = append(fields, twitchcategory.FieldIgdbID) +func (m *SessionsMutation) Fields() []string { + fields := make([]string, 0, 3) + if m.token != nil { + fields = append(fields, sessions.FieldToken) } - if m.updated_at != nil { - fields = append(fields, twitchcategory.FieldUpdatedAt) + if m.data != nil { + fields = append(fields, sessions.FieldData) } - if m.created_at != nil { - fields = append(fields, twitchcategory.FieldCreatedAt) + if m.expiry != nil { + fields = append(fields, sessions.FieldExpiry) } return fields } @@ -9011,18 +9202,14 @@ func (m *TwitchCategoryMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *TwitchCategoryMutation) Field(name string) (ent.Value, bool) { +func (m *SessionsMutation) Field(name string) (ent.Value, bool) { switch name { - case twitchcategory.FieldName: - return m.Name() - case twitchcategory.FieldBoxArtURL: - return m.BoxArtURL() - case twitchcategory.FieldIgdbID: - return m.IgdbID() - case twitchcategory.FieldUpdatedAt: - return m.UpdatedAt() - case twitchcategory.FieldCreatedAt: - return m.CreatedAt() + case sessions.FieldToken: + return m.Token() + case sessions.FieldData: + return m.Data() + case sessions.FieldExpiry: + return m.Expiry() } return nil, false } @@ -9030,224 +9217,182 @@ func (m *TwitchCategoryMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *TwitchCategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *SessionsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case twitchcategory.FieldName: - return m.OldName(ctx) - case twitchcategory.FieldBoxArtURL: - return m.OldBoxArtURL(ctx) - case twitchcategory.FieldIgdbID: - return m.OldIgdbID(ctx) - case twitchcategory.FieldUpdatedAt: - return m.OldUpdatedAt(ctx) - case twitchcategory.FieldCreatedAt: - return m.OldCreatedAt(ctx) + case sessions.FieldToken: + return m.OldToken(ctx) + case sessions.FieldData: + return m.OldData(ctx) + case sessions.FieldExpiry: + return m.OldExpiry(ctx) } - return nil, fmt.Errorf("unknown TwitchCategory field %s", name) + return nil, fmt.Errorf("unknown Sessions field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *TwitchCategoryMutation) SetField(name string, value ent.Value) error { +func (m *SessionsMutation) SetField(name string, value ent.Value) error { switch name { - case twitchcategory.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case twitchcategory.FieldBoxArtURL: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetBoxArtURL(v) - return nil - case twitchcategory.FieldIgdbID: + case sessions.FieldToken: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetIgdbID(v) + m.SetToken(v) return nil - case twitchcategory.FieldUpdatedAt: - v, ok := value.(time.Time) + case sessions.FieldData: + v, ok := value.([]byte) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUpdatedAt(v) + m.SetData(v) return nil - case twitchcategory.FieldCreatedAt: + case sessions.FieldExpiry: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetCreatedAt(v) + m.SetExpiry(v) return nil } - return fmt.Errorf("unknown TwitchCategory field %s", name) + return fmt.Errorf("unknown Sessions field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *TwitchCategoryMutation) AddedFields() []string { +func (m *SessionsMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *TwitchCategoryMutation) AddedField(name string) (ent.Value, bool) { +func (m *SessionsMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *TwitchCategoryMutation) AddField(name string, value ent.Value) error { +func (m *SessionsMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown TwitchCategory numeric field %s", name) + return fmt.Errorf("unknown Sessions numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *TwitchCategoryMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(twitchcategory.FieldBoxArtURL) { - fields = append(fields, twitchcategory.FieldBoxArtURL) - } - if m.FieldCleared(twitchcategory.FieldIgdbID) { - fields = append(fields, twitchcategory.FieldIgdbID) - } - return fields +func (m *SessionsMutation) ClearedFields() []string { + return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *TwitchCategoryMutation) FieldCleared(name string) bool { +func (m *SessionsMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *TwitchCategoryMutation) ClearField(name string) error { - switch name { - case twitchcategory.FieldBoxArtURL: - m.ClearBoxArtURL() - return nil - case twitchcategory.FieldIgdbID: - m.ClearIgdbID() - return nil - } - return fmt.Errorf("unknown TwitchCategory nullable field %s", name) +func (m *SessionsMutation) ClearField(name string) error { + return fmt.Errorf("unknown Sessions nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *TwitchCategoryMutation) ResetField(name string) error { +func (m *SessionsMutation) ResetField(name string) error { switch name { - case twitchcategory.FieldName: - m.ResetName() - return nil - case twitchcategory.FieldBoxArtURL: - m.ResetBoxArtURL() - return nil - case twitchcategory.FieldIgdbID: - m.ResetIgdbID() + case sessions.FieldToken: + m.ResetToken() return nil - case twitchcategory.FieldUpdatedAt: - m.ResetUpdatedAt() + case sessions.FieldData: + m.ResetData() return nil - case twitchcategory.FieldCreatedAt: - m.ResetCreatedAt() + case sessions.FieldExpiry: + m.ResetExpiry() return nil } - return fmt.Errorf("unknown TwitchCategory field %s", name) + return fmt.Errorf("unknown Sessions field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *TwitchCategoryMutation) AddedEdges() []string { +func (m *SessionsMutation) AddedEdges() []string { edges := make([]string, 0, 0) return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *TwitchCategoryMutation) AddedIDs(name string) []ent.Value { +func (m *SessionsMutation) AddedIDs(name string) []ent.Value { return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *TwitchCategoryMutation) RemovedEdges() []string { +func (m *SessionsMutation) RemovedEdges() []string { edges := make([]string, 0, 0) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *TwitchCategoryMutation) RemovedIDs(name string) []ent.Value { +func (m *SessionsMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *TwitchCategoryMutation) ClearedEdges() []string { +func (m *SessionsMutation) ClearedEdges() []string { edges := make([]string, 0, 0) return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *TwitchCategoryMutation) EdgeCleared(name string) bool { +func (m *SessionsMutation) EdgeCleared(name string) bool { return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *TwitchCategoryMutation) ClearEdge(name string) error { - return fmt.Errorf("unknown TwitchCategory unique edge %s", name) +func (m *SessionsMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Sessions unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *TwitchCategoryMutation) ResetEdge(name string) error { - return fmt.Errorf("unknown TwitchCategory edge %s", name) +func (m *SessionsMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Sessions edge %s", name) } -// UserMutation represents an operation that mutates the User nodes in the graph. -type UserMutation struct { +// TwitchCategoryMutation represents an operation that mutates the TwitchCategory nodes in the graph. +type TwitchCategoryMutation struct { config op Op typ string - id *uuid.UUID - sub *string - username *string - password *string - oauth *bool - role *utils.Role - webhook *string + id *string + name *string + box_art_url *string + igdb_id *string updated_at *time.Time created_at *time.Time clearedFields map[string]struct{} done bool - oldValue func(context.Context) (*User, error) - predicates []predicate.User + oldValue func(context.Context) (*TwitchCategory, error) + predicates []predicate.TwitchCategory } -var _ ent.Mutation = (*UserMutation)(nil) +var _ ent.Mutation = (*TwitchCategoryMutation)(nil) -// userOption allows management of the mutation configuration using functional options. -type userOption func(*UserMutation) +// twitchcategoryOption allows management of the mutation configuration using functional options. +type twitchcategoryOption func(*TwitchCategoryMutation) -// newUserMutation creates new mutation for the User entity. -func newUserMutation(c config, op Op, opts ...userOption) *UserMutation { - m := &UserMutation{ +// newTwitchCategoryMutation creates new mutation for the TwitchCategory entity. +func newTwitchCategoryMutation(c config, op Op, opts ...twitchcategoryOption) *TwitchCategoryMutation { + m := &TwitchCategoryMutation{ config: c, op: op, - typ: TypeUser, + typ: TypeTwitchCategory, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -9256,20 +9401,20 @@ func newUserMutation(c config, op Op, opts ...userOption) *UserMutation { return m } -// withUserID sets the ID field of the mutation. -func withUserID(id uuid.UUID) userOption { - return func(m *UserMutation) { +// withTwitchCategoryID sets the ID field of the mutation. +func withTwitchCategoryID(id string) twitchcategoryOption { + return func(m *TwitchCategoryMutation) { var ( err error once sync.Once - value *User + value *TwitchCategory ) - m.oldValue = func(ctx context.Context) (*User, error) { + m.oldValue = func(ctx context.Context) (*TwitchCategory, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().User.Get(ctx, id) + value, err = m.Client().TwitchCategory.Get(ctx, id) } }) return value, err @@ -9278,10 +9423,10 @@ func withUserID(id uuid.UUID) userOption { } } -// withUser sets the old User of the mutation. -func withUser(node *User) userOption { - return func(m *UserMutation) { - m.oldValue = func(context.Context) (*User, error) { +// withTwitchCategory sets the old TwitchCategory of the mutation. +func withTwitchCategory(node *TwitchCategory) twitchcategoryOption { + return func(m *TwitchCategoryMutation) { + m.oldValue = func(context.Context) (*TwitchCategory, error) { return node, nil } m.id = &node.ID @@ -9290,7 +9435,7 @@ func withUser(node *User) userOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m UserMutation) Client() *Client { +func (m TwitchCategoryMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -9298,7 +9443,7 @@ func (m UserMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m UserMutation) Tx() (*Tx, error) { +func (m TwitchCategoryMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -9308,14 +9453,14 @@ func (m UserMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of User entities. -func (m *UserMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of TwitchCategory entities. +func (m *TwitchCategoryMutation) SetID(id string) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *UserMutation) ID() (id uuid.UUID, exists bool) { +func (m *TwitchCategoryMutation) ID() (id string, exists bool) { if m.id == nil { return } @@ -9326,406 +9471,276 @@ func (m *UserMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *UserMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *TwitchCategoryMutation) IDs(ctx context.Context) ([]string, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []uuid.UUID{id}, nil + return []string{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().User.Query().Where(m.predicates...).IDs(ctx) + return m.Client().TwitchCategory.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetSub sets the "sub" field. -func (m *UserMutation) SetSub(s string) { - m.sub = &s +// SetName sets the "name" field. +func (m *TwitchCategoryMutation) SetName(s string) { + m.name = &s } -// Sub returns the value of the "sub" field in the mutation. -func (m *UserMutation) Sub() (r string, exists bool) { - v := m.sub +// Name returns the value of the "name" field in the mutation. +func (m *TwitchCategoryMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldSub returns the old "sub" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the TwitchCategory entity. +// If the TwitchCategory object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldSub(ctx context.Context) (v string, err error) { +func (m *TwitchCategoryMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSub is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSub requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSub: %w", err) + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.Sub, nil -} - -// ClearSub clears the value of the "sub" field. -func (m *UserMutation) ClearSub() { - m.sub = nil - m.clearedFields[user.FieldSub] = struct{}{} -} - -// SubCleared returns if the "sub" field was cleared in this mutation. -func (m *UserMutation) SubCleared() bool { - _, ok := m.clearedFields[user.FieldSub] - return ok + return oldValue.Name, nil } -// ResetSub resets all changes to the "sub" field. -func (m *UserMutation) ResetSub() { - m.sub = nil - delete(m.clearedFields, user.FieldSub) +// ResetName resets all changes to the "name" field. +func (m *TwitchCategoryMutation) ResetName() { + m.name = nil } -// SetUsername sets the "username" field. -func (m *UserMutation) SetUsername(s string) { - m.username = &s +// SetBoxArtURL sets the "box_art_url" field. +func (m *TwitchCategoryMutation) SetBoxArtURL(s string) { + m.box_art_url = &s } -// Username returns the value of the "username" field in the mutation. -func (m *UserMutation) Username() (r string, exists bool) { - v := m.username +// BoxArtURL returns the value of the "box_art_url" field in the mutation. +func (m *TwitchCategoryMutation) BoxArtURL() (r string, exists bool) { + v := m.box_art_url if v == nil { return } return *v, true } -// OldUsername returns the old "username" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. +// OldBoxArtURL returns the old "box_art_url" field's value of the TwitchCategory entity. +// If the TwitchCategory object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) { +func (m *TwitchCategoryMutation) OldBoxArtURL(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUsername is only allowed on UpdateOne operations") + return v, errors.New("OldBoxArtURL is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUsername requires an ID field in the mutation") + return v, errors.New("OldBoxArtURL requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUsername: %w", err) + return v, fmt.Errorf("querying old value for OldBoxArtURL: %w", err) } - return oldValue.Username, nil + return oldValue.BoxArtURL, nil } -// ResetUsername resets all changes to the "username" field. -func (m *UserMutation) ResetUsername() { - m.username = nil +// ClearBoxArtURL clears the value of the "box_art_url" field. +func (m *TwitchCategoryMutation) ClearBoxArtURL() { + m.box_art_url = nil + m.clearedFields[twitchcategory.FieldBoxArtURL] = struct{}{} } -// SetPassword sets the "password" field. -func (m *UserMutation) SetPassword(s string) { - m.password = &s +// BoxArtURLCleared returns if the "box_art_url" field was cleared in this mutation. +func (m *TwitchCategoryMutation) BoxArtURLCleared() bool { + _, ok := m.clearedFields[twitchcategory.FieldBoxArtURL] + return ok } -// Password returns the value of the "password" field in the mutation. -func (m *UserMutation) Password() (r string, exists bool) { - v := m.password +// ResetBoxArtURL resets all changes to the "box_art_url" field. +func (m *TwitchCategoryMutation) ResetBoxArtURL() { + m.box_art_url = nil + delete(m.clearedFields, twitchcategory.FieldBoxArtURL) +} + +// SetIgdbID sets the "igdb_id" field. +func (m *TwitchCategoryMutation) SetIgdbID(s string) { + m.igdb_id = &s +} + +// IgdbID returns the value of the "igdb_id" field in the mutation. +func (m *TwitchCategoryMutation) IgdbID() (r string, exists bool) { + v := m.igdb_id if v == nil { return } return *v, true } -// OldPassword returns the old "password" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. +// OldIgdbID returns the old "igdb_id" field's value of the TwitchCategory entity. +// If the TwitchCategory object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldPassword(ctx context.Context) (v string, err error) { +func (m *TwitchCategoryMutation) OldIgdbID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPassword is only allowed on UpdateOne operations") + return v, errors.New("OldIgdbID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPassword requires an ID field in the mutation") + return v, errors.New("OldIgdbID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPassword: %w", err) + return v, fmt.Errorf("querying old value for OldIgdbID: %w", err) } - return oldValue.Password, nil + return oldValue.IgdbID, nil } -// ClearPassword clears the value of the "password" field. -func (m *UserMutation) ClearPassword() { - m.password = nil - m.clearedFields[user.FieldPassword] = struct{}{} +// ClearIgdbID clears the value of the "igdb_id" field. +func (m *TwitchCategoryMutation) ClearIgdbID() { + m.igdb_id = nil + m.clearedFields[twitchcategory.FieldIgdbID] = struct{}{} } -// PasswordCleared returns if the "password" field was cleared in this mutation. -func (m *UserMutation) PasswordCleared() bool { - _, ok := m.clearedFields[user.FieldPassword] +// IgdbIDCleared returns if the "igdb_id" field was cleared in this mutation. +func (m *TwitchCategoryMutation) IgdbIDCleared() bool { + _, ok := m.clearedFields[twitchcategory.FieldIgdbID] return ok } -// ResetPassword resets all changes to the "password" field. -func (m *UserMutation) ResetPassword() { - m.password = nil - delete(m.clearedFields, user.FieldPassword) +// ResetIgdbID resets all changes to the "igdb_id" field. +func (m *TwitchCategoryMutation) ResetIgdbID() { + m.igdb_id = nil + delete(m.clearedFields, twitchcategory.FieldIgdbID) } -// SetOauth sets the "oauth" field. -func (m *UserMutation) SetOauth(b bool) { - m.oauth = &b +// SetUpdatedAt sets the "updated_at" field. +func (m *TwitchCategoryMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t } -// Oauth returns the value of the "oauth" field in the mutation. -func (m *UserMutation) Oauth() (r bool, exists bool) { - v := m.oauth +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *TwitchCategoryMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at if v == nil { return } return *v, true } -// OldOauth returns the old "oauth" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. +// OldUpdatedAt returns the old "updated_at" field's value of the TwitchCategory entity. +// If the TwitchCategory object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldOauth(ctx context.Context) (v bool, err error) { +func (m *TwitchCategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOauth is only allowed on UpdateOne operations") + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOauth requires an ID field in the mutation") + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldOauth: %w", err) + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) } - return oldValue.Oauth, nil + return oldValue.UpdatedAt, nil } -// ResetOauth resets all changes to the "oauth" field. -func (m *UserMutation) ResetOauth() { - m.oauth = nil +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *TwitchCategoryMutation) ResetUpdatedAt() { + m.updated_at = nil } -// SetRole sets the "role" field. -func (m *UserMutation) SetRole(u utils.Role) { - m.role = &u +// SetCreatedAt sets the "created_at" field. +func (m *TwitchCategoryMutation) SetCreatedAt(t time.Time) { + m.created_at = &t } -// Role returns the value of the "role" field in the mutation. -func (m *UserMutation) Role() (r utils.Role, exists bool) { - v := m.role +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *TwitchCategoryMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at if v == nil { return } return *v, true } -// OldRole returns the old "role" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. +// OldCreatedAt returns the old "created_at" field's value of the TwitchCategory entity. +// If the TwitchCategory object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldRole(ctx context.Context) (v utils.Role, err error) { +func (m *TwitchCategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRole is only allowed on UpdateOne operations") + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRole requires an ID field in the mutation") + return v, errors.New("OldCreatedAt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldRole: %w", err) + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) } - return oldValue.Role, nil + return oldValue.CreatedAt, nil } -// ResetRole resets all changes to the "role" field. -func (m *UserMutation) ResetRole() { - m.role = nil +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *TwitchCategoryMutation) ResetCreatedAt() { + m.created_at = nil } -// SetWebhook sets the "webhook" field. -func (m *UserMutation) SetWebhook(s string) { - m.webhook = &s +// Where appends a list predicates to the TwitchCategoryMutation builder. +func (m *TwitchCategoryMutation) Where(ps ...predicate.TwitchCategory) { + m.predicates = append(m.predicates, ps...) } -// Webhook returns the value of the "webhook" field in the mutation. -func (m *UserMutation) Webhook() (r string, exists bool) { - v := m.webhook - if v == nil { - return +// WhereP appends storage-level predicates to the TwitchCategoryMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *TwitchCategoryMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.TwitchCategory, len(ps)) + for i := range ps { + p[i] = ps[i] } - return *v, true + m.Where(p...) } -// OldWebhook returns the old "webhook" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldWebhook(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldWebhook is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldWebhook requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldWebhook: %w", err) - } - return oldValue.Webhook, nil -} - -// ClearWebhook clears the value of the "webhook" field. -func (m *UserMutation) ClearWebhook() { - m.webhook = nil - m.clearedFields[user.FieldWebhook] = struct{}{} -} - -// WebhookCleared returns if the "webhook" field was cleared in this mutation. -func (m *UserMutation) WebhookCleared() bool { - _, ok := m.clearedFields[user.FieldWebhook] - return ok -} - -// ResetWebhook resets all changes to the "webhook" field. -func (m *UserMutation) ResetWebhook() { - m.webhook = nil - delete(m.clearedFields, user.FieldWebhook) -} - -// SetUpdatedAt sets the "updated_at" field. -func (m *UserMutation) SetUpdatedAt(t time.Time) { - m.updated_at = &t -} - -// UpdatedAt returns the value of the "updated_at" field in the mutation. -func (m *UserMutation) UpdatedAt() (r time.Time, exists bool) { - v := m.updated_at - if v == nil { - return - } - return *v, true -} - -// OldUpdatedAt returns the old "updated_at" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) - } - return oldValue.UpdatedAt, nil -} - -// ResetUpdatedAt resets all changes to the "updated_at" field. -func (m *UserMutation) ResetUpdatedAt() { - m.updated_at = nil -} - -// SetCreatedAt sets the "created_at" field. -func (m *UserMutation) SetCreatedAt(t time.Time) { - m.created_at = &t -} - -// CreatedAt returns the value of the "created_at" field in the mutation. -func (m *UserMutation) CreatedAt() (r time.Time, exists bool) { - v := m.created_at - if v == nil { - return - } - return *v, true -} - -// OldCreatedAt returns the old "created_at" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreatedAt requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) - } - return oldValue.CreatedAt, nil -} - -// ResetCreatedAt resets all changes to the "created_at" field. -func (m *UserMutation) ResetCreatedAt() { - m.created_at = nil -} - -// Where appends a list predicates to the UserMutation builder. -func (m *UserMutation) Where(ps ...predicate.User) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the UserMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.User, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *UserMutation) Op() Op { - return m.op +// Op returns the operation name. +func (m *TwitchCategoryMutation) Op() Op { + return m.op } // SetOp allows setting the mutation operation. -func (m *UserMutation) SetOp(op Op) { +func (m *TwitchCategoryMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (User). -func (m *UserMutation) Type() string { +// Type returns the node type of this mutation (TwitchCategory). +func (m *TwitchCategoryMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 8) - if m.sub != nil { - fields = append(fields, user.FieldSub) - } - if m.username != nil { - fields = append(fields, user.FieldUsername) - } - if m.password != nil { - fields = append(fields, user.FieldPassword) - } - if m.oauth != nil { - fields = append(fields, user.FieldOauth) +func (m *TwitchCategoryMutation) Fields() []string { + fields := make([]string, 0, 5) + if m.name != nil { + fields = append(fields, twitchcategory.FieldName) } - if m.role != nil { - fields = append(fields, user.FieldRole) + if m.box_art_url != nil { + fields = append(fields, twitchcategory.FieldBoxArtURL) } - if m.webhook != nil { - fields = append(fields, user.FieldWebhook) + if m.igdb_id != nil { + fields = append(fields, twitchcategory.FieldIgdbID) } if m.updated_at != nil { - fields = append(fields, user.FieldUpdatedAt) + fields = append(fields, twitchcategory.FieldUpdatedAt) } if m.created_at != nil { - fields = append(fields, user.FieldCreatedAt) + fields = append(fields, twitchcategory.FieldCreatedAt) } return fields } @@ -9733,23 +9748,17 @@ func (m *UserMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *UserMutation) Field(name string) (ent.Value, bool) { +func (m *TwitchCategoryMutation) Field(name string) (ent.Value, bool) { switch name { - case user.FieldSub: - return m.Sub() - case user.FieldUsername: - return m.Username() - case user.FieldPassword: - return m.Password() - case user.FieldOauth: - return m.Oauth() - case user.FieldRole: - return m.Role() - case user.FieldWebhook: - return m.Webhook() - case user.FieldUpdatedAt: + case twitchcategory.FieldName: + return m.Name() + case twitchcategory.FieldBoxArtURL: + return m.BoxArtURL() + case twitchcategory.FieldIgdbID: + return m.IgdbID() + case twitchcategory.FieldUpdatedAt: return m.UpdatedAt() - case user.FieldCreatedAt: + case twitchcategory.FieldCreatedAt: return m.CreatedAt() } return nil, false @@ -9758,83 +9767,56 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *TwitchCategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case user.FieldSub: - return m.OldSub(ctx) - case user.FieldUsername: - return m.OldUsername(ctx) - case user.FieldPassword: - return m.OldPassword(ctx) - case user.FieldOauth: - return m.OldOauth(ctx) - case user.FieldRole: - return m.OldRole(ctx) - case user.FieldWebhook: - return m.OldWebhook(ctx) - case user.FieldUpdatedAt: + case twitchcategory.FieldName: + return m.OldName(ctx) + case twitchcategory.FieldBoxArtURL: + return m.OldBoxArtURL(ctx) + case twitchcategory.FieldIgdbID: + return m.OldIgdbID(ctx) + case twitchcategory.FieldUpdatedAt: return m.OldUpdatedAt(ctx) - case user.FieldCreatedAt: + case twitchcategory.FieldCreatedAt: return m.OldCreatedAt(ctx) } - return nil, fmt.Errorf("unknown User field %s", name) + return nil, fmt.Errorf("unknown TwitchCategory field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *UserMutation) SetField(name string, value ent.Value) error { +func (m *TwitchCategoryMutation) SetField(name string, value ent.Value) error { switch name { - case user.FieldSub: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSub(v) - return nil - case user.FieldUsername: + case twitchcategory.FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUsername(v) + m.SetName(v) return nil - case user.FieldPassword: + case twitchcategory.FieldBoxArtURL: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetPassword(v) - return nil - case user.FieldOauth: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetOauth(v) - return nil - case user.FieldRole: - v, ok := value.(utils.Role) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRole(v) + m.SetBoxArtURL(v) return nil - case user.FieldWebhook: + case twitchcategory.FieldIgdbID: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetWebhook(v) + m.SetIgdbID(v) return nil - case user.FieldUpdatedAt: + case twitchcategory.FieldUpdatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUpdatedAt(v) return nil - case user.FieldCreatedAt: + case twitchcategory.FieldCreatedAt: v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) @@ -9842,226 +9824,167 @@ func (m *UserMutation) SetField(name string, value ent.Value) error { m.SetCreatedAt(v) return nil } - return fmt.Errorf("unknown User field %s", name) + return fmt.Errorf("unknown TwitchCategory field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *UserMutation) AddedFields() []string { +func (m *TwitchCategoryMutation) AddedFields() []string { return nil } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *UserMutation) AddedField(name string) (ent.Value, bool) { +func (m *TwitchCategoryMutation) AddedField(name string) (ent.Value, bool) { return nil, false } // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *UserMutation) AddField(name string, value ent.Value) error { +func (m *TwitchCategoryMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown User numeric field %s", name) + return fmt.Errorf("unknown TwitchCategory numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *UserMutation) ClearedFields() []string { +func (m *TwitchCategoryMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(user.FieldSub) { - fields = append(fields, user.FieldSub) - } - if m.FieldCleared(user.FieldPassword) { - fields = append(fields, user.FieldPassword) + if m.FieldCleared(twitchcategory.FieldBoxArtURL) { + fields = append(fields, twitchcategory.FieldBoxArtURL) } - if m.FieldCleared(user.FieldWebhook) { - fields = append(fields, user.FieldWebhook) + if m.FieldCleared(twitchcategory.FieldIgdbID) { + fields = append(fields, twitchcategory.FieldIgdbID) } return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *UserMutation) FieldCleared(name string) bool { +func (m *TwitchCategoryMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *UserMutation) ClearField(name string) error { +func (m *TwitchCategoryMutation) ClearField(name string) error { switch name { - case user.FieldSub: - m.ClearSub() - return nil - case user.FieldPassword: - m.ClearPassword() + case twitchcategory.FieldBoxArtURL: + m.ClearBoxArtURL() return nil - case user.FieldWebhook: - m.ClearWebhook() + case twitchcategory.FieldIgdbID: + m.ClearIgdbID() return nil } - return fmt.Errorf("unknown User nullable field %s", name) + return fmt.Errorf("unknown TwitchCategory nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *UserMutation) ResetField(name string) error { +func (m *TwitchCategoryMutation) ResetField(name string) error { switch name { - case user.FieldSub: - m.ResetSub() - return nil - case user.FieldUsername: - m.ResetUsername() - return nil - case user.FieldPassword: - m.ResetPassword() - return nil - case user.FieldOauth: - m.ResetOauth() + case twitchcategory.FieldName: + m.ResetName() return nil - case user.FieldRole: - m.ResetRole() + case twitchcategory.FieldBoxArtURL: + m.ResetBoxArtURL() return nil - case user.FieldWebhook: - m.ResetWebhook() + case twitchcategory.FieldIgdbID: + m.ResetIgdbID() return nil - case user.FieldUpdatedAt: + case twitchcategory.FieldUpdatedAt: m.ResetUpdatedAt() return nil - case user.FieldCreatedAt: + case twitchcategory.FieldCreatedAt: m.ResetCreatedAt() return nil } - return fmt.Errorf("unknown User field %s", name) + return fmt.Errorf("unknown TwitchCategory field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *UserMutation) AddedEdges() []string { +func (m *TwitchCategoryMutation) AddedEdges() []string { edges := make([]string, 0, 0) return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *UserMutation) AddedIDs(name string) []ent.Value { +func (m *TwitchCategoryMutation) AddedIDs(name string) []ent.Value { return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *UserMutation) RemovedEdges() []string { +func (m *TwitchCategoryMutation) RemovedEdges() []string { edges := make([]string, 0, 0) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *UserMutation) RemovedIDs(name string) []ent.Value { +func (m *TwitchCategoryMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *UserMutation) ClearedEdges() []string { +func (m *TwitchCategoryMutation) ClearedEdges() []string { edges := make([]string, 0, 0) return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *UserMutation) EdgeCleared(name string) bool { +func (m *TwitchCategoryMutation) EdgeCleared(name string) bool { return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *UserMutation) ClearEdge(name string) error { - return fmt.Errorf("unknown User unique edge %s", name) +func (m *TwitchCategoryMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown TwitchCategory unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *UserMutation) ResetEdge(name string) error { - return fmt.Errorf("unknown User edge %s", name) +func (m *TwitchCategoryMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown TwitchCategory edge %s", name) } -// VodMutation represents an operation that mutates the Vod nodes in the graph. -type VodMutation struct { +// UserMutation represents an operation that mutates the User nodes in the graph. +type UserMutation struct { config - op Op - typ string - id *uuid.UUID - ext_id *string - ext_stream_id *string - platform *utils.VideoPlatform - _type *utils.VodType - title *string - duration *int - addduration *int - views *int - addviews *int - resolution *string - processing *bool - thumbnail_path *string - web_thumbnail_path *string - video_path *string - video_hls_path *string - chat_path *string - live_chat_path *string - live_chat_convert_path *string - chat_video_path *string - info_path *string - caption_path *string - folder_name *string - file_name *string - tmp_video_download_path *string - tmp_video_convert_path *string - tmp_chat_download_path *string - tmp_live_chat_download_path *string - tmp_live_chat_convert_path *string - tmp_chat_render_path *string - tmp_video_hls_path *string - locked *bool - local_views *int - addlocal_views *int - streamed_at *time.Time - updated_at *time.Time - created_at *time.Time - clearedFields map[string]struct{} - channel *uuid.UUID - clearedchannel bool - queue *uuid.UUID - clearedqueue bool - playlists map[uuid.UUID]struct{} - removedplaylists map[uuid.UUID]struct{} - clearedplaylists bool - chapters map[uuid.UUID]struct{} - removedchapters map[uuid.UUID]struct{} - clearedchapters bool - muted_segments map[uuid.UUID]struct{} - removedmuted_segments map[uuid.UUID]struct{} - clearedmuted_segments bool - multistream_info map[int]struct{} - removedmultistream_info map[int]struct{} - clearedmultistream_info bool - done bool - oldValue func(context.Context) (*Vod, error) - predicates []predicate.Vod + op Op + typ string + id *uuid.UUID + sub *string + username *string + password *string + oauth *bool + role *utils.Role + webhook *string + updated_at *time.Time + created_at *time.Time + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*User, error) + predicates []predicate.User } -var _ ent.Mutation = (*VodMutation)(nil) +var _ ent.Mutation = (*UserMutation)(nil) -// vodOption allows management of the mutation configuration using functional options. -type vodOption func(*VodMutation) +// userOption allows management of the mutation configuration using functional options. +type userOption func(*UserMutation) -// newVodMutation creates new mutation for the Vod entity. -func newVodMutation(c config, op Op, opts ...vodOption) *VodMutation { - m := &VodMutation{ +// newUserMutation creates new mutation for the User entity. +func newUserMutation(c config, op Op, opts ...userOption) *UserMutation { + m := &UserMutation{ config: c, op: op, - typ: TypeVod, + typ: TypeUser, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -10070,20 +9993,20 @@ func newVodMutation(c config, op Op, opts ...vodOption) *VodMutation { return m } -// withVodID sets the ID field of the mutation. -func withVodID(id uuid.UUID) vodOption { - return func(m *VodMutation) { +// withUserID sets the ID field of the mutation. +func withUserID(id uuid.UUID) userOption { + return func(m *UserMutation) { var ( err error once sync.Once - value *Vod + value *User ) - m.oldValue = func(ctx context.Context) (*Vod, error) { + m.oldValue = func(ctx context.Context) (*User, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().Vod.Get(ctx, id) + value, err = m.Client().User.Get(ctx, id) } }) return value, err @@ -10092,10 +10015,10 @@ func withVodID(id uuid.UUID) vodOption { } } -// withVod sets the old Vod of the mutation. -func withVod(node *Vod) vodOption { - return func(m *VodMutation) { - m.oldValue = func(context.Context) (*Vod, error) { +// withUser sets the old User of the mutation. +func withUser(node *User) userOption { + return func(m *UserMutation) { + m.oldValue = func(context.Context) (*User, error) { return node, nil } m.id = &node.ID @@ -10104,7 +10027,7 @@ func withVod(node *Vod) vodOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m VodMutation) Client() *Client { +func (m UserMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -10112,7 +10035,7 @@ func (m VodMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m VodMutation) Tx() (*Tx, error) { +func (m UserMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -10122,14 +10045,14 @@ func (m VodMutation) Tx() (*Tx, error) { } // SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Vod entities. -func (m *VodMutation) SetID(id uuid.UUID) { +// operation is only accepted on creation of User entities. +func (m *UserMutation) SetID(id uuid.UUID) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *VodMutation) ID() (id uuid.UUID, exists bool) { +func (m *UserMutation) ID() (id uuid.UUID, exists bool) { if m.id == nil { return } @@ -10140,7 +10063,7 @@ func (m *VodMutation) ID() (id uuid.UUID, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *VodMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { +func (m *UserMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -10149,1397 +10072,2797 @@ func (m *VodMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().Vod.Query().Where(m.predicates...).IDs(ctx) + return m.Client().User.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetExtID sets the "ext_id" field. -func (m *VodMutation) SetExtID(s string) { - m.ext_id = &s +// SetSub sets the "sub" field. +func (m *UserMutation) SetSub(s string) { + m.sub = &s } -// ExtID returns the value of the "ext_id" field in the mutation. -func (m *VodMutation) ExtID() (r string, exists bool) { - v := m.ext_id +// Sub returns the value of the "sub" field in the mutation. +func (m *UserMutation) Sub() (r string, exists bool) { + v := m.sub if v == nil { return } return *v, true } -// OldExtID returns the old "ext_id" field's value of the Vod entity. -// If the Vod object wasn't provided to the builder, the object is fetched from the database. +// OldSub returns the old "sub" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldExtID(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldSub(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldExtID is only allowed on UpdateOne operations") + return v, errors.New("OldSub is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldExtID requires an ID field in the mutation") + return v, errors.New("OldSub requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldExtID: %w", err) + return v, fmt.Errorf("querying old value for OldSub: %w", err) } - return oldValue.ExtID, nil + return oldValue.Sub, nil } -// ResetExtID resets all changes to the "ext_id" field. -func (m *VodMutation) ResetExtID() { - m.ext_id = nil +// ClearSub clears the value of the "sub" field. +func (m *UserMutation) ClearSub() { + m.sub = nil + m.clearedFields[user.FieldSub] = struct{}{} } -// SetExtStreamID sets the "ext_stream_id" field. -func (m *VodMutation) SetExtStreamID(s string) { - m.ext_stream_id = &s +// SubCleared returns if the "sub" field was cleared in this mutation. +func (m *UserMutation) SubCleared() bool { + _, ok := m.clearedFields[user.FieldSub] + return ok } -// ExtStreamID returns the value of the "ext_stream_id" field in the mutation. -func (m *VodMutation) ExtStreamID() (r string, exists bool) { - v := m.ext_stream_id +// ResetSub resets all changes to the "sub" field. +func (m *UserMutation) ResetSub() { + m.sub = nil + delete(m.clearedFields, user.FieldSub) +} + +// SetUsername sets the "username" field. +func (m *UserMutation) SetUsername(s string) { + m.username = &s +} + +// Username returns the value of the "username" field in the mutation. +func (m *UserMutation) Username() (r string, exists bool) { + v := m.username if v == nil { return } return *v, true } -// OldExtStreamID returns the old "ext_stream_id" field's value of the Vod entity. -// If the Vod object wasn't provided to the builder, the object is fetched from the database. +// OldUsername returns the old "username" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldExtStreamID(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldExtStreamID is only allowed on UpdateOne operations") + return v, errors.New("OldUsername is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldExtStreamID requires an ID field in the mutation") + return v, errors.New("OldUsername requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldExtStreamID: %w", err) + return v, fmt.Errorf("querying old value for OldUsername: %w", err) } - return oldValue.ExtStreamID, nil + return oldValue.Username, nil } -// ClearExtStreamID clears the value of the "ext_stream_id" field. -func (m *VodMutation) ClearExtStreamID() { - m.ext_stream_id = nil - m.clearedFields[vod.FieldExtStreamID] = struct{}{} +// ResetUsername resets all changes to the "username" field. +func (m *UserMutation) ResetUsername() { + m.username = nil } -// ExtStreamIDCleared returns if the "ext_stream_id" field was cleared in this mutation. -func (m *VodMutation) ExtStreamIDCleared() bool { - _, ok := m.clearedFields[vod.FieldExtStreamID] - return ok +// SetPassword sets the "password" field. +func (m *UserMutation) SetPassword(s string) { + m.password = &s } -// ResetExtStreamID resets all changes to the "ext_stream_id" field. -func (m *VodMutation) ResetExtStreamID() { - m.ext_stream_id = nil - delete(m.clearedFields, vod.FieldExtStreamID) +// Password returns the value of the "password" field in the mutation. +func (m *UserMutation) Password() (r string, exists bool) { + v := m.password + if v == nil { + return + } + return *v, true +} + +// OldPassword returns the old "password" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldPassword(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPassword is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPassword requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPassword: %w", err) + } + return oldValue.Password, nil +} + +// ClearPassword clears the value of the "password" field. +func (m *UserMutation) ClearPassword() { + m.password = nil + m.clearedFields[user.FieldPassword] = struct{}{} +} + +// PasswordCleared returns if the "password" field was cleared in this mutation. +func (m *UserMutation) PasswordCleared() bool { + _, ok := m.clearedFields[user.FieldPassword] + return ok +} + +// ResetPassword resets all changes to the "password" field. +func (m *UserMutation) ResetPassword() { + m.password = nil + delete(m.clearedFields, user.FieldPassword) +} + +// SetOauth sets the "oauth" field. +func (m *UserMutation) SetOauth(b bool) { + m.oauth = &b +} + +// Oauth returns the value of the "oauth" field in the mutation. +func (m *UserMutation) Oauth() (r bool, exists bool) { + v := m.oauth + if v == nil { + return + } + return *v, true +} + +// OldOauth returns the old "oauth" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldOauth(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOauth is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOauth requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOauth: %w", err) + } + return oldValue.Oauth, nil +} + +// ResetOauth resets all changes to the "oauth" field. +func (m *UserMutation) ResetOauth() { + m.oauth = nil +} + +// SetRole sets the "role" field. +func (m *UserMutation) SetRole(u utils.Role) { + m.role = &u +} + +// Role returns the value of the "role" field in the mutation. +func (m *UserMutation) Role() (r utils.Role, exists bool) { + v := m.role + if v == nil { + return + } + return *v, true +} + +// OldRole returns the old "role" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldRole(ctx context.Context) (v utils.Role, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRole is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRole requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRole: %w", err) + } + return oldValue.Role, nil +} + +// ResetRole resets all changes to the "role" field. +func (m *UserMutation) ResetRole() { + m.role = nil +} + +// SetWebhook sets the "webhook" field. +func (m *UserMutation) SetWebhook(s string) { + m.webhook = &s +} + +// Webhook returns the value of the "webhook" field in the mutation. +func (m *UserMutation) Webhook() (r string, exists bool) { + v := m.webhook + if v == nil { + return + } + return *v, true +} + +// OldWebhook returns the old "webhook" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldWebhook(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldWebhook is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldWebhook requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWebhook: %w", err) + } + return oldValue.Webhook, nil +} + +// ClearWebhook clears the value of the "webhook" field. +func (m *UserMutation) ClearWebhook() { + m.webhook = nil + m.clearedFields[user.FieldWebhook] = struct{}{} +} + +// WebhookCleared returns if the "webhook" field was cleared in this mutation. +func (m *UserMutation) WebhookCleared() bool { + _, ok := m.clearedFields[user.FieldWebhook] + return ok +} + +// ResetWebhook resets all changes to the "webhook" field. +func (m *UserMutation) ResetWebhook() { + m.webhook = nil + delete(m.clearedFields, user.FieldWebhook) +} + +// SetUpdatedAt sets the "updated_at" field. +func (m *UserMutation) SetUpdatedAt(t time.Time) { + m.updated_at = &t +} + +// UpdatedAt returns the value of the "updated_at" field in the mutation. +func (m *UserMutation) UpdatedAt() (r time.Time, exists bool) { + v := m.updated_at + if v == nil { + return + } + return *v, true +} + +// OldUpdatedAt returns the old "updated_at" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err) + } + return oldValue.UpdatedAt, nil +} + +// ResetUpdatedAt resets all changes to the "updated_at" field. +func (m *UserMutation) ResetUpdatedAt() { + m.updated_at = nil +} + +// SetCreatedAt sets the "created_at" field. +func (m *UserMutation) SetCreatedAt(t time.Time) { + m.created_at = &t +} + +// CreatedAt returns the value of the "created_at" field in the mutation. +func (m *UserMutation) CreatedAt() (r time.Time, exists bool) { + v := m.created_at + if v == nil { + return + } + return *v, true +} + +// OldCreatedAt returns the old "created_at" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreatedAt requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err) + } + return oldValue.CreatedAt, nil +} + +// ResetCreatedAt resets all changes to the "created_at" field. +func (m *UserMutation) ResetCreatedAt() { + m.created_at = nil +} + +// Where appends a list predicates to the UserMutation builder. +func (m *UserMutation) Where(ps ...predicate.User) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the UserMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.User, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *UserMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *UserMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (User). +func (m *UserMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *UserMutation) Fields() []string { + fields := make([]string, 0, 8) + if m.sub != nil { + fields = append(fields, user.FieldSub) + } + if m.username != nil { + fields = append(fields, user.FieldUsername) + } + if m.password != nil { + fields = append(fields, user.FieldPassword) + } + if m.oauth != nil { + fields = append(fields, user.FieldOauth) + } + if m.role != nil { + fields = append(fields, user.FieldRole) + } + if m.webhook != nil { + fields = append(fields, user.FieldWebhook) + } + if m.updated_at != nil { + fields = append(fields, user.FieldUpdatedAt) + } + if m.created_at != nil { + fields = append(fields, user.FieldCreatedAt) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *UserMutation) Field(name string) (ent.Value, bool) { + switch name { + case user.FieldSub: + return m.Sub() + case user.FieldUsername: + return m.Username() + case user.FieldPassword: + return m.Password() + case user.FieldOauth: + return m.Oauth() + case user.FieldRole: + return m.Role() + case user.FieldWebhook: + return m.Webhook() + case user.FieldUpdatedAt: + return m.UpdatedAt() + case user.FieldCreatedAt: + return m.CreatedAt() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case user.FieldSub: + return m.OldSub(ctx) + case user.FieldUsername: + return m.OldUsername(ctx) + case user.FieldPassword: + return m.OldPassword(ctx) + case user.FieldOauth: + return m.OldOauth(ctx) + case user.FieldRole: + return m.OldRole(ctx) + case user.FieldWebhook: + return m.OldWebhook(ctx) + case user.FieldUpdatedAt: + return m.OldUpdatedAt(ctx) + case user.FieldCreatedAt: + return m.OldCreatedAt(ctx) + } + return nil, fmt.Errorf("unknown User field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserMutation) SetField(name string, value ent.Value) error { + switch name { + case user.FieldSub: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSub(v) + return nil + case user.FieldUsername: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUsername(v) + return nil + case user.FieldPassword: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPassword(v) + return nil + case user.FieldOauth: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOauth(v) + return nil + case user.FieldRole: + v, ok := value.(utils.Role) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRole(v) + return nil + case user.FieldWebhook: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetWebhook(v) + return nil + case user.FieldUpdatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdatedAt(v) + return nil + case user.FieldCreatedAt: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreatedAt(v) + return nil + } + return fmt.Errorf("unknown User field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *UserMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown User numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(user.FieldSub) { + fields = append(fields, user.FieldSub) + } + if m.FieldCleared(user.FieldPassword) { + fields = append(fields, user.FieldPassword) + } + if m.FieldCleared(user.FieldWebhook) { + fields = append(fields, user.FieldWebhook) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *UserMutation) ClearField(name string) error { + switch name { + case user.FieldSub: + m.ClearSub() + return nil + case user.FieldPassword: + m.ClearPassword() + return nil + case user.FieldWebhook: + m.ClearWebhook() + return nil + } + return fmt.Errorf("unknown User nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *UserMutation) ResetField(name string) error { + switch name { + case user.FieldSub: + m.ResetSub() + return nil + case user.FieldUsername: + m.ResetUsername() + return nil + case user.FieldPassword: + m.ResetPassword() + return nil + case user.FieldOauth: + m.ResetOauth() + return nil + case user.FieldRole: + m.ResetRole() + return nil + case user.FieldWebhook: + m.ResetWebhook() + return nil + case user.FieldUpdatedAt: + m.ResetUpdatedAt() + return nil + case user.FieldCreatedAt: + m.ResetCreatedAt() + return nil + } + return fmt.Errorf("unknown User field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UserMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UserMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UserMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *UserMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UserMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UserMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *UserMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown User unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *UserMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown User edge %s", name) +} + +// VodMutation represents an operation that mutates the Vod nodes in the graph. +type VodMutation struct { + config + op Op + typ string + id *uuid.UUID + ext_id *string + clip_ext_vod_id *string + ext_stream_id *string + platform *utils.VideoPlatform + _type *utils.VodType + title *string + duration *int + addduration *int + clip_vod_offset *int + addclip_vod_offset *int + views *int + addviews *int + resolution *string + processing *bool + thumbnail_path *string + web_thumbnail_path *string + video_path *string + video_hls_path *string + chat_path *string + live_chat_path *string + live_chat_convert_path *string + chat_video_path *string + info_path *string + caption_path *string + folder_name *string + file_name *string + tmp_video_download_path *string + tmp_video_convert_path *string + tmp_chat_download_path *string + tmp_live_chat_download_path *string + tmp_live_chat_convert_path *string + tmp_chat_render_path *string + tmp_video_hls_path *string + locked *bool + local_views *int + addlocal_views *int + sprite_thumbnails_enabled *bool + sprite_thumbnails_images *[]string + appendsprite_thumbnails_images []string + sprite_thumbnails_interval *int + addsprite_thumbnails_interval *int + sprite_thumbnails_width *int + addsprite_thumbnails_width *int + sprite_thumbnails_height *int + addsprite_thumbnails_height *int + sprite_thumbnails_rows *int + addsprite_thumbnails_rows *int + sprite_thumbnails_columns *int + addsprite_thumbnails_columns *int + streamed_at *time.Time + updated_at *time.Time + created_at *time.Time + clearedFields map[string]struct{} + channel *uuid.UUID + clearedchannel bool + queue *uuid.UUID + clearedqueue bool + playlists map[uuid.UUID]struct{} + removedplaylists map[uuid.UUID]struct{} + clearedplaylists bool + chapters map[uuid.UUID]struct{} + removedchapters map[uuid.UUID]struct{} + clearedchapters bool + muted_segments map[uuid.UUID]struct{} + removedmuted_segments map[uuid.UUID]struct{} + clearedmuted_segments bool + multistream_info map[int]struct{} + removedmultistream_info map[int]struct{} + clearedmultistream_info bool + done bool + oldValue func(context.Context) (*Vod, error) + predicates []predicate.Vod +} + +var _ ent.Mutation = (*VodMutation)(nil) + +// vodOption allows management of the mutation configuration using functional options. +type vodOption func(*VodMutation) + +// newVodMutation creates new mutation for the Vod entity. +func newVodMutation(c config, op Op, opts ...vodOption) *VodMutation { + m := &VodMutation{ + config: c, + op: op, + typ: TypeVod, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withVodID sets the ID field of the mutation. +func withVodID(id uuid.UUID) vodOption { + return func(m *VodMutation) { + var ( + err error + once sync.Once + value *Vod + ) + m.oldValue = func(ctx context.Context) (*Vod, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Vod.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withVod sets the old Vod of the mutation. +func withVod(node *Vod) vodOption { + return func(m *VodMutation) { + m.oldValue = func(context.Context) (*Vod, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m VodMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m VodMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Vod entities. +func (m *VodMutation) SetID(id uuid.UUID) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *VodMutation) ID() (id uuid.UUID, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *VodMutation) IDs(ctx context.Context) ([]uuid.UUID, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []uuid.UUID{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Vod.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetExtID sets the "ext_id" field. +func (m *VodMutation) SetExtID(s string) { + m.ext_id = &s +} + +// ExtID returns the value of the "ext_id" field in the mutation. +func (m *VodMutation) ExtID() (r string, exists bool) { + v := m.ext_id + if v == nil { + return + } + return *v, true +} + +// OldExtID returns the old "ext_id" field's value of the Vod entity. +// If the Vod object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *VodMutation) OldExtID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldExtID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldExtID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldExtID: %w", err) + } + return oldValue.ExtID, nil +} + +// ResetExtID resets all changes to the "ext_id" field. +func (m *VodMutation) ResetExtID() { + m.ext_id = nil +} + +// SetClipExtVodID sets the "clip_ext_vod_id" field. +func (m *VodMutation) SetClipExtVodID(s string) { + m.clip_ext_vod_id = &s +} + +// ClipExtVodID returns the value of the "clip_ext_vod_id" field in the mutation. +func (m *VodMutation) ClipExtVodID() (r string, exists bool) { + v := m.clip_ext_vod_id + if v == nil { + return + } + return *v, true +} + +// OldClipExtVodID returns the old "clip_ext_vod_id" field's value of the Vod entity. +// If the Vod object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *VodMutation) OldClipExtVodID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldClipExtVodID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldClipExtVodID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldClipExtVodID: %w", err) + } + return oldValue.ClipExtVodID, nil +} + +// ClearClipExtVodID clears the value of the "clip_ext_vod_id" field. +func (m *VodMutation) ClearClipExtVodID() { + m.clip_ext_vod_id = nil + m.clearedFields[vod.FieldClipExtVodID] = struct{}{} +} + +// ClipExtVodIDCleared returns if the "clip_ext_vod_id" field was cleared in this mutation. +func (m *VodMutation) ClipExtVodIDCleared() bool { + _, ok := m.clearedFields[vod.FieldClipExtVodID] + return ok +} + +// ResetClipExtVodID resets all changes to the "clip_ext_vod_id" field. +func (m *VodMutation) ResetClipExtVodID() { + m.clip_ext_vod_id = nil + delete(m.clearedFields, vod.FieldClipExtVodID) +} + +// SetExtStreamID sets the "ext_stream_id" field. +func (m *VodMutation) SetExtStreamID(s string) { + m.ext_stream_id = &s +} + +// ExtStreamID returns the value of the "ext_stream_id" field in the mutation. +func (m *VodMutation) ExtStreamID() (r string, exists bool) { + v := m.ext_stream_id + if v == nil { + return + } + return *v, true +} + +// OldExtStreamID returns the old "ext_stream_id" field's value of the Vod entity. +// If the Vod object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *VodMutation) OldExtStreamID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldExtStreamID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldExtStreamID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldExtStreamID: %w", err) + } + return oldValue.ExtStreamID, nil +} + +// ClearExtStreamID clears the value of the "ext_stream_id" field. +func (m *VodMutation) ClearExtStreamID() { + m.ext_stream_id = nil + m.clearedFields[vod.FieldExtStreamID] = struct{}{} +} + +// ExtStreamIDCleared returns if the "ext_stream_id" field was cleared in this mutation. +func (m *VodMutation) ExtStreamIDCleared() bool { + _, ok := m.clearedFields[vod.FieldExtStreamID] + return ok +} + +// ResetExtStreamID resets all changes to the "ext_stream_id" field. +func (m *VodMutation) ResetExtStreamID() { + m.ext_stream_id = nil + delete(m.clearedFields, vod.FieldExtStreamID) +} + +// SetPlatform sets the "platform" field. +func (m *VodMutation) SetPlatform(up utils.VideoPlatform) { + m.platform = &up +} + +// Platform returns the value of the "platform" field in the mutation. +func (m *VodMutation) Platform() (r utils.VideoPlatform, exists bool) { + v := m.platform + if v == nil { + return + } + return *v, true +} + +// OldPlatform returns the old "platform" field's value of the Vod entity. +// If the Vod object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *VodMutation) OldPlatform(ctx context.Context) (v utils.VideoPlatform, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPlatform is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPlatform requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPlatform: %w", err) + } + return oldValue.Platform, nil +} + +// ResetPlatform resets all changes to the "platform" field. +func (m *VodMutation) ResetPlatform() { + m.platform = nil +} + +// SetType sets the "type" field. +func (m *VodMutation) SetType(ut utils.VodType) { + m._type = &ut +} + +// GetType returns the value of the "type" field in the mutation. +func (m *VodMutation) GetType() (r utils.VodType, exists bool) { + v := m._type + if v == nil { + return + } + return *v, true +} + +// OldType returns the old "type" field's value of the Vod entity. +// If the Vod object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *VodMutation) OldType(ctx context.Context) (v utils.VodType, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) + } + return oldValue.Type, nil +} + +// ResetType resets all changes to the "type" field. +func (m *VodMutation) ResetType() { + m._type = nil +} + +// SetTitle sets the "title" field. +func (m *VodMutation) SetTitle(s string) { + m.title = &s +} + +// Title returns the value of the "title" field in the mutation. +func (m *VodMutation) Title() (r string, exists bool) { + v := m.title + if v == nil { + return + } + return *v, true +} + +// OldTitle returns the old "title" field's value of the Vod entity. +// If the Vod object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *VodMutation) OldTitle(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTitle is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTitle requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTitle: %w", err) + } + return oldValue.Title, nil +} + +// ResetTitle resets all changes to the "title" field. +func (m *VodMutation) ResetTitle() { + m.title = nil +} + +// SetDuration sets the "duration" field. +func (m *VodMutation) SetDuration(i int) { + m.duration = &i + m.addduration = nil +} + +// Duration returns the value of the "duration" field in the mutation. +func (m *VodMutation) Duration() (r int, exists bool) { + v := m.duration + if v == nil { + return + } + return *v, true +} + +// OldDuration returns the old "duration" field's value of the Vod entity. +// If the Vod object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *VodMutation) OldDuration(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDuration is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDuration requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDuration: %w", err) + } + return oldValue.Duration, nil +} + +// AddDuration adds i to the "duration" field. +func (m *VodMutation) AddDuration(i int) { + if m.addduration != nil { + *m.addduration += i + } else { + m.addduration = &i + } +} + +// AddedDuration returns the value that was added to the "duration" field in this mutation. +func (m *VodMutation) AddedDuration() (r int, exists bool) { + v := m.addduration + if v == nil { + return + } + return *v, true +} + +// ResetDuration resets all changes to the "duration" field. +func (m *VodMutation) ResetDuration() { + m.duration = nil + m.addduration = nil +} + +// SetClipVodOffset sets the "clip_vod_offset" field. +func (m *VodMutation) SetClipVodOffset(i int) { + m.clip_vod_offset = &i + m.addclip_vod_offset = nil +} + +// ClipVodOffset returns the value of the "clip_vod_offset" field in the mutation. +func (m *VodMutation) ClipVodOffset() (r int, exists bool) { + v := m.clip_vod_offset + if v == nil { + return + } + return *v, true +} + +// OldClipVodOffset returns the old "clip_vod_offset" field's value of the Vod entity. +// If the Vod object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *VodMutation) OldClipVodOffset(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldClipVodOffset is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldClipVodOffset requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldClipVodOffset: %w", err) + } + return oldValue.ClipVodOffset, nil +} + +// AddClipVodOffset adds i to the "clip_vod_offset" field. +func (m *VodMutation) AddClipVodOffset(i int) { + if m.addclip_vod_offset != nil { + *m.addclip_vod_offset += i + } else { + m.addclip_vod_offset = &i + } +} + +// AddedClipVodOffset returns the value that was added to the "clip_vod_offset" field in this mutation. +func (m *VodMutation) AddedClipVodOffset() (r int, exists bool) { + v := m.addclip_vod_offset + if v == nil { + return + } + return *v, true +} + +// ClearClipVodOffset clears the value of the "clip_vod_offset" field. +func (m *VodMutation) ClearClipVodOffset() { + m.clip_vod_offset = nil + m.addclip_vod_offset = nil + m.clearedFields[vod.FieldClipVodOffset] = struct{}{} +} + +// ClipVodOffsetCleared returns if the "clip_vod_offset" field was cleared in this mutation. +func (m *VodMutation) ClipVodOffsetCleared() bool { + _, ok := m.clearedFields[vod.FieldClipVodOffset] + return ok +} + +// ResetClipVodOffset resets all changes to the "clip_vod_offset" field. +func (m *VodMutation) ResetClipVodOffset() { + m.clip_vod_offset = nil + m.addclip_vod_offset = nil + delete(m.clearedFields, vod.FieldClipVodOffset) +} + +// SetViews sets the "views" field. +func (m *VodMutation) SetViews(i int) { + m.views = &i + m.addviews = nil +} + +// Views returns the value of the "views" field in the mutation. +func (m *VodMutation) Views() (r int, exists bool) { + v := m.views + if v == nil { + return + } + return *v, true +} + +// OldViews returns the old "views" field's value of the Vod entity. +// If the Vod object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *VodMutation) OldViews(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldViews is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldViews requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldViews: %w", err) + } + return oldValue.Views, nil +} + +// AddViews adds i to the "views" field. +func (m *VodMutation) AddViews(i int) { + if m.addviews != nil { + *m.addviews += i + } else { + m.addviews = &i + } +} + +// AddedViews returns the value that was added to the "views" field in this mutation. +func (m *VodMutation) AddedViews() (r int, exists bool) { + v := m.addviews + if v == nil { + return + } + return *v, true +} + +// ResetViews resets all changes to the "views" field. +func (m *VodMutation) ResetViews() { + m.views = nil + m.addviews = nil +} + +// SetResolution sets the "resolution" field. +func (m *VodMutation) SetResolution(s string) { + m.resolution = &s +} + +// Resolution returns the value of the "resolution" field in the mutation. +func (m *VodMutation) Resolution() (r string, exists bool) { + v := m.resolution + if v == nil { + return + } + return *v, true +} + +// OldResolution returns the old "resolution" field's value of the Vod entity. +// If the Vod object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *VodMutation) OldResolution(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldResolution is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldResolution requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldResolution: %w", err) + } + return oldValue.Resolution, nil +} + +// ClearResolution clears the value of the "resolution" field. +func (m *VodMutation) ClearResolution() { + m.resolution = nil + m.clearedFields[vod.FieldResolution] = struct{}{} +} + +// ResolutionCleared returns if the "resolution" field was cleared in this mutation. +func (m *VodMutation) ResolutionCleared() bool { + _, ok := m.clearedFields[vod.FieldResolution] + return ok +} + +// ResetResolution resets all changes to the "resolution" field. +func (m *VodMutation) ResetResolution() { + m.resolution = nil + delete(m.clearedFields, vod.FieldResolution) +} + +// SetProcessing sets the "processing" field. +func (m *VodMutation) SetProcessing(b bool) { + m.processing = &b +} + +// Processing returns the value of the "processing" field in the mutation. +func (m *VodMutation) Processing() (r bool, exists bool) { + v := m.processing + if v == nil { + return + } + return *v, true +} + +// OldProcessing returns the old "processing" field's value of the Vod entity. +// If the Vod object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *VodMutation) OldProcessing(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldProcessing is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldProcessing requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldProcessing: %w", err) + } + return oldValue.Processing, nil +} + +// ResetProcessing resets all changes to the "processing" field. +func (m *VodMutation) ResetProcessing() { + m.processing = nil } -// SetPlatform sets the "platform" field. -func (m *VodMutation) SetPlatform(up utils.VideoPlatform) { - m.platform = &up +// SetThumbnailPath sets the "thumbnail_path" field. +func (m *VodMutation) SetThumbnailPath(s string) { + m.thumbnail_path = &s } -// Platform returns the value of the "platform" field in the mutation. -func (m *VodMutation) Platform() (r utils.VideoPlatform, exists bool) { - v := m.platform +// ThumbnailPath returns the value of the "thumbnail_path" field in the mutation. +func (m *VodMutation) ThumbnailPath() (r string, exists bool) { + v := m.thumbnail_path if v == nil { return } return *v, true } -// OldPlatform returns the old "platform" field's value of the Vod entity. +// OldThumbnailPath returns the old "thumbnail_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldPlatform(ctx context.Context) (v utils.VideoPlatform, err error) { +func (m *VodMutation) OldThumbnailPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPlatform is only allowed on UpdateOne operations") + return v, errors.New("OldThumbnailPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPlatform requires an ID field in the mutation") + return v, errors.New("OldThumbnailPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPlatform: %w", err) + return v, fmt.Errorf("querying old value for OldThumbnailPath: %w", err) } - return oldValue.Platform, nil + return oldValue.ThumbnailPath, nil } -// ResetPlatform resets all changes to the "platform" field. -func (m *VodMutation) ResetPlatform() { - m.platform = nil +// ClearThumbnailPath clears the value of the "thumbnail_path" field. +func (m *VodMutation) ClearThumbnailPath() { + m.thumbnail_path = nil + m.clearedFields[vod.FieldThumbnailPath] = struct{}{} } -// SetType sets the "type" field. -func (m *VodMutation) SetType(ut utils.VodType) { - m._type = &ut +// ThumbnailPathCleared returns if the "thumbnail_path" field was cleared in this mutation. +func (m *VodMutation) ThumbnailPathCleared() bool { + _, ok := m.clearedFields[vod.FieldThumbnailPath] + return ok } -// GetType returns the value of the "type" field in the mutation. -func (m *VodMutation) GetType() (r utils.VodType, exists bool) { - v := m._type +// ResetThumbnailPath resets all changes to the "thumbnail_path" field. +func (m *VodMutation) ResetThumbnailPath() { + m.thumbnail_path = nil + delete(m.clearedFields, vod.FieldThumbnailPath) +} + +// SetWebThumbnailPath sets the "web_thumbnail_path" field. +func (m *VodMutation) SetWebThumbnailPath(s string) { + m.web_thumbnail_path = &s +} + +// WebThumbnailPath returns the value of the "web_thumbnail_path" field in the mutation. +func (m *VodMutation) WebThumbnailPath() (r string, exists bool) { + v := m.web_thumbnail_path if v == nil { return } return *v, true } -// OldType returns the old "type" field's value of the Vod entity. +// OldWebThumbnailPath returns the old "web_thumbnail_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldType(ctx context.Context) (v utils.VodType, err error) { +func (m *VodMutation) OldWebThumbnailPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldType is only allowed on UpdateOne operations") + return v, errors.New("OldWebThumbnailPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldType requires an ID field in the mutation") + return v, errors.New("OldWebThumbnailPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldType: %w", err) + return v, fmt.Errorf("querying old value for OldWebThumbnailPath: %w", err) } - return oldValue.Type, nil + return oldValue.WebThumbnailPath, nil } -// ResetType resets all changes to the "type" field. -func (m *VodMutation) ResetType() { - m._type = nil +// ResetWebThumbnailPath resets all changes to the "web_thumbnail_path" field. +func (m *VodMutation) ResetWebThumbnailPath() { + m.web_thumbnail_path = nil } -// SetTitle sets the "title" field. -func (m *VodMutation) SetTitle(s string) { - m.title = &s +// SetVideoPath sets the "video_path" field. +func (m *VodMutation) SetVideoPath(s string) { + m.video_path = &s } -// Title returns the value of the "title" field in the mutation. -func (m *VodMutation) Title() (r string, exists bool) { - v := m.title +// VideoPath returns the value of the "video_path" field in the mutation. +func (m *VodMutation) VideoPath() (r string, exists bool) { + v := m.video_path if v == nil { return } return *v, true } -// OldTitle returns the old "title" field's value of the Vod entity. +// OldVideoPath returns the old "video_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldTitle(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldVideoPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTitle is only allowed on UpdateOne operations") + return v, errors.New("OldVideoPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTitle requires an ID field in the mutation") + return v, errors.New("OldVideoPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTitle: %w", err) + return v, fmt.Errorf("querying old value for OldVideoPath: %w", err) } - return oldValue.Title, nil + return oldValue.VideoPath, nil } -// ResetTitle resets all changes to the "title" field. -func (m *VodMutation) ResetTitle() { - m.title = nil +// ResetVideoPath resets all changes to the "video_path" field. +func (m *VodMutation) ResetVideoPath() { + m.video_path = nil } -// SetDuration sets the "duration" field. -func (m *VodMutation) SetDuration(i int) { - m.duration = &i - m.addduration = nil +// SetVideoHlsPath sets the "video_hls_path" field. +func (m *VodMutation) SetVideoHlsPath(s string) { + m.video_hls_path = &s } -// Duration returns the value of the "duration" field in the mutation. -func (m *VodMutation) Duration() (r int, exists bool) { - v := m.duration +// VideoHlsPath returns the value of the "video_hls_path" field in the mutation. +func (m *VodMutation) VideoHlsPath() (r string, exists bool) { + v := m.video_hls_path if v == nil { return } return *v, true } -// OldDuration returns the old "duration" field's value of the Vod entity. +// OldVideoHlsPath returns the old "video_hls_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldDuration(ctx context.Context) (v int, err error) { +func (m *VodMutation) OldVideoHlsPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDuration is only allowed on UpdateOne operations") + return v, errors.New("OldVideoHlsPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDuration requires an ID field in the mutation") + return v, errors.New("OldVideoHlsPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDuration: %w", err) + return v, fmt.Errorf("querying old value for OldVideoHlsPath: %w", err) } - return oldValue.Duration, nil + return oldValue.VideoHlsPath, nil } -// AddDuration adds i to the "duration" field. -func (m *VodMutation) AddDuration(i int) { - if m.addduration != nil { - *m.addduration += i - } else { - m.addduration = &i - } +// ClearVideoHlsPath clears the value of the "video_hls_path" field. +func (m *VodMutation) ClearVideoHlsPath() { + m.video_hls_path = nil + m.clearedFields[vod.FieldVideoHlsPath] = struct{}{} } -// AddedDuration returns the value that was added to the "duration" field in this mutation. -func (m *VodMutation) AddedDuration() (r int, exists bool) { - v := m.addduration - if v == nil { - return - } - return *v, true +// VideoHlsPathCleared returns if the "video_hls_path" field was cleared in this mutation. +func (m *VodMutation) VideoHlsPathCleared() bool { + _, ok := m.clearedFields[vod.FieldVideoHlsPath] + return ok } -// ResetDuration resets all changes to the "duration" field. -func (m *VodMutation) ResetDuration() { - m.duration = nil - m.addduration = nil +// ResetVideoHlsPath resets all changes to the "video_hls_path" field. +func (m *VodMutation) ResetVideoHlsPath() { + m.video_hls_path = nil + delete(m.clearedFields, vod.FieldVideoHlsPath) } -// SetViews sets the "views" field. -func (m *VodMutation) SetViews(i int) { - m.views = &i - m.addviews = nil +// SetChatPath sets the "chat_path" field. +func (m *VodMutation) SetChatPath(s string) { + m.chat_path = &s } -// Views returns the value of the "views" field in the mutation. -func (m *VodMutation) Views() (r int, exists bool) { - v := m.views +// ChatPath returns the value of the "chat_path" field in the mutation. +func (m *VodMutation) ChatPath() (r string, exists bool) { + v := m.chat_path if v == nil { return } return *v, true } -// OldViews returns the old "views" field's value of the Vod entity. +// OldChatPath returns the old "chat_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldViews(ctx context.Context) (v int, err error) { +func (m *VodMutation) OldChatPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldViews is only allowed on UpdateOne operations") + return v, errors.New("OldChatPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldViews requires an ID field in the mutation") + return v, errors.New("OldChatPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldViews: %w", err) + return v, fmt.Errorf("querying old value for OldChatPath: %w", err) } - return oldValue.Views, nil + return oldValue.ChatPath, nil } -// AddViews adds i to the "views" field. -func (m *VodMutation) AddViews(i int) { - if m.addviews != nil { - *m.addviews += i - } else { - m.addviews = &i - } +// ClearChatPath clears the value of the "chat_path" field. +func (m *VodMutation) ClearChatPath() { + m.chat_path = nil + m.clearedFields[vod.FieldChatPath] = struct{}{} } -// AddedViews returns the value that was added to the "views" field in this mutation. -func (m *VodMutation) AddedViews() (r int, exists bool) { - v := m.addviews - if v == nil { - return - } - return *v, true +// ChatPathCleared returns if the "chat_path" field was cleared in this mutation. +func (m *VodMutation) ChatPathCleared() bool { + _, ok := m.clearedFields[vod.FieldChatPath] + return ok } -// ResetViews resets all changes to the "views" field. -func (m *VodMutation) ResetViews() { - m.views = nil - m.addviews = nil +// ResetChatPath resets all changes to the "chat_path" field. +func (m *VodMutation) ResetChatPath() { + m.chat_path = nil + delete(m.clearedFields, vod.FieldChatPath) } -// SetResolution sets the "resolution" field. -func (m *VodMutation) SetResolution(s string) { - m.resolution = &s +// SetLiveChatPath sets the "live_chat_path" field. +func (m *VodMutation) SetLiveChatPath(s string) { + m.live_chat_path = &s } -// Resolution returns the value of the "resolution" field in the mutation. -func (m *VodMutation) Resolution() (r string, exists bool) { - v := m.resolution +// LiveChatPath returns the value of the "live_chat_path" field in the mutation. +func (m *VodMutation) LiveChatPath() (r string, exists bool) { + v := m.live_chat_path if v == nil { return } return *v, true } -// OldResolution returns the old "resolution" field's value of the Vod entity. +// OldLiveChatPath returns the old "live_chat_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldResolution(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldLiveChatPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldResolution is only allowed on UpdateOne operations") + return v, errors.New("OldLiveChatPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldResolution requires an ID field in the mutation") + return v, errors.New("OldLiveChatPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldResolution: %w", err) + return v, fmt.Errorf("querying old value for OldLiveChatPath: %w", err) } - return oldValue.Resolution, nil + return oldValue.LiveChatPath, nil } -// ClearResolution clears the value of the "resolution" field. -func (m *VodMutation) ClearResolution() { - m.resolution = nil - m.clearedFields[vod.FieldResolution] = struct{}{} +// ClearLiveChatPath clears the value of the "live_chat_path" field. +func (m *VodMutation) ClearLiveChatPath() { + m.live_chat_path = nil + m.clearedFields[vod.FieldLiveChatPath] = struct{}{} } -// ResolutionCleared returns if the "resolution" field was cleared in this mutation. -func (m *VodMutation) ResolutionCleared() bool { - _, ok := m.clearedFields[vod.FieldResolution] +// LiveChatPathCleared returns if the "live_chat_path" field was cleared in this mutation. +func (m *VodMutation) LiveChatPathCleared() bool { + _, ok := m.clearedFields[vod.FieldLiveChatPath] return ok } -// ResetResolution resets all changes to the "resolution" field. -func (m *VodMutation) ResetResolution() { - m.resolution = nil - delete(m.clearedFields, vod.FieldResolution) +// ResetLiveChatPath resets all changes to the "live_chat_path" field. +func (m *VodMutation) ResetLiveChatPath() { + m.live_chat_path = nil + delete(m.clearedFields, vod.FieldLiveChatPath) } -// SetProcessing sets the "processing" field. -func (m *VodMutation) SetProcessing(b bool) { - m.processing = &b +// SetLiveChatConvertPath sets the "live_chat_convert_path" field. +func (m *VodMutation) SetLiveChatConvertPath(s string) { + m.live_chat_convert_path = &s } -// Processing returns the value of the "processing" field in the mutation. -func (m *VodMutation) Processing() (r bool, exists bool) { - v := m.processing +// LiveChatConvertPath returns the value of the "live_chat_convert_path" field in the mutation. +func (m *VodMutation) LiveChatConvertPath() (r string, exists bool) { + v := m.live_chat_convert_path if v == nil { return } return *v, true } -// OldProcessing returns the old "processing" field's value of the Vod entity. +// OldLiveChatConvertPath returns the old "live_chat_convert_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldProcessing(ctx context.Context) (v bool, err error) { +func (m *VodMutation) OldLiveChatConvertPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldProcessing is only allowed on UpdateOne operations") + return v, errors.New("OldLiveChatConvertPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldProcessing requires an ID field in the mutation") + return v, errors.New("OldLiveChatConvertPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldProcessing: %w", err) + return v, fmt.Errorf("querying old value for OldLiveChatConvertPath: %w", err) } - return oldValue.Processing, nil + return oldValue.LiveChatConvertPath, nil } -// ResetProcessing resets all changes to the "processing" field. -func (m *VodMutation) ResetProcessing() { - m.processing = nil +// ClearLiveChatConvertPath clears the value of the "live_chat_convert_path" field. +func (m *VodMutation) ClearLiveChatConvertPath() { + m.live_chat_convert_path = nil + m.clearedFields[vod.FieldLiveChatConvertPath] = struct{}{} } -// SetThumbnailPath sets the "thumbnail_path" field. -func (m *VodMutation) SetThumbnailPath(s string) { - m.thumbnail_path = &s +// LiveChatConvertPathCleared returns if the "live_chat_convert_path" field was cleared in this mutation. +func (m *VodMutation) LiveChatConvertPathCleared() bool { + _, ok := m.clearedFields[vod.FieldLiveChatConvertPath] + return ok } -// ThumbnailPath returns the value of the "thumbnail_path" field in the mutation. -func (m *VodMutation) ThumbnailPath() (r string, exists bool) { - v := m.thumbnail_path +// ResetLiveChatConvertPath resets all changes to the "live_chat_convert_path" field. +func (m *VodMutation) ResetLiveChatConvertPath() { + m.live_chat_convert_path = nil + delete(m.clearedFields, vod.FieldLiveChatConvertPath) +} + +// SetChatVideoPath sets the "chat_video_path" field. +func (m *VodMutation) SetChatVideoPath(s string) { + m.chat_video_path = &s +} + +// ChatVideoPath returns the value of the "chat_video_path" field in the mutation. +func (m *VodMutation) ChatVideoPath() (r string, exists bool) { + v := m.chat_video_path if v == nil { return } return *v, true } -// OldThumbnailPath returns the old "thumbnail_path" field's value of the Vod entity. +// OldChatVideoPath returns the old "chat_video_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldThumbnailPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldChatVideoPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldThumbnailPath is only allowed on UpdateOne operations") + return v, errors.New("OldChatVideoPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldThumbnailPath requires an ID field in the mutation") + return v, errors.New("OldChatVideoPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldThumbnailPath: %w", err) + return v, fmt.Errorf("querying old value for OldChatVideoPath: %w", err) } - return oldValue.ThumbnailPath, nil + return oldValue.ChatVideoPath, nil } -// ClearThumbnailPath clears the value of the "thumbnail_path" field. -func (m *VodMutation) ClearThumbnailPath() { - m.thumbnail_path = nil - m.clearedFields[vod.FieldThumbnailPath] = struct{}{} +// ClearChatVideoPath clears the value of the "chat_video_path" field. +func (m *VodMutation) ClearChatVideoPath() { + m.chat_video_path = nil + m.clearedFields[vod.FieldChatVideoPath] = struct{}{} } -// ThumbnailPathCleared returns if the "thumbnail_path" field was cleared in this mutation. -func (m *VodMutation) ThumbnailPathCleared() bool { - _, ok := m.clearedFields[vod.FieldThumbnailPath] +// ChatVideoPathCleared returns if the "chat_video_path" field was cleared in this mutation. +func (m *VodMutation) ChatVideoPathCleared() bool { + _, ok := m.clearedFields[vod.FieldChatVideoPath] return ok } -// ResetThumbnailPath resets all changes to the "thumbnail_path" field. -func (m *VodMutation) ResetThumbnailPath() { - m.thumbnail_path = nil - delete(m.clearedFields, vod.FieldThumbnailPath) +// ResetChatVideoPath resets all changes to the "chat_video_path" field. +func (m *VodMutation) ResetChatVideoPath() { + m.chat_video_path = nil + delete(m.clearedFields, vod.FieldChatVideoPath) } -// SetWebThumbnailPath sets the "web_thumbnail_path" field. -func (m *VodMutation) SetWebThumbnailPath(s string) { - m.web_thumbnail_path = &s +// SetInfoPath sets the "info_path" field. +func (m *VodMutation) SetInfoPath(s string) { + m.info_path = &s } -// WebThumbnailPath returns the value of the "web_thumbnail_path" field in the mutation. -func (m *VodMutation) WebThumbnailPath() (r string, exists bool) { - v := m.web_thumbnail_path +// InfoPath returns the value of the "info_path" field in the mutation. +func (m *VodMutation) InfoPath() (r string, exists bool) { + v := m.info_path if v == nil { return } return *v, true } -// OldWebThumbnailPath returns the old "web_thumbnail_path" field's value of the Vod entity. +// OldInfoPath returns the old "info_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldWebThumbnailPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldInfoPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldWebThumbnailPath is only allowed on UpdateOne operations") + return v, errors.New("OldInfoPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldWebThumbnailPath requires an ID field in the mutation") + return v, errors.New("OldInfoPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldWebThumbnailPath: %w", err) + return v, fmt.Errorf("querying old value for OldInfoPath: %w", err) } - return oldValue.WebThumbnailPath, nil + return oldValue.InfoPath, nil } -// ResetWebThumbnailPath resets all changes to the "web_thumbnail_path" field. -func (m *VodMutation) ResetWebThumbnailPath() { - m.web_thumbnail_path = nil +// ClearInfoPath clears the value of the "info_path" field. +func (m *VodMutation) ClearInfoPath() { + m.info_path = nil + m.clearedFields[vod.FieldInfoPath] = struct{}{} } -// SetVideoPath sets the "video_path" field. -func (m *VodMutation) SetVideoPath(s string) { - m.video_path = &s +// InfoPathCleared returns if the "info_path" field was cleared in this mutation. +func (m *VodMutation) InfoPathCleared() bool { + _, ok := m.clearedFields[vod.FieldInfoPath] + return ok } -// VideoPath returns the value of the "video_path" field in the mutation. -func (m *VodMutation) VideoPath() (r string, exists bool) { - v := m.video_path +// ResetInfoPath resets all changes to the "info_path" field. +func (m *VodMutation) ResetInfoPath() { + m.info_path = nil + delete(m.clearedFields, vod.FieldInfoPath) +} + +// SetCaptionPath sets the "caption_path" field. +func (m *VodMutation) SetCaptionPath(s string) { + m.caption_path = &s +} + +// CaptionPath returns the value of the "caption_path" field in the mutation. +func (m *VodMutation) CaptionPath() (r string, exists bool) { + v := m.caption_path if v == nil { return } return *v, true } -// OldVideoPath returns the old "video_path" field's value of the Vod entity. +// OldCaptionPath returns the old "caption_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldVideoPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldCaptionPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVideoPath is only allowed on UpdateOne operations") + return v, errors.New("OldCaptionPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVideoPath requires an ID field in the mutation") + return v, errors.New("OldCaptionPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldVideoPath: %w", err) + return v, fmt.Errorf("querying old value for OldCaptionPath: %w", err) } - return oldValue.VideoPath, nil + return oldValue.CaptionPath, nil } -// ResetVideoPath resets all changes to the "video_path" field. -func (m *VodMutation) ResetVideoPath() { - m.video_path = nil +// ClearCaptionPath clears the value of the "caption_path" field. +func (m *VodMutation) ClearCaptionPath() { + m.caption_path = nil + m.clearedFields[vod.FieldCaptionPath] = struct{}{} } -// SetVideoHlsPath sets the "video_hls_path" field. -func (m *VodMutation) SetVideoHlsPath(s string) { - m.video_hls_path = &s +// CaptionPathCleared returns if the "caption_path" field was cleared in this mutation. +func (m *VodMutation) CaptionPathCleared() bool { + _, ok := m.clearedFields[vod.FieldCaptionPath] + return ok } -// VideoHlsPath returns the value of the "video_hls_path" field in the mutation. -func (m *VodMutation) VideoHlsPath() (r string, exists bool) { - v := m.video_hls_path +// ResetCaptionPath resets all changes to the "caption_path" field. +func (m *VodMutation) ResetCaptionPath() { + m.caption_path = nil + delete(m.clearedFields, vod.FieldCaptionPath) +} + +// SetFolderName sets the "folder_name" field. +func (m *VodMutation) SetFolderName(s string) { + m.folder_name = &s +} + +// FolderName returns the value of the "folder_name" field in the mutation. +func (m *VodMutation) FolderName() (r string, exists bool) { + v := m.folder_name if v == nil { return } return *v, true } -// OldVideoHlsPath returns the old "video_hls_path" field's value of the Vod entity. +// OldFolderName returns the old "folder_name" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldVideoHlsPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldFolderName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVideoHlsPath is only allowed on UpdateOne operations") + return v, errors.New("OldFolderName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVideoHlsPath requires an ID field in the mutation") + return v, errors.New("OldFolderName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldVideoHlsPath: %w", err) + return v, fmt.Errorf("querying old value for OldFolderName: %w", err) } - return oldValue.VideoHlsPath, nil + return oldValue.FolderName, nil } -// ClearVideoHlsPath clears the value of the "video_hls_path" field. -func (m *VodMutation) ClearVideoHlsPath() { - m.video_hls_path = nil - m.clearedFields[vod.FieldVideoHlsPath] = struct{}{} +// ClearFolderName clears the value of the "folder_name" field. +func (m *VodMutation) ClearFolderName() { + m.folder_name = nil + m.clearedFields[vod.FieldFolderName] = struct{}{} } -// VideoHlsPathCleared returns if the "video_hls_path" field was cleared in this mutation. -func (m *VodMutation) VideoHlsPathCleared() bool { - _, ok := m.clearedFields[vod.FieldVideoHlsPath] +// FolderNameCleared returns if the "folder_name" field was cleared in this mutation. +func (m *VodMutation) FolderNameCleared() bool { + _, ok := m.clearedFields[vod.FieldFolderName] return ok } -// ResetVideoHlsPath resets all changes to the "video_hls_path" field. -func (m *VodMutation) ResetVideoHlsPath() { - m.video_hls_path = nil - delete(m.clearedFields, vod.FieldVideoHlsPath) +// ResetFolderName resets all changes to the "folder_name" field. +func (m *VodMutation) ResetFolderName() { + m.folder_name = nil + delete(m.clearedFields, vod.FieldFolderName) } -// SetChatPath sets the "chat_path" field. -func (m *VodMutation) SetChatPath(s string) { - m.chat_path = &s +// SetFileName sets the "file_name" field. +func (m *VodMutation) SetFileName(s string) { + m.file_name = &s } -// ChatPath returns the value of the "chat_path" field in the mutation. -func (m *VodMutation) ChatPath() (r string, exists bool) { - v := m.chat_path +// FileName returns the value of the "file_name" field in the mutation. +func (m *VodMutation) FileName() (r string, exists bool) { + v := m.file_name if v == nil { return } return *v, true } -// OldChatPath returns the old "chat_path" field's value of the Vod entity. +// OldFileName returns the old "file_name" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldChatPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldFileName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldChatPath is only allowed on UpdateOne operations") + return v, errors.New("OldFileName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldChatPath requires an ID field in the mutation") + return v, errors.New("OldFileName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldChatPath: %w", err) + return v, fmt.Errorf("querying old value for OldFileName: %w", err) } - return oldValue.ChatPath, nil + return oldValue.FileName, nil } -// ClearChatPath clears the value of the "chat_path" field. -func (m *VodMutation) ClearChatPath() { - m.chat_path = nil - m.clearedFields[vod.FieldChatPath] = struct{}{} +// ClearFileName clears the value of the "file_name" field. +func (m *VodMutation) ClearFileName() { + m.file_name = nil + m.clearedFields[vod.FieldFileName] = struct{}{} } -// ChatPathCleared returns if the "chat_path" field was cleared in this mutation. -func (m *VodMutation) ChatPathCleared() bool { - _, ok := m.clearedFields[vod.FieldChatPath] +// FileNameCleared returns if the "file_name" field was cleared in this mutation. +func (m *VodMutation) FileNameCleared() bool { + _, ok := m.clearedFields[vod.FieldFileName] return ok } -// ResetChatPath resets all changes to the "chat_path" field. -func (m *VodMutation) ResetChatPath() { - m.chat_path = nil - delete(m.clearedFields, vod.FieldChatPath) +// ResetFileName resets all changes to the "file_name" field. +func (m *VodMutation) ResetFileName() { + m.file_name = nil + delete(m.clearedFields, vod.FieldFileName) } -// SetLiveChatPath sets the "live_chat_path" field. -func (m *VodMutation) SetLiveChatPath(s string) { - m.live_chat_path = &s +// SetTmpVideoDownloadPath sets the "tmp_video_download_path" field. +func (m *VodMutation) SetTmpVideoDownloadPath(s string) { + m.tmp_video_download_path = &s } -// LiveChatPath returns the value of the "live_chat_path" field in the mutation. -func (m *VodMutation) LiveChatPath() (r string, exists bool) { - v := m.live_chat_path +// TmpVideoDownloadPath returns the value of the "tmp_video_download_path" field in the mutation. +func (m *VodMutation) TmpVideoDownloadPath() (r string, exists bool) { + v := m.tmp_video_download_path if v == nil { return } return *v, true } -// OldLiveChatPath returns the old "live_chat_path" field's value of the Vod entity. +// OldTmpVideoDownloadPath returns the old "tmp_video_download_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldLiveChatPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldTmpVideoDownloadPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLiveChatPath is only allowed on UpdateOne operations") + return v, errors.New("OldTmpVideoDownloadPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLiveChatPath requires an ID field in the mutation") + return v, errors.New("OldTmpVideoDownloadPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLiveChatPath: %w", err) + return v, fmt.Errorf("querying old value for OldTmpVideoDownloadPath: %w", err) } - return oldValue.LiveChatPath, nil + return oldValue.TmpVideoDownloadPath, nil } -// ClearLiveChatPath clears the value of the "live_chat_path" field. -func (m *VodMutation) ClearLiveChatPath() { - m.live_chat_path = nil - m.clearedFields[vod.FieldLiveChatPath] = struct{}{} +// ClearTmpVideoDownloadPath clears the value of the "tmp_video_download_path" field. +func (m *VodMutation) ClearTmpVideoDownloadPath() { + m.tmp_video_download_path = nil + m.clearedFields[vod.FieldTmpVideoDownloadPath] = struct{}{} } -// LiveChatPathCleared returns if the "live_chat_path" field was cleared in this mutation. -func (m *VodMutation) LiveChatPathCleared() bool { - _, ok := m.clearedFields[vod.FieldLiveChatPath] +// TmpVideoDownloadPathCleared returns if the "tmp_video_download_path" field was cleared in this mutation. +func (m *VodMutation) TmpVideoDownloadPathCleared() bool { + _, ok := m.clearedFields[vod.FieldTmpVideoDownloadPath] return ok } -// ResetLiveChatPath resets all changes to the "live_chat_path" field. -func (m *VodMutation) ResetLiveChatPath() { - m.live_chat_path = nil - delete(m.clearedFields, vod.FieldLiveChatPath) +// ResetTmpVideoDownloadPath resets all changes to the "tmp_video_download_path" field. +func (m *VodMutation) ResetTmpVideoDownloadPath() { + m.tmp_video_download_path = nil + delete(m.clearedFields, vod.FieldTmpVideoDownloadPath) } -// SetLiveChatConvertPath sets the "live_chat_convert_path" field. -func (m *VodMutation) SetLiveChatConvertPath(s string) { - m.live_chat_convert_path = &s +// SetTmpVideoConvertPath sets the "tmp_video_convert_path" field. +func (m *VodMutation) SetTmpVideoConvertPath(s string) { + m.tmp_video_convert_path = &s } -// LiveChatConvertPath returns the value of the "live_chat_convert_path" field in the mutation. -func (m *VodMutation) LiveChatConvertPath() (r string, exists bool) { - v := m.live_chat_convert_path +// TmpVideoConvertPath returns the value of the "tmp_video_convert_path" field in the mutation. +func (m *VodMutation) TmpVideoConvertPath() (r string, exists bool) { + v := m.tmp_video_convert_path if v == nil { return } return *v, true } -// OldLiveChatConvertPath returns the old "live_chat_convert_path" field's value of the Vod entity. +// OldTmpVideoConvertPath returns the old "tmp_video_convert_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldLiveChatConvertPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldTmpVideoConvertPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLiveChatConvertPath is only allowed on UpdateOne operations") + return v, errors.New("OldTmpVideoConvertPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLiveChatConvertPath requires an ID field in the mutation") + return v, errors.New("OldTmpVideoConvertPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLiveChatConvertPath: %w", err) + return v, fmt.Errorf("querying old value for OldTmpVideoConvertPath: %w", err) } - return oldValue.LiveChatConvertPath, nil + return oldValue.TmpVideoConvertPath, nil } -// ClearLiveChatConvertPath clears the value of the "live_chat_convert_path" field. -func (m *VodMutation) ClearLiveChatConvertPath() { - m.live_chat_convert_path = nil - m.clearedFields[vod.FieldLiveChatConvertPath] = struct{}{} +// ClearTmpVideoConvertPath clears the value of the "tmp_video_convert_path" field. +func (m *VodMutation) ClearTmpVideoConvertPath() { + m.tmp_video_convert_path = nil + m.clearedFields[vod.FieldTmpVideoConvertPath] = struct{}{} } -// LiveChatConvertPathCleared returns if the "live_chat_convert_path" field was cleared in this mutation. -func (m *VodMutation) LiveChatConvertPathCleared() bool { - _, ok := m.clearedFields[vod.FieldLiveChatConvertPath] +// TmpVideoConvertPathCleared returns if the "tmp_video_convert_path" field was cleared in this mutation. +func (m *VodMutation) TmpVideoConvertPathCleared() bool { + _, ok := m.clearedFields[vod.FieldTmpVideoConvertPath] return ok } -// ResetLiveChatConvertPath resets all changes to the "live_chat_convert_path" field. -func (m *VodMutation) ResetLiveChatConvertPath() { - m.live_chat_convert_path = nil - delete(m.clearedFields, vod.FieldLiveChatConvertPath) +// ResetTmpVideoConvertPath resets all changes to the "tmp_video_convert_path" field. +func (m *VodMutation) ResetTmpVideoConvertPath() { + m.tmp_video_convert_path = nil + delete(m.clearedFields, vod.FieldTmpVideoConvertPath) } -// SetChatVideoPath sets the "chat_video_path" field. -func (m *VodMutation) SetChatVideoPath(s string) { - m.chat_video_path = &s +// SetTmpChatDownloadPath sets the "tmp_chat_download_path" field. +func (m *VodMutation) SetTmpChatDownloadPath(s string) { + m.tmp_chat_download_path = &s } -// ChatVideoPath returns the value of the "chat_video_path" field in the mutation. -func (m *VodMutation) ChatVideoPath() (r string, exists bool) { - v := m.chat_video_path +// TmpChatDownloadPath returns the value of the "tmp_chat_download_path" field in the mutation. +func (m *VodMutation) TmpChatDownloadPath() (r string, exists bool) { + v := m.tmp_chat_download_path if v == nil { return } return *v, true } -// OldChatVideoPath returns the old "chat_video_path" field's value of the Vod entity. +// OldTmpChatDownloadPath returns the old "tmp_chat_download_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldChatVideoPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldTmpChatDownloadPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldChatVideoPath is only allowed on UpdateOne operations") + return v, errors.New("OldTmpChatDownloadPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldChatVideoPath requires an ID field in the mutation") + return v, errors.New("OldTmpChatDownloadPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldChatVideoPath: %w", err) + return v, fmt.Errorf("querying old value for OldTmpChatDownloadPath: %w", err) } - return oldValue.ChatVideoPath, nil + return oldValue.TmpChatDownloadPath, nil } -// ClearChatVideoPath clears the value of the "chat_video_path" field. -func (m *VodMutation) ClearChatVideoPath() { - m.chat_video_path = nil - m.clearedFields[vod.FieldChatVideoPath] = struct{}{} +// ClearTmpChatDownloadPath clears the value of the "tmp_chat_download_path" field. +func (m *VodMutation) ClearTmpChatDownloadPath() { + m.tmp_chat_download_path = nil + m.clearedFields[vod.FieldTmpChatDownloadPath] = struct{}{} } -// ChatVideoPathCleared returns if the "chat_video_path" field was cleared in this mutation. -func (m *VodMutation) ChatVideoPathCleared() bool { - _, ok := m.clearedFields[vod.FieldChatVideoPath] +// TmpChatDownloadPathCleared returns if the "tmp_chat_download_path" field was cleared in this mutation. +func (m *VodMutation) TmpChatDownloadPathCleared() bool { + _, ok := m.clearedFields[vod.FieldTmpChatDownloadPath] return ok } -// ResetChatVideoPath resets all changes to the "chat_video_path" field. -func (m *VodMutation) ResetChatVideoPath() { - m.chat_video_path = nil - delete(m.clearedFields, vod.FieldChatVideoPath) +// ResetTmpChatDownloadPath resets all changes to the "tmp_chat_download_path" field. +func (m *VodMutation) ResetTmpChatDownloadPath() { + m.tmp_chat_download_path = nil + delete(m.clearedFields, vod.FieldTmpChatDownloadPath) } -// SetInfoPath sets the "info_path" field. -func (m *VodMutation) SetInfoPath(s string) { - m.info_path = &s +// SetTmpLiveChatDownloadPath sets the "tmp_live_chat_download_path" field. +func (m *VodMutation) SetTmpLiveChatDownloadPath(s string) { + m.tmp_live_chat_download_path = &s } -// InfoPath returns the value of the "info_path" field in the mutation. -func (m *VodMutation) InfoPath() (r string, exists bool) { - v := m.info_path +// TmpLiveChatDownloadPath returns the value of the "tmp_live_chat_download_path" field in the mutation. +func (m *VodMutation) TmpLiveChatDownloadPath() (r string, exists bool) { + v := m.tmp_live_chat_download_path if v == nil { return } return *v, true } -// OldInfoPath returns the old "info_path" field's value of the Vod entity. +// OldTmpLiveChatDownloadPath returns the old "tmp_live_chat_download_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldInfoPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldTmpLiveChatDownloadPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldInfoPath is only allowed on UpdateOne operations") + return v, errors.New("OldTmpLiveChatDownloadPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldInfoPath requires an ID field in the mutation") + return v, errors.New("OldTmpLiveChatDownloadPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldInfoPath: %w", err) + return v, fmt.Errorf("querying old value for OldTmpLiveChatDownloadPath: %w", err) } - return oldValue.InfoPath, nil + return oldValue.TmpLiveChatDownloadPath, nil } -// ClearInfoPath clears the value of the "info_path" field. -func (m *VodMutation) ClearInfoPath() { - m.info_path = nil - m.clearedFields[vod.FieldInfoPath] = struct{}{} +// ClearTmpLiveChatDownloadPath clears the value of the "tmp_live_chat_download_path" field. +func (m *VodMutation) ClearTmpLiveChatDownloadPath() { + m.tmp_live_chat_download_path = nil + m.clearedFields[vod.FieldTmpLiveChatDownloadPath] = struct{}{} } -// InfoPathCleared returns if the "info_path" field was cleared in this mutation. -func (m *VodMutation) InfoPathCleared() bool { - _, ok := m.clearedFields[vod.FieldInfoPath] +// TmpLiveChatDownloadPathCleared returns if the "tmp_live_chat_download_path" field was cleared in this mutation. +func (m *VodMutation) TmpLiveChatDownloadPathCleared() bool { + _, ok := m.clearedFields[vod.FieldTmpLiveChatDownloadPath] return ok } -// ResetInfoPath resets all changes to the "info_path" field. -func (m *VodMutation) ResetInfoPath() { - m.info_path = nil - delete(m.clearedFields, vod.FieldInfoPath) +// ResetTmpLiveChatDownloadPath resets all changes to the "tmp_live_chat_download_path" field. +func (m *VodMutation) ResetTmpLiveChatDownloadPath() { + m.tmp_live_chat_download_path = nil + delete(m.clearedFields, vod.FieldTmpLiveChatDownloadPath) } -// SetCaptionPath sets the "caption_path" field. -func (m *VodMutation) SetCaptionPath(s string) { - m.caption_path = &s +// SetTmpLiveChatConvertPath sets the "tmp_live_chat_convert_path" field. +func (m *VodMutation) SetTmpLiveChatConvertPath(s string) { + m.tmp_live_chat_convert_path = &s } -// CaptionPath returns the value of the "caption_path" field in the mutation. -func (m *VodMutation) CaptionPath() (r string, exists bool) { - v := m.caption_path +// TmpLiveChatConvertPath returns the value of the "tmp_live_chat_convert_path" field in the mutation. +func (m *VodMutation) TmpLiveChatConvertPath() (r string, exists bool) { + v := m.tmp_live_chat_convert_path if v == nil { return } return *v, true } -// OldCaptionPath returns the old "caption_path" field's value of the Vod entity. +// OldTmpLiveChatConvertPath returns the old "tmp_live_chat_convert_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldCaptionPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldTmpLiveChatConvertPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCaptionPath is only allowed on UpdateOne operations") + return v, errors.New("OldTmpLiveChatConvertPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCaptionPath requires an ID field in the mutation") + return v, errors.New("OldTmpLiveChatConvertPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCaptionPath: %w", err) + return v, fmt.Errorf("querying old value for OldTmpLiveChatConvertPath: %w", err) } - return oldValue.CaptionPath, nil + return oldValue.TmpLiveChatConvertPath, nil } -// ClearCaptionPath clears the value of the "caption_path" field. -func (m *VodMutation) ClearCaptionPath() { - m.caption_path = nil - m.clearedFields[vod.FieldCaptionPath] = struct{}{} +// ClearTmpLiveChatConvertPath clears the value of the "tmp_live_chat_convert_path" field. +func (m *VodMutation) ClearTmpLiveChatConvertPath() { + m.tmp_live_chat_convert_path = nil + m.clearedFields[vod.FieldTmpLiveChatConvertPath] = struct{}{} } -// CaptionPathCleared returns if the "caption_path" field was cleared in this mutation. -func (m *VodMutation) CaptionPathCleared() bool { - _, ok := m.clearedFields[vod.FieldCaptionPath] +// TmpLiveChatConvertPathCleared returns if the "tmp_live_chat_convert_path" field was cleared in this mutation. +func (m *VodMutation) TmpLiveChatConvertPathCleared() bool { + _, ok := m.clearedFields[vod.FieldTmpLiveChatConvertPath] return ok } -// ResetCaptionPath resets all changes to the "caption_path" field. -func (m *VodMutation) ResetCaptionPath() { - m.caption_path = nil - delete(m.clearedFields, vod.FieldCaptionPath) -} - -// SetFolderName sets the "folder_name" field. -func (m *VodMutation) SetFolderName(s string) { - m.folder_name = &s +// ResetTmpLiveChatConvertPath resets all changes to the "tmp_live_chat_convert_path" field. +func (m *VodMutation) ResetTmpLiveChatConvertPath() { + m.tmp_live_chat_convert_path = nil + delete(m.clearedFields, vod.FieldTmpLiveChatConvertPath) } -// FolderName returns the value of the "folder_name" field in the mutation. -func (m *VodMutation) FolderName() (r string, exists bool) { - v := m.folder_name +// SetTmpChatRenderPath sets the "tmp_chat_render_path" field. +func (m *VodMutation) SetTmpChatRenderPath(s string) { + m.tmp_chat_render_path = &s +} + +// TmpChatRenderPath returns the value of the "tmp_chat_render_path" field in the mutation. +func (m *VodMutation) TmpChatRenderPath() (r string, exists bool) { + v := m.tmp_chat_render_path if v == nil { return } return *v, true } -// OldFolderName returns the old "folder_name" field's value of the Vod entity. +// OldTmpChatRenderPath returns the old "tmp_chat_render_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldFolderName(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldTmpChatRenderPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldFolderName is only allowed on UpdateOne operations") + return v, errors.New("OldTmpChatRenderPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldFolderName requires an ID field in the mutation") + return v, errors.New("OldTmpChatRenderPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldFolderName: %w", err) + return v, fmt.Errorf("querying old value for OldTmpChatRenderPath: %w", err) } - return oldValue.FolderName, nil + return oldValue.TmpChatRenderPath, nil } -// ClearFolderName clears the value of the "folder_name" field. -func (m *VodMutation) ClearFolderName() { - m.folder_name = nil - m.clearedFields[vod.FieldFolderName] = struct{}{} +// ClearTmpChatRenderPath clears the value of the "tmp_chat_render_path" field. +func (m *VodMutation) ClearTmpChatRenderPath() { + m.tmp_chat_render_path = nil + m.clearedFields[vod.FieldTmpChatRenderPath] = struct{}{} } -// FolderNameCleared returns if the "folder_name" field was cleared in this mutation. -func (m *VodMutation) FolderNameCleared() bool { - _, ok := m.clearedFields[vod.FieldFolderName] +// TmpChatRenderPathCleared returns if the "tmp_chat_render_path" field was cleared in this mutation. +func (m *VodMutation) TmpChatRenderPathCleared() bool { + _, ok := m.clearedFields[vod.FieldTmpChatRenderPath] return ok } -// ResetFolderName resets all changes to the "folder_name" field. -func (m *VodMutation) ResetFolderName() { - m.folder_name = nil - delete(m.clearedFields, vod.FieldFolderName) +// ResetTmpChatRenderPath resets all changes to the "tmp_chat_render_path" field. +func (m *VodMutation) ResetTmpChatRenderPath() { + m.tmp_chat_render_path = nil + delete(m.clearedFields, vod.FieldTmpChatRenderPath) } -// SetFileName sets the "file_name" field. -func (m *VodMutation) SetFileName(s string) { - m.file_name = &s +// SetTmpVideoHlsPath sets the "tmp_video_hls_path" field. +func (m *VodMutation) SetTmpVideoHlsPath(s string) { + m.tmp_video_hls_path = &s } -// FileName returns the value of the "file_name" field in the mutation. -func (m *VodMutation) FileName() (r string, exists bool) { - v := m.file_name +// TmpVideoHlsPath returns the value of the "tmp_video_hls_path" field in the mutation. +func (m *VodMutation) TmpVideoHlsPath() (r string, exists bool) { + v := m.tmp_video_hls_path if v == nil { return } return *v, true } -// OldFileName returns the old "file_name" field's value of the Vod entity. +// OldTmpVideoHlsPath returns the old "tmp_video_hls_path" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldFileName(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldTmpVideoHlsPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldFileName is only allowed on UpdateOne operations") + return v, errors.New("OldTmpVideoHlsPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldFileName requires an ID field in the mutation") + return v, errors.New("OldTmpVideoHlsPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldFileName: %w", err) + return v, fmt.Errorf("querying old value for OldTmpVideoHlsPath: %w", err) } - return oldValue.FileName, nil + return oldValue.TmpVideoHlsPath, nil } -// ClearFileName clears the value of the "file_name" field. -func (m *VodMutation) ClearFileName() { - m.file_name = nil - m.clearedFields[vod.FieldFileName] = struct{}{} +// ClearTmpVideoHlsPath clears the value of the "tmp_video_hls_path" field. +func (m *VodMutation) ClearTmpVideoHlsPath() { + m.tmp_video_hls_path = nil + m.clearedFields[vod.FieldTmpVideoHlsPath] = struct{}{} } -// FileNameCleared returns if the "file_name" field was cleared in this mutation. -func (m *VodMutation) FileNameCleared() bool { - _, ok := m.clearedFields[vod.FieldFileName] +// TmpVideoHlsPathCleared returns if the "tmp_video_hls_path" field was cleared in this mutation. +func (m *VodMutation) TmpVideoHlsPathCleared() bool { + _, ok := m.clearedFields[vod.FieldTmpVideoHlsPath] return ok } -// ResetFileName resets all changes to the "file_name" field. -func (m *VodMutation) ResetFileName() { - m.file_name = nil - delete(m.clearedFields, vod.FieldFileName) +// ResetTmpVideoHlsPath resets all changes to the "tmp_video_hls_path" field. +func (m *VodMutation) ResetTmpVideoHlsPath() { + m.tmp_video_hls_path = nil + delete(m.clearedFields, vod.FieldTmpVideoHlsPath) } -// SetTmpVideoDownloadPath sets the "tmp_video_download_path" field. -func (m *VodMutation) SetTmpVideoDownloadPath(s string) { - m.tmp_video_download_path = &s +// SetLocked sets the "locked" field. +func (m *VodMutation) SetLocked(b bool) { + m.locked = &b } -// TmpVideoDownloadPath returns the value of the "tmp_video_download_path" field in the mutation. -func (m *VodMutation) TmpVideoDownloadPath() (r string, exists bool) { - v := m.tmp_video_download_path +// Locked returns the value of the "locked" field in the mutation. +func (m *VodMutation) Locked() (r bool, exists bool) { + v := m.locked if v == nil { return } return *v, true } -// OldTmpVideoDownloadPath returns the old "tmp_video_download_path" field's value of the Vod entity. +// OldLocked returns the old "locked" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldTmpVideoDownloadPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldLocked(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTmpVideoDownloadPath is only allowed on UpdateOne operations") + return v, errors.New("OldLocked is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTmpVideoDownloadPath requires an ID field in the mutation") + return v, errors.New("OldLocked requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTmpVideoDownloadPath: %w", err) + return v, fmt.Errorf("querying old value for OldLocked: %w", err) } - return oldValue.TmpVideoDownloadPath, nil -} - -// ClearTmpVideoDownloadPath clears the value of the "tmp_video_download_path" field. -func (m *VodMutation) ClearTmpVideoDownloadPath() { - m.tmp_video_download_path = nil - m.clearedFields[vod.FieldTmpVideoDownloadPath] = struct{}{} -} - -// TmpVideoDownloadPathCleared returns if the "tmp_video_download_path" field was cleared in this mutation. -func (m *VodMutation) TmpVideoDownloadPathCleared() bool { - _, ok := m.clearedFields[vod.FieldTmpVideoDownloadPath] - return ok + return oldValue.Locked, nil } -// ResetTmpVideoDownloadPath resets all changes to the "tmp_video_download_path" field. -func (m *VodMutation) ResetTmpVideoDownloadPath() { - m.tmp_video_download_path = nil - delete(m.clearedFields, vod.FieldTmpVideoDownloadPath) +// ResetLocked resets all changes to the "locked" field. +func (m *VodMutation) ResetLocked() { + m.locked = nil } -// SetTmpVideoConvertPath sets the "tmp_video_convert_path" field. -func (m *VodMutation) SetTmpVideoConvertPath(s string) { - m.tmp_video_convert_path = &s +// SetLocalViews sets the "local_views" field. +func (m *VodMutation) SetLocalViews(i int) { + m.local_views = &i + m.addlocal_views = nil } -// TmpVideoConvertPath returns the value of the "tmp_video_convert_path" field in the mutation. -func (m *VodMutation) TmpVideoConvertPath() (r string, exists bool) { - v := m.tmp_video_convert_path +// LocalViews returns the value of the "local_views" field in the mutation. +func (m *VodMutation) LocalViews() (r int, exists bool) { + v := m.local_views if v == nil { return } return *v, true } -// OldTmpVideoConvertPath returns the old "tmp_video_convert_path" field's value of the Vod entity. +// OldLocalViews returns the old "local_views" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldTmpVideoConvertPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldLocalViews(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTmpVideoConvertPath is only allowed on UpdateOne operations") + return v, errors.New("OldLocalViews is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTmpVideoConvertPath requires an ID field in the mutation") + return v, errors.New("OldLocalViews requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTmpVideoConvertPath: %w", err) + return v, fmt.Errorf("querying old value for OldLocalViews: %w", err) } - return oldValue.TmpVideoConvertPath, nil + return oldValue.LocalViews, nil } -// ClearTmpVideoConvertPath clears the value of the "tmp_video_convert_path" field. -func (m *VodMutation) ClearTmpVideoConvertPath() { - m.tmp_video_convert_path = nil - m.clearedFields[vod.FieldTmpVideoConvertPath] = struct{}{} +// AddLocalViews adds i to the "local_views" field. +func (m *VodMutation) AddLocalViews(i int) { + if m.addlocal_views != nil { + *m.addlocal_views += i + } else { + m.addlocal_views = &i + } } -// TmpVideoConvertPathCleared returns if the "tmp_video_convert_path" field was cleared in this mutation. -func (m *VodMutation) TmpVideoConvertPathCleared() bool { - _, ok := m.clearedFields[vod.FieldTmpVideoConvertPath] - return ok +// AddedLocalViews returns the value that was added to the "local_views" field in this mutation. +func (m *VodMutation) AddedLocalViews() (r int, exists bool) { + v := m.addlocal_views + if v == nil { + return + } + return *v, true } -// ResetTmpVideoConvertPath resets all changes to the "tmp_video_convert_path" field. -func (m *VodMutation) ResetTmpVideoConvertPath() { - m.tmp_video_convert_path = nil - delete(m.clearedFields, vod.FieldTmpVideoConvertPath) +// ResetLocalViews resets all changes to the "local_views" field. +func (m *VodMutation) ResetLocalViews() { + m.local_views = nil + m.addlocal_views = nil } -// SetTmpChatDownloadPath sets the "tmp_chat_download_path" field. -func (m *VodMutation) SetTmpChatDownloadPath(s string) { - m.tmp_chat_download_path = &s +// SetSpriteThumbnailsEnabled sets the "sprite_thumbnails_enabled" field. +func (m *VodMutation) SetSpriteThumbnailsEnabled(b bool) { + m.sprite_thumbnails_enabled = &b } -// TmpChatDownloadPath returns the value of the "tmp_chat_download_path" field in the mutation. -func (m *VodMutation) TmpChatDownloadPath() (r string, exists bool) { - v := m.tmp_chat_download_path +// SpriteThumbnailsEnabled returns the value of the "sprite_thumbnails_enabled" field in the mutation. +func (m *VodMutation) SpriteThumbnailsEnabled() (r bool, exists bool) { + v := m.sprite_thumbnails_enabled if v == nil { return } return *v, true } -// OldTmpChatDownloadPath returns the old "tmp_chat_download_path" field's value of the Vod entity. +// OldSpriteThumbnailsEnabled returns the old "sprite_thumbnails_enabled" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldTmpChatDownloadPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldSpriteThumbnailsEnabled(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTmpChatDownloadPath is only allowed on UpdateOne operations") + return v, errors.New("OldSpriteThumbnailsEnabled is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTmpChatDownloadPath requires an ID field in the mutation") + return v, errors.New("OldSpriteThumbnailsEnabled requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTmpChatDownloadPath: %w", err) + return v, fmt.Errorf("querying old value for OldSpriteThumbnailsEnabled: %w", err) } - return oldValue.TmpChatDownloadPath, nil -} - -// ClearTmpChatDownloadPath clears the value of the "tmp_chat_download_path" field. -func (m *VodMutation) ClearTmpChatDownloadPath() { - m.tmp_chat_download_path = nil - m.clearedFields[vod.FieldTmpChatDownloadPath] = struct{}{} -} - -// TmpChatDownloadPathCleared returns if the "tmp_chat_download_path" field was cleared in this mutation. -func (m *VodMutation) TmpChatDownloadPathCleared() bool { - _, ok := m.clearedFields[vod.FieldTmpChatDownloadPath] - return ok + return oldValue.SpriteThumbnailsEnabled, nil } -// ResetTmpChatDownloadPath resets all changes to the "tmp_chat_download_path" field. -func (m *VodMutation) ResetTmpChatDownloadPath() { - m.tmp_chat_download_path = nil - delete(m.clearedFields, vod.FieldTmpChatDownloadPath) +// ResetSpriteThumbnailsEnabled resets all changes to the "sprite_thumbnails_enabled" field. +func (m *VodMutation) ResetSpriteThumbnailsEnabled() { + m.sprite_thumbnails_enabled = nil } -// SetTmpLiveChatDownloadPath sets the "tmp_live_chat_download_path" field. -func (m *VodMutation) SetTmpLiveChatDownloadPath(s string) { - m.tmp_live_chat_download_path = &s +// SetSpriteThumbnailsImages sets the "sprite_thumbnails_images" field. +func (m *VodMutation) SetSpriteThumbnailsImages(s []string) { + m.sprite_thumbnails_images = &s + m.appendsprite_thumbnails_images = nil } -// TmpLiveChatDownloadPath returns the value of the "tmp_live_chat_download_path" field in the mutation. -func (m *VodMutation) TmpLiveChatDownloadPath() (r string, exists bool) { - v := m.tmp_live_chat_download_path +// SpriteThumbnailsImages returns the value of the "sprite_thumbnails_images" field in the mutation. +func (m *VodMutation) SpriteThumbnailsImages() (r []string, exists bool) { + v := m.sprite_thumbnails_images if v == nil { return } return *v, true } -// OldTmpLiveChatDownloadPath returns the old "tmp_live_chat_download_path" field's value of the Vod entity. +// OldSpriteThumbnailsImages returns the old "sprite_thumbnails_images" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldTmpLiveChatDownloadPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldSpriteThumbnailsImages(ctx context.Context) (v []string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTmpLiveChatDownloadPath is only allowed on UpdateOne operations") + return v, errors.New("OldSpriteThumbnailsImages is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTmpLiveChatDownloadPath requires an ID field in the mutation") + return v, errors.New("OldSpriteThumbnailsImages requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTmpLiveChatDownloadPath: %w", err) + return v, fmt.Errorf("querying old value for OldSpriteThumbnailsImages: %w", err) } - return oldValue.TmpLiveChatDownloadPath, nil + return oldValue.SpriteThumbnailsImages, nil } -// ClearTmpLiveChatDownloadPath clears the value of the "tmp_live_chat_download_path" field. -func (m *VodMutation) ClearTmpLiveChatDownloadPath() { - m.tmp_live_chat_download_path = nil - m.clearedFields[vod.FieldTmpLiveChatDownloadPath] = struct{}{} +// AppendSpriteThumbnailsImages adds s to the "sprite_thumbnails_images" field. +func (m *VodMutation) AppendSpriteThumbnailsImages(s []string) { + m.appendsprite_thumbnails_images = append(m.appendsprite_thumbnails_images, s...) } -// TmpLiveChatDownloadPathCleared returns if the "tmp_live_chat_download_path" field was cleared in this mutation. -func (m *VodMutation) TmpLiveChatDownloadPathCleared() bool { - _, ok := m.clearedFields[vod.FieldTmpLiveChatDownloadPath] +// AppendedSpriteThumbnailsImages returns the list of values that were appended to the "sprite_thumbnails_images" field in this mutation. +func (m *VodMutation) AppendedSpriteThumbnailsImages() ([]string, bool) { + if len(m.appendsprite_thumbnails_images) == 0 { + return nil, false + } + return m.appendsprite_thumbnails_images, true +} + +// ClearSpriteThumbnailsImages clears the value of the "sprite_thumbnails_images" field. +func (m *VodMutation) ClearSpriteThumbnailsImages() { + m.sprite_thumbnails_images = nil + m.appendsprite_thumbnails_images = nil + m.clearedFields[vod.FieldSpriteThumbnailsImages] = struct{}{} +} + +// SpriteThumbnailsImagesCleared returns if the "sprite_thumbnails_images" field was cleared in this mutation. +func (m *VodMutation) SpriteThumbnailsImagesCleared() bool { + _, ok := m.clearedFields[vod.FieldSpriteThumbnailsImages] return ok } -// ResetTmpLiveChatDownloadPath resets all changes to the "tmp_live_chat_download_path" field. -func (m *VodMutation) ResetTmpLiveChatDownloadPath() { - m.tmp_live_chat_download_path = nil - delete(m.clearedFields, vod.FieldTmpLiveChatDownloadPath) +// ResetSpriteThumbnailsImages resets all changes to the "sprite_thumbnails_images" field. +func (m *VodMutation) ResetSpriteThumbnailsImages() { + m.sprite_thumbnails_images = nil + m.appendsprite_thumbnails_images = nil + delete(m.clearedFields, vod.FieldSpriteThumbnailsImages) } -// SetTmpLiveChatConvertPath sets the "tmp_live_chat_convert_path" field. -func (m *VodMutation) SetTmpLiveChatConvertPath(s string) { - m.tmp_live_chat_convert_path = &s +// SetSpriteThumbnailsInterval sets the "sprite_thumbnails_interval" field. +func (m *VodMutation) SetSpriteThumbnailsInterval(i int) { + m.sprite_thumbnails_interval = &i + m.addsprite_thumbnails_interval = nil } -// TmpLiveChatConvertPath returns the value of the "tmp_live_chat_convert_path" field in the mutation. -func (m *VodMutation) TmpLiveChatConvertPath() (r string, exists bool) { - v := m.tmp_live_chat_convert_path +// SpriteThumbnailsInterval returns the value of the "sprite_thumbnails_interval" field in the mutation. +func (m *VodMutation) SpriteThumbnailsInterval() (r int, exists bool) { + v := m.sprite_thumbnails_interval if v == nil { return } return *v, true } -// OldTmpLiveChatConvertPath returns the old "tmp_live_chat_convert_path" field's value of the Vod entity. +// OldSpriteThumbnailsInterval returns the old "sprite_thumbnails_interval" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldTmpLiveChatConvertPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldSpriteThumbnailsInterval(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTmpLiveChatConvertPath is only allowed on UpdateOne operations") + return v, errors.New("OldSpriteThumbnailsInterval is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTmpLiveChatConvertPath requires an ID field in the mutation") + return v, errors.New("OldSpriteThumbnailsInterval requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTmpLiveChatConvertPath: %w", err) + return v, fmt.Errorf("querying old value for OldSpriteThumbnailsInterval: %w", err) + } + return oldValue.SpriteThumbnailsInterval, nil +} + +// AddSpriteThumbnailsInterval adds i to the "sprite_thumbnails_interval" field. +func (m *VodMutation) AddSpriteThumbnailsInterval(i int) { + if m.addsprite_thumbnails_interval != nil { + *m.addsprite_thumbnails_interval += i + } else { + m.addsprite_thumbnails_interval = &i + } +} + +// AddedSpriteThumbnailsInterval returns the value that was added to the "sprite_thumbnails_interval" field in this mutation. +func (m *VodMutation) AddedSpriteThumbnailsInterval() (r int, exists bool) { + v := m.addsprite_thumbnails_interval + if v == nil { + return } - return oldValue.TmpLiveChatConvertPath, nil + return *v, true } -// ClearTmpLiveChatConvertPath clears the value of the "tmp_live_chat_convert_path" field. -func (m *VodMutation) ClearTmpLiveChatConvertPath() { - m.tmp_live_chat_convert_path = nil - m.clearedFields[vod.FieldTmpLiveChatConvertPath] = struct{}{} +// ClearSpriteThumbnailsInterval clears the value of the "sprite_thumbnails_interval" field. +func (m *VodMutation) ClearSpriteThumbnailsInterval() { + m.sprite_thumbnails_interval = nil + m.addsprite_thumbnails_interval = nil + m.clearedFields[vod.FieldSpriteThumbnailsInterval] = struct{}{} } -// TmpLiveChatConvertPathCleared returns if the "tmp_live_chat_convert_path" field was cleared in this mutation. -func (m *VodMutation) TmpLiveChatConvertPathCleared() bool { - _, ok := m.clearedFields[vod.FieldTmpLiveChatConvertPath] +// SpriteThumbnailsIntervalCleared returns if the "sprite_thumbnails_interval" field was cleared in this mutation. +func (m *VodMutation) SpriteThumbnailsIntervalCleared() bool { + _, ok := m.clearedFields[vod.FieldSpriteThumbnailsInterval] return ok } -// ResetTmpLiveChatConvertPath resets all changes to the "tmp_live_chat_convert_path" field. -func (m *VodMutation) ResetTmpLiveChatConvertPath() { - m.tmp_live_chat_convert_path = nil - delete(m.clearedFields, vod.FieldTmpLiveChatConvertPath) +// ResetSpriteThumbnailsInterval resets all changes to the "sprite_thumbnails_interval" field. +func (m *VodMutation) ResetSpriteThumbnailsInterval() { + m.sprite_thumbnails_interval = nil + m.addsprite_thumbnails_interval = nil + delete(m.clearedFields, vod.FieldSpriteThumbnailsInterval) } -// SetTmpChatRenderPath sets the "tmp_chat_render_path" field. -func (m *VodMutation) SetTmpChatRenderPath(s string) { - m.tmp_chat_render_path = &s +// SetSpriteThumbnailsWidth sets the "sprite_thumbnails_width" field. +func (m *VodMutation) SetSpriteThumbnailsWidth(i int) { + m.sprite_thumbnails_width = &i + m.addsprite_thumbnails_width = nil } -// TmpChatRenderPath returns the value of the "tmp_chat_render_path" field in the mutation. -func (m *VodMutation) TmpChatRenderPath() (r string, exists bool) { - v := m.tmp_chat_render_path +// SpriteThumbnailsWidth returns the value of the "sprite_thumbnails_width" field in the mutation. +func (m *VodMutation) SpriteThumbnailsWidth() (r int, exists bool) { + v := m.sprite_thumbnails_width if v == nil { return } return *v, true } -// OldTmpChatRenderPath returns the old "tmp_chat_render_path" field's value of the Vod entity. +// OldSpriteThumbnailsWidth returns the old "sprite_thumbnails_width" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldTmpChatRenderPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldSpriteThumbnailsWidth(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTmpChatRenderPath is only allowed on UpdateOne operations") + return v, errors.New("OldSpriteThumbnailsWidth is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTmpChatRenderPath requires an ID field in the mutation") + return v, errors.New("OldSpriteThumbnailsWidth requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTmpChatRenderPath: %w", err) + return v, fmt.Errorf("querying old value for OldSpriteThumbnailsWidth: %w", err) } - return oldValue.TmpChatRenderPath, nil + return oldValue.SpriteThumbnailsWidth, nil } -// ClearTmpChatRenderPath clears the value of the "tmp_chat_render_path" field. -func (m *VodMutation) ClearTmpChatRenderPath() { - m.tmp_chat_render_path = nil - m.clearedFields[vod.FieldTmpChatRenderPath] = struct{}{} +// AddSpriteThumbnailsWidth adds i to the "sprite_thumbnails_width" field. +func (m *VodMutation) AddSpriteThumbnailsWidth(i int) { + if m.addsprite_thumbnails_width != nil { + *m.addsprite_thumbnails_width += i + } else { + m.addsprite_thumbnails_width = &i + } } -// TmpChatRenderPathCleared returns if the "tmp_chat_render_path" field was cleared in this mutation. -func (m *VodMutation) TmpChatRenderPathCleared() bool { - _, ok := m.clearedFields[vod.FieldTmpChatRenderPath] +// AddedSpriteThumbnailsWidth returns the value that was added to the "sprite_thumbnails_width" field in this mutation. +func (m *VodMutation) AddedSpriteThumbnailsWidth() (r int, exists bool) { + v := m.addsprite_thumbnails_width + if v == nil { + return + } + return *v, true +} + +// ClearSpriteThumbnailsWidth clears the value of the "sprite_thumbnails_width" field. +func (m *VodMutation) ClearSpriteThumbnailsWidth() { + m.sprite_thumbnails_width = nil + m.addsprite_thumbnails_width = nil + m.clearedFields[vod.FieldSpriteThumbnailsWidth] = struct{}{} +} + +// SpriteThumbnailsWidthCleared returns if the "sprite_thumbnails_width" field was cleared in this mutation. +func (m *VodMutation) SpriteThumbnailsWidthCleared() bool { + _, ok := m.clearedFields[vod.FieldSpriteThumbnailsWidth] return ok } -// ResetTmpChatRenderPath resets all changes to the "tmp_chat_render_path" field. -func (m *VodMutation) ResetTmpChatRenderPath() { - m.tmp_chat_render_path = nil - delete(m.clearedFields, vod.FieldTmpChatRenderPath) +// ResetSpriteThumbnailsWidth resets all changes to the "sprite_thumbnails_width" field. +func (m *VodMutation) ResetSpriteThumbnailsWidth() { + m.sprite_thumbnails_width = nil + m.addsprite_thumbnails_width = nil + delete(m.clearedFields, vod.FieldSpriteThumbnailsWidth) } -// SetTmpVideoHlsPath sets the "tmp_video_hls_path" field. -func (m *VodMutation) SetTmpVideoHlsPath(s string) { - m.tmp_video_hls_path = &s +// SetSpriteThumbnailsHeight sets the "sprite_thumbnails_height" field. +func (m *VodMutation) SetSpriteThumbnailsHeight(i int) { + m.sprite_thumbnails_height = &i + m.addsprite_thumbnails_height = nil } -// TmpVideoHlsPath returns the value of the "tmp_video_hls_path" field in the mutation. -func (m *VodMutation) TmpVideoHlsPath() (r string, exists bool) { - v := m.tmp_video_hls_path +// SpriteThumbnailsHeight returns the value of the "sprite_thumbnails_height" field in the mutation. +func (m *VodMutation) SpriteThumbnailsHeight() (r int, exists bool) { + v := m.sprite_thumbnails_height if v == nil { return } return *v, true } -// OldTmpVideoHlsPath returns the old "tmp_video_hls_path" field's value of the Vod entity. +// OldSpriteThumbnailsHeight returns the old "sprite_thumbnails_height" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldTmpVideoHlsPath(ctx context.Context) (v string, err error) { +func (m *VodMutation) OldSpriteThumbnailsHeight(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTmpVideoHlsPath is only allowed on UpdateOne operations") + return v, errors.New("OldSpriteThumbnailsHeight is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTmpVideoHlsPath requires an ID field in the mutation") + return v, errors.New("OldSpriteThumbnailsHeight requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldTmpVideoHlsPath: %w", err) + return v, fmt.Errorf("querying old value for OldSpriteThumbnailsHeight: %w", err) } - return oldValue.TmpVideoHlsPath, nil + return oldValue.SpriteThumbnailsHeight, nil } -// ClearTmpVideoHlsPath clears the value of the "tmp_video_hls_path" field. -func (m *VodMutation) ClearTmpVideoHlsPath() { - m.tmp_video_hls_path = nil - m.clearedFields[vod.FieldTmpVideoHlsPath] = struct{}{} +// AddSpriteThumbnailsHeight adds i to the "sprite_thumbnails_height" field. +func (m *VodMutation) AddSpriteThumbnailsHeight(i int) { + if m.addsprite_thumbnails_height != nil { + *m.addsprite_thumbnails_height += i + } else { + m.addsprite_thumbnails_height = &i + } } -// TmpVideoHlsPathCleared returns if the "tmp_video_hls_path" field was cleared in this mutation. -func (m *VodMutation) TmpVideoHlsPathCleared() bool { - _, ok := m.clearedFields[vod.FieldTmpVideoHlsPath] +// AddedSpriteThumbnailsHeight returns the value that was added to the "sprite_thumbnails_height" field in this mutation. +func (m *VodMutation) AddedSpriteThumbnailsHeight() (r int, exists bool) { + v := m.addsprite_thumbnails_height + if v == nil { + return + } + return *v, true +} + +// ClearSpriteThumbnailsHeight clears the value of the "sprite_thumbnails_height" field. +func (m *VodMutation) ClearSpriteThumbnailsHeight() { + m.sprite_thumbnails_height = nil + m.addsprite_thumbnails_height = nil + m.clearedFields[vod.FieldSpriteThumbnailsHeight] = struct{}{} +} + +// SpriteThumbnailsHeightCleared returns if the "sprite_thumbnails_height" field was cleared in this mutation. +func (m *VodMutation) SpriteThumbnailsHeightCleared() bool { + _, ok := m.clearedFields[vod.FieldSpriteThumbnailsHeight] return ok } -// ResetTmpVideoHlsPath resets all changes to the "tmp_video_hls_path" field. -func (m *VodMutation) ResetTmpVideoHlsPath() { - m.tmp_video_hls_path = nil - delete(m.clearedFields, vod.FieldTmpVideoHlsPath) +// ResetSpriteThumbnailsHeight resets all changes to the "sprite_thumbnails_height" field. +func (m *VodMutation) ResetSpriteThumbnailsHeight() { + m.sprite_thumbnails_height = nil + m.addsprite_thumbnails_height = nil + delete(m.clearedFields, vod.FieldSpriteThumbnailsHeight) } -// SetLocked sets the "locked" field. -func (m *VodMutation) SetLocked(b bool) { - m.locked = &b +// SetSpriteThumbnailsRows sets the "sprite_thumbnails_rows" field. +func (m *VodMutation) SetSpriteThumbnailsRows(i int) { + m.sprite_thumbnails_rows = &i + m.addsprite_thumbnails_rows = nil } -// Locked returns the value of the "locked" field in the mutation. -func (m *VodMutation) Locked() (r bool, exists bool) { - v := m.locked +// SpriteThumbnailsRows returns the value of the "sprite_thumbnails_rows" field in the mutation. +func (m *VodMutation) SpriteThumbnailsRows() (r int, exists bool) { + v := m.sprite_thumbnails_rows if v == nil { return } return *v, true } -// OldLocked returns the old "locked" field's value of the Vod entity. +// OldSpriteThumbnailsRows returns the old "sprite_thumbnails_rows" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldLocked(ctx context.Context) (v bool, err error) { +func (m *VodMutation) OldSpriteThumbnailsRows(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocked is only allowed on UpdateOne operations") + return v, errors.New("OldSpriteThumbnailsRows is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocked requires an ID field in the mutation") + return v, errors.New("OldSpriteThumbnailsRows requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocked: %w", err) + return v, fmt.Errorf("querying old value for OldSpriteThumbnailsRows: %w", err) } - return oldValue.Locked, nil + return oldValue.SpriteThumbnailsRows, nil } -// ResetLocked resets all changes to the "locked" field. -func (m *VodMutation) ResetLocked() { - m.locked = nil +// AddSpriteThumbnailsRows adds i to the "sprite_thumbnails_rows" field. +func (m *VodMutation) AddSpriteThumbnailsRows(i int) { + if m.addsprite_thumbnails_rows != nil { + *m.addsprite_thumbnails_rows += i + } else { + m.addsprite_thumbnails_rows = &i + } } -// SetLocalViews sets the "local_views" field. -func (m *VodMutation) SetLocalViews(i int) { - m.local_views = &i - m.addlocal_views = nil +// AddedSpriteThumbnailsRows returns the value that was added to the "sprite_thumbnails_rows" field in this mutation. +func (m *VodMutation) AddedSpriteThumbnailsRows() (r int, exists bool) { + v := m.addsprite_thumbnails_rows + if v == nil { + return + } + return *v, true } -// LocalViews returns the value of the "local_views" field in the mutation. -func (m *VodMutation) LocalViews() (r int, exists bool) { - v := m.local_views +// ClearSpriteThumbnailsRows clears the value of the "sprite_thumbnails_rows" field. +func (m *VodMutation) ClearSpriteThumbnailsRows() { + m.sprite_thumbnails_rows = nil + m.addsprite_thumbnails_rows = nil + m.clearedFields[vod.FieldSpriteThumbnailsRows] = struct{}{} +} + +// SpriteThumbnailsRowsCleared returns if the "sprite_thumbnails_rows" field was cleared in this mutation. +func (m *VodMutation) SpriteThumbnailsRowsCleared() bool { + _, ok := m.clearedFields[vod.FieldSpriteThumbnailsRows] + return ok +} + +// ResetSpriteThumbnailsRows resets all changes to the "sprite_thumbnails_rows" field. +func (m *VodMutation) ResetSpriteThumbnailsRows() { + m.sprite_thumbnails_rows = nil + m.addsprite_thumbnails_rows = nil + delete(m.clearedFields, vod.FieldSpriteThumbnailsRows) +} + +// SetSpriteThumbnailsColumns sets the "sprite_thumbnails_columns" field. +func (m *VodMutation) SetSpriteThumbnailsColumns(i int) { + m.sprite_thumbnails_columns = &i + m.addsprite_thumbnails_columns = nil +} + +// SpriteThumbnailsColumns returns the value of the "sprite_thumbnails_columns" field in the mutation. +func (m *VodMutation) SpriteThumbnailsColumns() (r int, exists bool) { + v := m.sprite_thumbnails_columns if v == nil { return } return *v, true } -// OldLocalViews returns the old "local_views" field's value of the Vod entity. +// OldSpriteThumbnailsColumns returns the old "sprite_thumbnails_columns" field's value of the Vod entity. // If the Vod object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *VodMutation) OldLocalViews(ctx context.Context) (v int, err error) { +func (m *VodMutation) OldSpriteThumbnailsColumns(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLocalViews is only allowed on UpdateOne operations") + return v, errors.New("OldSpriteThumbnailsColumns is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLocalViews requires an ID field in the mutation") + return v, errors.New("OldSpriteThumbnailsColumns requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldLocalViews: %w", err) + return v, fmt.Errorf("querying old value for OldSpriteThumbnailsColumns: %w", err) } - return oldValue.LocalViews, nil + return oldValue.SpriteThumbnailsColumns, nil } -// AddLocalViews adds i to the "local_views" field. -func (m *VodMutation) AddLocalViews(i int) { - if m.addlocal_views != nil { - *m.addlocal_views += i +// AddSpriteThumbnailsColumns adds i to the "sprite_thumbnails_columns" field. +func (m *VodMutation) AddSpriteThumbnailsColumns(i int) { + if m.addsprite_thumbnails_columns != nil { + *m.addsprite_thumbnails_columns += i } else { - m.addlocal_views = &i + m.addsprite_thumbnails_columns = &i } } -// AddedLocalViews returns the value that was added to the "local_views" field in this mutation. -func (m *VodMutation) AddedLocalViews() (r int, exists bool) { - v := m.addlocal_views +// AddedSpriteThumbnailsColumns returns the value that was added to the "sprite_thumbnails_columns" field in this mutation. +func (m *VodMutation) AddedSpriteThumbnailsColumns() (r int, exists bool) { + v := m.addsprite_thumbnails_columns if v == nil { return } return *v, true } -// ResetLocalViews resets all changes to the "local_views" field. -func (m *VodMutation) ResetLocalViews() { - m.local_views = nil - m.addlocal_views = nil +// ClearSpriteThumbnailsColumns clears the value of the "sprite_thumbnails_columns" field. +func (m *VodMutation) ClearSpriteThumbnailsColumns() { + m.sprite_thumbnails_columns = nil + m.addsprite_thumbnails_columns = nil + m.clearedFields[vod.FieldSpriteThumbnailsColumns] = struct{}{} +} + +// SpriteThumbnailsColumnsCleared returns if the "sprite_thumbnails_columns" field was cleared in this mutation. +func (m *VodMutation) SpriteThumbnailsColumnsCleared() bool { + _, ok := m.clearedFields[vod.FieldSpriteThumbnailsColumns] + return ok +} + +// ResetSpriteThumbnailsColumns resets all changes to the "sprite_thumbnails_columns" field. +func (m *VodMutation) ResetSpriteThumbnailsColumns() { + m.sprite_thumbnails_columns = nil + m.addsprite_thumbnails_columns = nil + delete(m.clearedFields, vod.FieldSpriteThumbnailsColumns) } // SetStreamedAt sets the "streamed_at" field. @@ -11978,10 +13301,13 @@ func (m *VodMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *VodMutation) Fields() []string { - fields := make([]string, 0, 33) + fields := make([]string, 0, 42) if m.ext_id != nil { fields = append(fields, vod.FieldExtID) } + if m.clip_ext_vod_id != nil { + fields = append(fields, vod.FieldClipExtVodID) + } if m.ext_stream_id != nil { fields = append(fields, vod.FieldExtStreamID) } @@ -11997,6 +13323,9 @@ func (m *VodMutation) Fields() []string { if m.duration != nil { fields = append(fields, vod.FieldDuration) } + if m.clip_vod_offset != nil { + fields = append(fields, vod.FieldClipVodOffset) + } if m.views != nil { fields = append(fields, vod.FieldViews) } @@ -12069,6 +13398,27 @@ func (m *VodMutation) Fields() []string { if m.local_views != nil { fields = append(fields, vod.FieldLocalViews) } + if m.sprite_thumbnails_enabled != nil { + fields = append(fields, vod.FieldSpriteThumbnailsEnabled) + } + if m.sprite_thumbnails_images != nil { + fields = append(fields, vod.FieldSpriteThumbnailsImages) + } + if m.sprite_thumbnails_interval != nil { + fields = append(fields, vod.FieldSpriteThumbnailsInterval) + } + if m.sprite_thumbnails_width != nil { + fields = append(fields, vod.FieldSpriteThumbnailsWidth) + } + if m.sprite_thumbnails_height != nil { + fields = append(fields, vod.FieldSpriteThumbnailsHeight) + } + if m.sprite_thumbnails_rows != nil { + fields = append(fields, vod.FieldSpriteThumbnailsRows) + } + if m.sprite_thumbnails_columns != nil { + fields = append(fields, vod.FieldSpriteThumbnailsColumns) + } if m.streamed_at != nil { fields = append(fields, vod.FieldStreamedAt) } @@ -12088,6 +13438,8 @@ func (m *VodMutation) Field(name string) (ent.Value, bool) { switch name { case vod.FieldExtID: return m.ExtID() + case vod.FieldClipExtVodID: + return m.ClipExtVodID() case vod.FieldExtStreamID: return m.ExtStreamID() case vod.FieldPlatform: @@ -12098,6 +13450,8 @@ func (m *VodMutation) Field(name string) (ent.Value, bool) { return m.Title() case vod.FieldDuration: return m.Duration() + case vod.FieldClipVodOffset: + return m.ClipVodOffset() case vod.FieldViews: return m.Views() case vod.FieldResolution: @@ -12146,6 +13500,20 @@ func (m *VodMutation) Field(name string) (ent.Value, bool) { return m.Locked() case vod.FieldLocalViews: return m.LocalViews() + case vod.FieldSpriteThumbnailsEnabled: + return m.SpriteThumbnailsEnabled() + case vod.FieldSpriteThumbnailsImages: + return m.SpriteThumbnailsImages() + case vod.FieldSpriteThumbnailsInterval: + return m.SpriteThumbnailsInterval() + case vod.FieldSpriteThumbnailsWidth: + return m.SpriteThumbnailsWidth() + case vod.FieldSpriteThumbnailsHeight: + return m.SpriteThumbnailsHeight() + case vod.FieldSpriteThumbnailsRows: + return m.SpriteThumbnailsRows() + case vod.FieldSpriteThumbnailsColumns: + return m.SpriteThumbnailsColumns() case vod.FieldStreamedAt: return m.StreamedAt() case vod.FieldUpdatedAt: @@ -12163,6 +13531,8 @@ func (m *VodMutation) OldField(ctx context.Context, name string) (ent.Value, err switch name { case vod.FieldExtID: return m.OldExtID(ctx) + case vod.FieldClipExtVodID: + return m.OldClipExtVodID(ctx) case vod.FieldExtStreamID: return m.OldExtStreamID(ctx) case vod.FieldPlatform: @@ -12173,6 +13543,8 @@ func (m *VodMutation) OldField(ctx context.Context, name string) (ent.Value, err return m.OldTitle(ctx) case vod.FieldDuration: return m.OldDuration(ctx) + case vod.FieldClipVodOffset: + return m.OldClipVodOffset(ctx) case vod.FieldViews: return m.OldViews(ctx) case vod.FieldResolution: @@ -12221,6 +13593,20 @@ func (m *VodMutation) OldField(ctx context.Context, name string) (ent.Value, err return m.OldLocked(ctx) case vod.FieldLocalViews: return m.OldLocalViews(ctx) + case vod.FieldSpriteThumbnailsEnabled: + return m.OldSpriteThumbnailsEnabled(ctx) + case vod.FieldSpriteThumbnailsImages: + return m.OldSpriteThumbnailsImages(ctx) + case vod.FieldSpriteThumbnailsInterval: + return m.OldSpriteThumbnailsInterval(ctx) + case vod.FieldSpriteThumbnailsWidth: + return m.OldSpriteThumbnailsWidth(ctx) + case vod.FieldSpriteThumbnailsHeight: + return m.OldSpriteThumbnailsHeight(ctx) + case vod.FieldSpriteThumbnailsRows: + return m.OldSpriteThumbnailsRows(ctx) + case vod.FieldSpriteThumbnailsColumns: + return m.OldSpriteThumbnailsColumns(ctx) case vod.FieldStreamedAt: return m.OldStreamedAt(ctx) case vod.FieldUpdatedAt: @@ -12243,6 +13629,13 @@ func (m *VodMutation) SetField(name string, value ent.Value) error { } m.SetExtID(v) return nil + case vod.FieldClipExtVodID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetClipExtVodID(v) + return nil case vod.FieldExtStreamID: v, ok := value.(string) if !ok { @@ -12278,6 +13671,13 @@ func (m *VodMutation) SetField(name string, value ent.Value) error { } m.SetDuration(v) return nil + case vod.FieldClipVodOffset: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetClipVodOffset(v) + return nil case vod.FieldViews: v, ok := value.(int) if !ok { @@ -12446,6 +13846,55 @@ func (m *VodMutation) SetField(name string, value ent.Value) error { } m.SetLocalViews(v) return nil + case vod.FieldSpriteThumbnailsEnabled: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSpriteThumbnailsEnabled(v) + return nil + case vod.FieldSpriteThumbnailsImages: + v, ok := value.([]string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSpriteThumbnailsImages(v) + return nil + case vod.FieldSpriteThumbnailsInterval: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSpriteThumbnailsInterval(v) + return nil + case vod.FieldSpriteThumbnailsWidth: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSpriteThumbnailsWidth(v) + return nil + case vod.FieldSpriteThumbnailsHeight: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSpriteThumbnailsHeight(v) + return nil + case vod.FieldSpriteThumbnailsRows: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSpriteThumbnailsRows(v) + return nil + case vod.FieldSpriteThumbnailsColumns: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSpriteThumbnailsColumns(v) + return nil case vod.FieldStreamedAt: v, ok := value.(time.Time) if !ok { @@ -12478,12 +13927,30 @@ func (m *VodMutation) AddedFields() []string { if m.addduration != nil { fields = append(fields, vod.FieldDuration) } + if m.addclip_vod_offset != nil { + fields = append(fields, vod.FieldClipVodOffset) + } if m.addviews != nil { fields = append(fields, vod.FieldViews) } if m.addlocal_views != nil { fields = append(fields, vod.FieldLocalViews) } + if m.addsprite_thumbnails_interval != nil { + fields = append(fields, vod.FieldSpriteThumbnailsInterval) + } + if m.addsprite_thumbnails_width != nil { + fields = append(fields, vod.FieldSpriteThumbnailsWidth) + } + if m.addsprite_thumbnails_height != nil { + fields = append(fields, vod.FieldSpriteThumbnailsHeight) + } + if m.addsprite_thumbnails_rows != nil { + fields = append(fields, vod.FieldSpriteThumbnailsRows) + } + if m.addsprite_thumbnails_columns != nil { + fields = append(fields, vod.FieldSpriteThumbnailsColumns) + } return fields } @@ -12494,10 +13961,22 @@ func (m *VodMutation) AddedField(name string) (ent.Value, bool) { switch name { case vod.FieldDuration: return m.AddedDuration() + case vod.FieldClipVodOffset: + return m.AddedClipVodOffset() case vod.FieldViews: return m.AddedViews() case vod.FieldLocalViews: return m.AddedLocalViews() + case vod.FieldSpriteThumbnailsInterval: + return m.AddedSpriteThumbnailsInterval() + case vod.FieldSpriteThumbnailsWidth: + return m.AddedSpriteThumbnailsWidth() + case vod.FieldSpriteThumbnailsHeight: + return m.AddedSpriteThumbnailsHeight() + case vod.FieldSpriteThumbnailsRows: + return m.AddedSpriteThumbnailsRows() + case vod.FieldSpriteThumbnailsColumns: + return m.AddedSpriteThumbnailsColumns() } return nil, false } @@ -12514,6 +13993,13 @@ func (m *VodMutation) AddField(name string, value ent.Value) error { } m.AddDuration(v) return nil + case vod.FieldClipVodOffset: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddClipVodOffset(v) + return nil case vod.FieldViews: v, ok := value.(int) if !ok { @@ -12528,6 +14014,41 @@ func (m *VodMutation) AddField(name string, value ent.Value) error { } m.AddLocalViews(v) return nil + case vod.FieldSpriteThumbnailsInterval: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSpriteThumbnailsInterval(v) + return nil + case vod.FieldSpriteThumbnailsWidth: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSpriteThumbnailsWidth(v) + return nil + case vod.FieldSpriteThumbnailsHeight: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSpriteThumbnailsHeight(v) + return nil + case vod.FieldSpriteThumbnailsRows: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSpriteThumbnailsRows(v) + return nil + case vod.FieldSpriteThumbnailsColumns: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSpriteThumbnailsColumns(v) + return nil } return fmt.Errorf("unknown Vod numeric field %s", name) } @@ -12536,9 +14057,15 @@ func (m *VodMutation) AddField(name string, value ent.Value) error { // mutation. func (m *VodMutation) ClearedFields() []string { var fields []string + if m.FieldCleared(vod.FieldClipExtVodID) { + fields = append(fields, vod.FieldClipExtVodID) + } if m.FieldCleared(vod.FieldExtStreamID) { fields = append(fields, vod.FieldExtStreamID) } + if m.FieldCleared(vod.FieldClipVodOffset) { + fields = append(fields, vod.FieldClipVodOffset) + } if m.FieldCleared(vod.FieldResolution) { fields = append(fields, vod.FieldResolution) } @@ -12593,6 +14120,24 @@ func (m *VodMutation) ClearedFields() []string { if m.FieldCleared(vod.FieldTmpVideoHlsPath) { fields = append(fields, vod.FieldTmpVideoHlsPath) } + if m.FieldCleared(vod.FieldSpriteThumbnailsImages) { + fields = append(fields, vod.FieldSpriteThumbnailsImages) + } + if m.FieldCleared(vod.FieldSpriteThumbnailsInterval) { + fields = append(fields, vod.FieldSpriteThumbnailsInterval) + } + if m.FieldCleared(vod.FieldSpriteThumbnailsWidth) { + fields = append(fields, vod.FieldSpriteThumbnailsWidth) + } + if m.FieldCleared(vod.FieldSpriteThumbnailsHeight) { + fields = append(fields, vod.FieldSpriteThumbnailsHeight) + } + if m.FieldCleared(vod.FieldSpriteThumbnailsRows) { + fields = append(fields, vod.FieldSpriteThumbnailsRows) + } + if m.FieldCleared(vod.FieldSpriteThumbnailsColumns) { + fields = append(fields, vod.FieldSpriteThumbnailsColumns) + } return fields } @@ -12607,9 +14152,15 @@ func (m *VodMutation) FieldCleared(name string) bool { // error if the field is not defined in the schema. func (m *VodMutation) ClearField(name string) error { switch name { + case vod.FieldClipExtVodID: + m.ClearClipExtVodID() + return nil case vod.FieldExtStreamID: m.ClearExtStreamID() return nil + case vod.FieldClipVodOffset: + m.ClearClipVodOffset() + return nil case vod.FieldResolution: m.ClearResolution() return nil @@ -12664,6 +14215,24 @@ func (m *VodMutation) ClearField(name string) error { case vod.FieldTmpVideoHlsPath: m.ClearTmpVideoHlsPath() return nil + case vod.FieldSpriteThumbnailsImages: + m.ClearSpriteThumbnailsImages() + return nil + case vod.FieldSpriteThumbnailsInterval: + m.ClearSpriteThumbnailsInterval() + return nil + case vod.FieldSpriteThumbnailsWidth: + m.ClearSpriteThumbnailsWidth() + return nil + case vod.FieldSpriteThumbnailsHeight: + m.ClearSpriteThumbnailsHeight() + return nil + case vod.FieldSpriteThumbnailsRows: + m.ClearSpriteThumbnailsRows() + return nil + case vod.FieldSpriteThumbnailsColumns: + m.ClearSpriteThumbnailsColumns() + return nil } return fmt.Errorf("unknown Vod nullable field %s", name) } @@ -12675,6 +14244,9 @@ func (m *VodMutation) ResetField(name string) error { case vod.FieldExtID: m.ResetExtID() return nil + case vod.FieldClipExtVodID: + m.ResetClipExtVodID() + return nil case vod.FieldExtStreamID: m.ResetExtStreamID() return nil @@ -12690,6 +14262,9 @@ func (m *VodMutation) ResetField(name string) error { case vod.FieldDuration: m.ResetDuration() return nil + case vod.FieldClipVodOffset: + m.ResetClipVodOffset() + return nil case vod.FieldViews: m.ResetViews() return nil @@ -12762,6 +14337,27 @@ func (m *VodMutation) ResetField(name string) error { case vod.FieldLocalViews: m.ResetLocalViews() return nil + case vod.FieldSpriteThumbnailsEnabled: + m.ResetSpriteThumbnailsEnabled() + return nil + case vod.FieldSpriteThumbnailsImages: + m.ResetSpriteThumbnailsImages() + return nil + case vod.FieldSpriteThumbnailsInterval: + m.ResetSpriteThumbnailsInterval() + return nil + case vod.FieldSpriteThumbnailsWidth: + m.ResetSpriteThumbnailsWidth() + return nil + case vod.FieldSpriteThumbnailsHeight: + m.ResetSpriteThumbnailsHeight() + return nil + case vod.FieldSpriteThumbnailsRows: + m.ResetSpriteThumbnailsRows() + return nil + case vod.FieldSpriteThumbnailsColumns: + m.ResetSpriteThumbnailsColumns() + return nil case vod.FieldStreamedAt: m.ResetStreamedAt() return nil diff --git a/ent/predicate/predicate.go b/ent/predicate/predicate.go index ecf937f3..a3e689de 100644 --- a/ent/predicate/predicate.go +++ b/ent/predicate/predicate.go @@ -39,6 +39,9 @@ type Playlist func(*sql.Selector) // Queue is the predicate function for queue builders. type Queue func(*sql.Selector) +// Sessions is the predicate function for sessions builders. +type Sessions func(*sql.Selector) + // TwitchCategory is the predicate function for twitchcategory builders. type TwitchCategory func(*sql.Selector) diff --git a/ent/runtime.go b/ent/runtime.go index 58e2371a..8ab8471a 100644 --- a/ent/runtime.go +++ b/ent/runtime.go @@ -17,6 +17,7 @@ import ( "github.com/zibbp/ganymede/ent/playlist" "github.com/zibbp/ganymede/ent/queue" "github.com/zibbp/ganymede/ent/schema" + "github.com/zibbp/ganymede/ent/sessions" "github.com/zibbp/ganymede/ent/twitchcategory" "github.com/zibbp/ganymede/ent/user" "github.com/zibbp/ganymede/ent/vod" @@ -112,14 +113,26 @@ func init() { liveDescApplyCategoriesToLive := liveFields[13].Descriptor() // live.DefaultApplyCategoriesToLive holds the default value on creation for the apply_categories_to_live field. live.DefaultApplyCategoriesToLive = liveDescApplyCategoriesToLive.Default.(bool) + // liveDescWatchClips is the schema descriptor for watch_clips field. + liveDescWatchClips := liveFields[14].Descriptor() + // live.DefaultWatchClips holds the default value on creation for the watch_clips field. + live.DefaultWatchClips = liveDescWatchClips.Default.(bool) + // liveDescClipsLimit is the schema descriptor for clips_limit field. + liveDescClipsLimit := liveFields[15].Descriptor() + // live.DefaultClipsLimit holds the default value on creation for the clips_limit field. + live.DefaultClipsLimit = liveDescClipsLimit.Default.(int) + // liveDescClipsIntervalDays is the schema descriptor for clips_interval_days field. + liveDescClipsIntervalDays := liveFields[16].Descriptor() + // live.DefaultClipsIntervalDays holds the default value on creation for the clips_interval_days field. + live.DefaultClipsIntervalDays = liveDescClipsIntervalDays.Default.(int) // liveDescUpdatedAt is the schema descriptor for updated_at field. - liveDescUpdatedAt := liveFields[14].Descriptor() + liveDescUpdatedAt := liveFields[18].Descriptor() // live.DefaultUpdatedAt holds the default value on creation for the updated_at field. live.DefaultUpdatedAt = liveDescUpdatedAt.Default.(func() time.Time) // live.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. live.UpdateDefaultUpdatedAt = liveDescUpdatedAt.UpdateDefault.(func() time.Time) // liveDescCreatedAt is the schema descriptor for created_at field. - liveDescCreatedAt := liveFields[15].Descriptor() + liveDescCreatedAt := liveFields[19].Descriptor() // live.DefaultCreatedAt holds the default value on creation for the created_at field. live.DefaultCreatedAt = liveDescCreatedAt.Default.(func() time.Time) // liveDescID is the schema descriptor for id field. @@ -232,6 +245,16 @@ func init() { queueDescID := queueFields[0].Descriptor() // queue.DefaultID holds the default value on creation for the id field. queue.DefaultID = queueDescID.Default.(func() uuid.UUID) + sessionsFields := schema.Sessions{}.Fields() + _ = sessionsFields + // sessionsDescToken is the schema descriptor for token field. + sessionsDescToken := sessionsFields[0].Descriptor() + // sessions.TokenValidator is a validator for the "token" field. It is called by the builders before save. + sessions.TokenValidator = sessionsDescToken.Validators[0].(func(string) error) + // sessionsDescData is the schema descriptor for data field. + sessionsDescData := sessionsFields[1].Descriptor() + // sessions.DataValidator is a validator for the "data" field. It is called by the builders before save. + sessions.DataValidator = sessionsDescData.Validators[0].(func([]byte) error) twitchcategoryFields := schema.TwitchCategory{}.Fields() _ = twitchcategoryFields // twitchcategoryDescUpdatedAt is the schema descriptor for updated_at field. @@ -267,37 +290,41 @@ func init() { vodFields := schema.Vod{}.Fields() _ = vodFields // vodDescDuration is the schema descriptor for duration field. - vodDescDuration := vodFields[6].Descriptor() + vodDescDuration := vodFields[7].Descriptor() // vod.DefaultDuration holds the default value on creation for the duration field. vod.DefaultDuration = vodDescDuration.Default.(int) // vodDescViews is the schema descriptor for views field. - vodDescViews := vodFields[7].Descriptor() + vodDescViews := vodFields[9].Descriptor() // vod.DefaultViews holds the default value on creation for the views field. vod.DefaultViews = vodDescViews.Default.(int) // vodDescProcessing is the schema descriptor for processing field. - vodDescProcessing := vodFields[9].Descriptor() + vodDescProcessing := vodFields[11].Descriptor() // vod.DefaultProcessing holds the default value on creation for the processing field. vod.DefaultProcessing = vodDescProcessing.Default.(bool) // vodDescLocked is the schema descriptor for locked field. - vodDescLocked := vodFields[29].Descriptor() + vodDescLocked := vodFields[31].Descriptor() // vod.DefaultLocked holds the default value on creation for the locked field. vod.DefaultLocked = vodDescLocked.Default.(bool) // vodDescLocalViews is the schema descriptor for local_views field. - vodDescLocalViews := vodFields[30].Descriptor() + vodDescLocalViews := vodFields[32].Descriptor() // vod.DefaultLocalViews holds the default value on creation for the local_views field. vod.DefaultLocalViews = vodDescLocalViews.Default.(int) + // vodDescSpriteThumbnailsEnabled is the schema descriptor for sprite_thumbnails_enabled field. + vodDescSpriteThumbnailsEnabled := vodFields[33].Descriptor() + // vod.DefaultSpriteThumbnailsEnabled holds the default value on creation for the sprite_thumbnails_enabled field. + vod.DefaultSpriteThumbnailsEnabled = vodDescSpriteThumbnailsEnabled.Default.(bool) // vodDescStreamedAt is the schema descriptor for streamed_at field. - vodDescStreamedAt := vodFields[31].Descriptor() + vodDescStreamedAt := vodFields[40].Descriptor() // vod.DefaultStreamedAt holds the default value on creation for the streamed_at field. vod.DefaultStreamedAt = vodDescStreamedAt.Default.(func() time.Time) // vodDescUpdatedAt is the schema descriptor for updated_at field. - vodDescUpdatedAt := vodFields[32].Descriptor() + vodDescUpdatedAt := vodFields[41].Descriptor() // vod.DefaultUpdatedAt holds the default value on creation for the updated_at field. vod.DefaultUpdatedAt = vodDescUpdatedAt.Default.(func() time.Time) // vod.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field. vod.UpdateDefaultUpdatedAt = vodDescUpdatedAt.UpdateDefault.(func() time.Time) // vodDescCreatedAt is the schema descriptor for created_at field. - vodDescCreatedAt := vodFields[33].Descriptor() + vodDescCreatedAt := vodFields[42].Descriptor() // vod.DefaultCreatedAt holds the default value on creation for the created_at field. vod.DefaultCreatedAt = vodDescCreatedAt.Default.(func() time.Time) // vodDescID is the schema descriptor for id field. diff --git a/ent/schema/live.go b/ent/schema/live.go index 6c17412c..158bb877 100644 --- a/ent/schema/live.go +++ b/ent/schema/live.go @@ -20,7 +20,7 @@ type Live struct { // Fields of the Live. func (Live) Fields() []ent.Field { - return []ent.Field{ + fields := []ent.Field{ field.UUID("id", uuid.UUID{}).Default(uuid.New), field.Bool("watch_live").Default(true).Comment("Watch live streams"), field.Bool("watch_vod").Default(false).Comment("Watch new VODs"), @@ -35,9 +35,17 @@ func (Live) Fields() []ent.Field { field.Bool("render_chat").Default(true).Comment("Whether the chat should be rendered."), field.Int64("video_age").Default(0).Comment("Restrict fetching videos to a certain age."), field.Bool("apply_categories_to_live").Default(false).Comment("Whether the categories should be applied to livestreams."), + field.Bool("watch_clips").Default(false).Comment("Whether to download clips on a schedule."), + field.Int("clips_limit").Default(0).Comment("The number of clips to archive."), + field.Int("clips_interval_days").Default(0).Comment("How often channel should be checked for clips to archive in days."), + field.Time("clips_last_checked").Comment("Time when clips were last checked.").Optional(), field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now), field.Time("created_at").Default(time.Now).Immutable(), } + for _, f := range fields { + f.Descriptor().Tag = `json:"` + f.Descriptor().Name + `"` + } + return fields } // Edges of the Live. diff --git a/ent/schema/playback.go b/ent/schema/playback.go index 0ef93884..7cfca4cb 100644 --- a/ent/schema/playback.go +++ b/ent/schema/playback.go @@ -1,11 +1,12 @@ package schema import ( + "time" + "entgo.io/ent" "entgo.io/ent/schema/field" "github.com/google/uuid" "github.com/zibbp/ganymede/internal/utils" - "time" ) // Playback holds the schema definition for the Playback entity. diff --git a/ent/schema/sessions.go b/ent/schema/sessions.go new file mode 100644 index 00000000..48637461 --- /dev/null +++ b/ent/schema/sessions.go @@ -0,0 +1,32 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" +) + +// Sessions holds the schema definition for the Sessions entity. +type Sessions struct { + ent.Schema +} + +// Fields of the Sessions. +func (Sessions) Fields() []ent.Field { + return []ent.Field{ + field.Text("token").Unique().NotEmpty().Immutable(), + field.Bytes("data").NotEmpty(), + field.Time("expiry"), + } +} + +func (Sessions) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("expiry"), + } +} + +// Edges of the Sessions. +func (Sessions) Edges() []ent.Edge { + return nil +} diff --git a/ent/schema/vod.go b/ent/schema/vod.go index 34fbe4be..c5715fb6 100644 --- a/ent/schema/vod.go +++ b/ent/schema/vod.go @@ -20,11 +20,13 @@ func (Vod) Fields() []ent.Field { return []ent.Field{ field.UUID("id", uuid.UUID{}).Default(uuid.New), field.String("ext_id").Comment("The ID of the video on the external platform."), + field.String("clip_ext_vod_id").Optional().Comment("The external VOD ID of a clip. This is only populated if the clip is linked to a video."), field.String("ext_stream_id").Optional().Comment("The ID of the stream on the external platform, if applicable."), field.Enum("platform").GoType(utils.VideoPlatform("")).Default(string(utils.PlatformTwitch)).Comment("The platform the VOD is from, takes an enum."), field.Enum("type").GoType(utils.VodType("")).Default(string(utils.Archive)).Comment("The type of VOD, takes an enum."), field.String("title"), field.Int("duration").Default(1), + field.Int("clip_vod_offset").Optional().Comment("The offset in seconds to where the clip starts in the VOD. This is only populdated if the video is a clip."), field.Int("views").Default(1), field.String("resolution").Optional(), field.Bool("processing").Default(false).Comment("Whether the VOD is currently processing."), @@ -49,6 +51,13 @@ func (Vod) Fields() []ent.Field { field.String("tmp_video_hls_path").Optional().Comment("The path where the temporary video hls files are"), field.Bool("locked").Default(false), field.Int("local_views").Default(0), + field.Bool("sprite_thumbnails_enabled").Default(false), + field.Strings("sprite_thumbnails_images").Optional(), + field.Int("sprite_thumbnails_interval").Optional(), + field.Int("sprite_thumbnails_width").Optional(), + field.Int("sprite_thumbnails_height").Optional(), + field.Int("sprite_thumbnails_rows").Optional(), + field.Int("sprite_thumbnails_columns").Optional(), field.Time("streamed_at").Default(time.Now).Comment("The time the VOD was streamed."), field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now), field.Time("created_at").Default(time.Now).Immutable(), diff --git a/ent/sessions.go b/ent/sessions.go new file mode 100644 index 00000000..02b114cd --- /dev/null +++ b/ent/sessions.go @@ -0,0 +1,130 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "github.com/zibbp/ganymede/ent/sessions" +) + +// Sessions is the model entity for the Sessions schema. +type Sessions struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Token holds the value of the "token" field. + Token string `json:"token,omitempty"` + // Data holds the value of the "data" field. + Data []byte `json:"data,omitempty"` + // Expiry holds the value of the "expiry" field. + Expiry time.Time `json:"expiry,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Sessions) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case sessions.FieldData: + values[i] = new([]byte) + case sessions.FieldID: + values[i] = new(sql.NullInt64) + case sessions.FieldToken: + values[i] = new(sql.NullString) + case sessions.FieldExpiry: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Sessions fields. +func (s *Sessions) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case sessions.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + s.ID = int(value.Int64) + case sessions.FieldToken: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field token", values[i]) + } else if value.Valid { + s.Token = value.String + } + case sessions.FieldData: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field data", values[i]) + } else if value != nil { + s.Data = *value + } + case sessions.FieldExpiry: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field expiry", values[i]) + } else if value.Valid { + s.Expiry = value.Time + } + default: + s.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Sessions. +// This includes values selected through modifiers, order, etc. +func (s *Sessions) Value(name string) (ent.Value, error) { + return s.selectValues.Get(name) +} + +// Update returns a builder for updating this Sessions. +// Note that you need to call Sessions.Unwrap() before calling this method if this Sessions +// was returned from a transaction, and the transaction was committed or rolled back. +func (s *Sessions) Update() *SessionsUpdateOne { + return NewSessionsClient(s.config).UpdateOne(s) +} + +// Unwrap unwraps the Sessions entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (s *Sessions) Unwrap() *Sessions { + _tx, ok := s.config.driver.(*txDriver) + if !ok { + panic("ent: Sessions is not a transactional entity") + } + s.config.driver = _tx.drv + return s +} + +// String implements the fmt.Stringer. +func (s *Sessions) String() string { + var builder strings.Builder + builder.WriteString("Sessions(") + builder.WriteString(fmt.Sprintf("id=%v, ", s.ID)) + builder.WriteString("token=") + builder.WriteString(s.Token) + builder.WriteString(", ") + builder.WriteString("data=") + builder.WriteString(fmt.Sprintf("%v", s.Data)) + builder.WriteString(", ") + builder.WriteString("expiry=") + builder.WriteString(s.Expiry.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// SessionsSlice is a parsable slice of Sessions. +type SessionsSlice []*Sessions diff --git a/ent/sessions/sessions.go b/ent/sessions/sessions.go new file mode 100644 index 00000000..54aceca5 --- /dev/null +++ b/ent/sessions/sessions.go @@ -0,0 +1,65 @@ +// Code generated by ent, DO NOT EDIT. + +package sessions + +import ( + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the sessions type in the database. + Label = "sessions" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldToken holds the string denoting the token field in the database. + FieldToken = "token" + // FieldData holds the string denoting the data field in the database. + FieldData = "data" + // FieldExpiry holds the string denoting the expiry field in the database. + FieldExpiry = "expiry" + // Table holds the table name of the sessions in the database. + Table = "sessions" +) + +// Columns holds all SQL columns for sessions fields. +var Columns = []string{ + FieldID, + FieldToken, + FieldData, + FieldExpiry, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // TokenValidator is a validator for the "token" field. It is called by the builders before save. + TokenValidator func(string) error + // DataValidator is a validator for the "data" field. It is called by the builders before save. + DataValidator func([]byte) error +) + +// OrderOption defines the ordering options for the Sessions queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByToken orders the results by the token field. +func ByToken(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldToken, opts...).ToFunc() +} + +// ByExpiry orders the results by the expiry field. +func ByExpiry(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldExpiry, opts...).ToFunc() +} diff --git a/ent/sessions/where.go b/ent/sessions/where.go new file mode 100644 index 00000000..a6ea7fb4 --- /dev/null +++ b/ent/sessions/where.go @@ -0,0 +1,230 @@ +// Code generated by ent, DO NOT EDIT. + +package sessions + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "github.com/zibbp/ganymede/ent/predicate" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.Sessions { + return predicate.Sessions(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.Sessions { + return predicate.Sessions(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.Sessions { + return predicate.Sessions(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.Sessions { + return predicate.Sessions(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.Sessions { + return predicate.Sessions(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.Sessions { + return predicate.Sessions(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.Sessions { + return predicate.Sessions(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.Sessions { + return predicate.Sessions(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.Sessions { + return predicate.Sessions(sql.FieldLTE(FieldID, id)) +} + +// Token applies equality check predicate on the "token" field. It's identical to TokenEQ. +func Token(v string) predicate.Sessions { + return predicate.Sessions(sql.FieldEQ(FieldToken, v)) +} + +// Data applies equality check predicate on the "data" field. It's identical to DataEQ. +func Data(v []byte) predicate.Sessions { + return predicate.Sessions(sql.FieldEQ(FieldData, v)) +} + +// Expiry applies equality check predicate on the "expiry" field. It's identical to ExpiryEQ. +func Expiry(v time.Time) predicate.Sessions { + return predicate.Sessions(sql.FieldEQ(FieldExpiry, v)) +} + +// TokenEQ applies the EQ predicate on the "token" field. +func TokenEQ(v string) predicate.Sessions { + return predicate.Sessions(sql.FieldEQ(FieldToken, v)) +} + +// TokenNEQ applies the NEQ predicate on the "token" field. +func TokenNEQ(v string) predicate.Sessions { + return predicate.Sessions(sql.FieldNEQ(FieldToken, v)) +} + +// TokenIn applies the In predicate on the "token" field. +func TokenIn(vs ...string) predicate.Sessions { + return predicate.Sessions(sql.FieldIn(FieldToken, vs...)) +} + +// TokenNotIn applies the NotIn predicate on the "token" field. +func TokenNotIn(vs ...string) predicate.Sessions { + return predicate.Sessions(sql.FieldNotIn(FieldToken, vs...)) +} + +// TokenGT applies the GT predicate on the "token" field. +func TokenGT(v string) predicate.Sessions { + return predicate.Sessions(sql.FieldGT(FieldToken, v)) +} + +// TokenGTE applies the GTE predicate on the "token" field. +func TokenGTE(v string) predicate.Sessions { + return predicate.Sessions(sql.FieldGTE(FieldToken, v)) +} + +// TokenLT applies the LT predicate on the "token" field. +func TokenLT(v string) predicate.Sessions { + return predicate.Sessions(sql.FieldLT(FieldToken, v)) +} + +// TokenLTE applies the LTE predicate on the "token" field. +func TokenLTE(v string) predicate.Sessions { + return predicate.Sessions(sql.FieldLTE(FieldToken, v)) +} + +// TokenContains applies the Contains predicate on the "token" field. +func TokenContains(v string) predicate.Sessions { + return predicate.Sessions(sql.FieldContains(FieldToken, v)) +} + +// TokenHasPrefix applies the HasPrefix predicate on the "token" field. +func TokenHasPrefix(v string) predicate.Sessions { + return predicate.Sessions(sql.FieldHasPrefix(FieldToken, v)) +} + +// TokenHasSuffix applies the HasSuffix predicate on the "token" field. +func TokenHasSuffix(v string) predicate.Sessions { + return predicate.Sessions(sql.FieldHasSuffix(FieldToken, v)) +} + +// TokenEqualFold applies the EqualFold predicate on the "token" field. +func TokenEqualFold(v string) predicate.Sessions { + return predicate.Sessions(sql.FieldEqualFold(FieldToken, v)) +} + +// TokenContainsFold applies the ContainsFold predicate on the "token" field. +func TokenContainsFold(v string) predicate.Sessions { + return predicate.Sessions(sql.FieldContainsFold(FieldToken, v)) +} + +// DataEQ applies the EQ predicate on the "data" field. +func DataEQ(v []byte) predicate.Sessions { + return predicate.Sessions(sql.FieldEQ(FieldData, v)) +} + +// DataNEQ applies the NEQ predicate on the "data" field. +func DataNEQ(v []byte) predicate.Sessions { + return predicate.Sessions(sql.FieldNEQ(FieldData, v)) +} + +// DataIn applies the In predicate on the "data" field. +func DataIn(vs ...[]byte) predicate.Sessions { + return predicate.Sessions(sql.FieldIn(FieldData, vs...)) +} + +// DataNotIn applies the NotIn predicate on the "data" field. +func DataNotIn(vs ...[]byte) predicate.Sessions { + return predicate.Sessions(sql.FieldNotIn(FieldData, vs...)) +} + +// DataGT applies the GT predicate on the "data" field. +func DataGT(v []byte) predicate.Sessions { + return predicate.Sessions(sql.FieldGT(FieldData, v)) +} + +// DataGTE applies the GTE predicate on the "data" field. +func DataGTE(v []byte) predicate.Sessions { + return predicate.Sessions(sql.FieldGTE(FieldData, v)) +} + +// DataLT applies the LT predicate on the "data" field. +func DataLT(v []byte) predicate.Sessions { + return predicate.Sessions(sql.FieldLT(FieldData, v)) +} + +// DataLTE applies the LTE predicate on the "data" field. +func DataLTE(v []byte) predicate.Sessions { + return predicate.Sessions(sql.FieldLTE(FieldData, v)) +} + +// ExpiryEQ applies the EQ predicate on the "expiry" field. +func ExpiryEQ(v time.Time) predicate.Sessions { + return predicate.Sessions(sql.FieldEQ(FieldExpiry, v)) +} + +// ExpiryNEQ applies the NEQ predicate on the "expiry" field. +func ExpiryNEQ(v time.Time) predicate.Sessions { + return predicate.Sessions(sql.FieldNEQ(FieldExpiry, v)) +} + +// ExpiryIn applies the In predicate on the "expiry" field. +func ExpiryIn(vs ...time.Time) predicate.Sessions { + return predicate.Sessions(sql.FieldIn(FieldExpiry, vs...)) +} + +// ExpiryNotIn applies the NotIn predicate on the "expiry" field. +func ExpiryNotIn(vs ...time.Time) predicate.Sessions { + return predicate.Sessions(sql.FieldNotIn(FieldExpiry, vs...)) +} + +// ExpiryGT applies the GT predicate on the "expiry" field. +func ExpiryGT(v time.Time) predicate.Sessions { + return predicate.Sessions(sql.FieldGT(FieldExpiry, v)) +} + +// ExpiryGTE applies the GTE predicate on the "expiry" field. +func ExpiryGTE(v time.Time) predicate.Sessions { + return predicate.Sessions(sql.FieldGTE(FieldExpiry, v)) +} + +// ExpiryLT applies the LT predicate on the "expiry" field. +func ExpiryLT(v time.Time) predicate.Sessions { + return predicate.Sessions(sql.FieldLT(FieldExpiry, v)) +} + +// ExpiryLTE applies the LTE predicate on the "expiry" field. +func ExpiryLTE(v time.Time) predicate.Sessions { + return predicate.Sessions(sql.FieldLTE(FieldExpiry, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Sessions) predicate.Sessions { + return predicate.Sessions(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Sessions) predicate.Sessions { + return predicate.Sessions(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Sessions) predicate.Sessions { + return predicate.Sessions(sql.NotPredicates(p)) +} diff --git a/ent/sessions_create.go b/ent/sessions_create.go new file mode 100644 index 00000000..4750cd13 --- /dev/null +++ b/ent/sessions_create.go @@ -0,0 +1,543 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/zibbp/ganymede/ent/sessions" +) + +// SessionsCreate is the builder for creating a Sessions entity. +type SessionsCreate struct { + config + mutation *SessionsMutation + hooks []Hook + conflict []sql.ConflictOption +} + +// SetToken sets the "token" field. +func (sc *SessionsCreate) SetToken(s string) *SessionsCreate { + sc.mutation.SetToken(s) + return sc +} + +// SetData sets the "data" field. +func (sc *SessionsCreate) SetData(b []byte) *SessionsCreate { + sc.mutation.SetData(b) + return sc +} + +// SetExpiry sets the "expiry" field. +func (sc *SessionsCreate) SetExpiry(t time.Time) *SessionsCreate { + sc.mutation.SetExpiry(t) + return sc +} + +// Mutation returns the SessionsMutation object of the builder. +func (sc *SessionsCreate) Mutation() *SessionsMutation { + return sc.mutation +} + +// Save creates the Sessions in the database. +func (sc *SessionsCreate) Save(ctx context.Context) (*Sessions, error) { + return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (sc *SessionsCreate) SaveX(ctx context.Context) *Sessions { + v, err := sc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (sc *SessionsCreate) Exec(ctx context.Context) error { + _, err := sc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (sc *SessionsCreate) ExecX(ctx context.Context) { + if err := sc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (sc *SessionsCreate) check() error { + if _, ok := sc.mutation.Token(); !ok { + return &ValidationError{Name: "token", err: errors.New(`ent: missing required field "Sessions.token"`)} + } + if v, ok := sc.mutation.Token(); ok { + if err := sessions.TokenValidator(v); err != nil { + return &ValidationError{Name: "token", err: fmt.Errorf(`ent: validator failed for field "Sessions.token": %w`, err)} + } + } + if _, ok := sc.mutation.Data(); !ok { + return &ValidationError{Name: "data", err: errors.New(`ent: missing required field "Sessions.data"`)} + } + if v, ok := sc.mutation.Data(); ok { + if err := sessions.DataValidator(v); err != nil { + return &ValidationError{Name: "data", err: fmt.Errorf(`ent: validator failed for field "Sessions.data": %w`, err)} + } + } + if _, ok := sc.mutation.Expiry(); !ok { + return &ValidationError{Name: "expiry", err: errors.New(`ent: missing required field "Sessions.expiry"`)} + } + return nil +} + +func (sc *SessionsCreate) sqlSave(ctx context.Context) (*Sessions, error) { + if err := sc.check(); err != nil { + return nil, err + } + _node, _spec := sc.createSpec() + if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + sc.mutation.id = &_node.ID + sc.mutation.done = true + return _node, nil +} + +func (sc *SessionsCreate) createSpec() (*Sessions, *sqlgraph.CreateSpec) { + var ( + _node = &Sessions{config: sc.config} + _spec = sqlgraph.NewCreateSpec(sessions.Table, sqlgraph.NewFieldSpec(sessions.FieldID, field.TypeInt)) + ) + _spec.OnConflict = sc.conflict + if value, ok := sc.mutation.Token(); ok { + _spec.SetField(sessions.FieldToken, field.TypeString, value) + _node.Token = value + } + if value, ok := sc.mutation.Data(); ok { + _spec.SetField(sessions.FieldData, field.TypeBytes, value) + _node.Data = value + } + if value, ok := sc.mutation.Expiry(); ok { + _spec.SetField(sessions.FieldExpiry, field.TypeTime, value) + _node.Expiry = value + } + return _node, _spec +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Sessions.Create(). +// SetToken(v). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.SessionsUpsert) { +// SetToken(v+v). +// }). +// Exec(ctx) +func (sc *SessionsCreate) OnConflict(opts ...sql.ConflictOption) *SessionsUpsertOne { + sc.conflict = opts + return &SessionsUpsertOne{ + create: sc, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Sessions.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (sc *SessionsCreate) OnConflictColumns(columns ...string) *SessionsUpsertOne { + sc.conflict = append(sc.conflict, sql.ConflictColumns(columns...)) + return &SessionsUpsertOne{ + create: sc, + } +} + +type ( + // SessionsUpsertOne is the builder for "upsert"-ing + // one Sessions node. + SessionsUpsertOne struct { + create *SessionsCreate + } + + // SessionsUpsert is the "OnConflict" setter. + SessionsUpsert struct { + *sql.UpdateSet + } +) + +// SetData sets the "data" field. +func (u *SessionsUpsert) SetData(v []byte) *SessionsUpsert { + u.Set(sessions.FieldData, v) + return u +} + +// UpdateData sets the "data" field to the value that was provided on create. +func (u *SessionsUpsert) UpdateData() *SessionsUpsert { + u.SetExcluded(sessions.FieldData) + return u +} + +// SetExpiry sets the "expiry" field. +func (u *SessionsUpsert) SetExpiry(v time.Time) *SessionsUpsert { + u.Set(sessions.FieldExpiry, v) + return u +} + +// UpdateExpiry sets the "expiry" field to the value that was provided on create. +func (u *SessionsUpsert) UpdateExpiry() *SessionsUpsert { + u.SetExcluded(sessions.FieldExpiry) + return u +} + +// UpdateNewValues updates the mutable fields using the new values that were set on create. +// Using this option is equivalent to using: +// +// client.Sessions.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *SessionsUpsertOne) UpdateNewValues() *SessionsUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + if _, exists := u.create.mutation.Token(); exists { + s.SetIgnore(sessions.FieldToken) + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Sessions.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *SessionsUpsertOne) Ignore() *SessionsUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *SessionsUpsertOne) DoNothing() *SessionsUpsertOne { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the SessionsCreate.OnConflict +// documentation for more info. +func (u *SessionsUpsertOne) Update(set func(*SessionsUpsert)) *SessionsUpsertOne { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&SessionsUpsert{UpdateSet: update}) + })) + return u +} + +// SetData sets the "data" field. +func (u *SessionsUpsertOne) SetData(v []byte) *SessionsUpsertOne { + return u.Update(func(s *SessionsUpsert) { + s.SetData(v) + }) +} + +// UpdateData sets the "data" field to the value that was provided on create. +func (u *SessionsUpsertOne) UpdateData() *SessionsUpsertOne { + return u.Update(func(s *SessionsUpsert) { + s.UpdateData() + }) +} + +// SetExpiry sets the "expiry" field. +func (u *SessionsUpsertOne) SetExpiry(v time.Time) *SessionsUpsertOne { + return u.Update(func(s *SessionsUpsert) { + s.SetExpiry(v) + }) +} + +// UpdateExpiry sets the "expiry" field to the value that was provided on create. +func (u *SessionsUpsertOne) UpdateExpiry() *SessionsUpsertOne { + return u.Update(func(s *SessionsUpsert) { + s.UpdateExpiry() + }) +} + +// Exec executes the query. +func (u *SessionsUpsertOne) Exec(ctx context.Context) error { + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for SessionsCreate.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *SessionsUpsertOne) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} + +// Exec executes the UPSERT query and returns the inserted/updated ID. +func (u *SessionsUpsertOne) ID(ctx context.Context) (id int, err error) { + node, err := u.create.Save(ctx) + if err != nil { + return id, err + } + return node.ID, nil +} + +// IDX is like ID, but panics if an error occurs. +func (u *SessionsUpsertOne) IDX(ctx context.Context) int { + id, err := u.ID(ctx) + if err != nil { + panic(err) + } + return id +} + +// SessionsCreateBulk is the builder for creating many Sessions entities in bulk. +type SessionsCreateBulk struct { + config + err error + builders []*SessionsCreate + conflict []sql.ConflictOption +} + +// Save creates the Sessions entities in the database. +func (scb *SessionsCreateBulk) Save(ctx context.Context) ([]*Sessions, error) { + if scb.err != nil { + return nil, scb.err + } + specs := make([]*sqlgraph.CreateSpec, len(scb.builders)) + nodes := make([]*Sessions, len(scb.builders)) + mutators := make([]Mutator, len(scb.builders)) + for i := range scb.builders { + func(i int, root context.Context) { + builder := scb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*SessionsMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, scb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + spec.OnConflict = scb.conflict + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, scb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, scb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (scb *SessionsCreateBulk) SaveX(ctx context.Context) []*Sessions { + v, err := scb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (scb *SessionsCreateBulk) Exec(ctx context.Context) error { + _, err := scb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (scb *SessionsCreateBulk) ExecX(ctx context.Context) { + if err := scb.Exec(ctx); err != nil { + panic(err) + } +} + +// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause +// of the `INSERT` statement. For example: +// +// client.Sessions.CreateBulk(builders...). +// OnConflict( +// // Update the row with the new values +// // the was proposed for insertion. +// sql.ResolveWithNewValues(), +// ). +// // Override some of the fields with custom +// // update values. +// Update(func(u *ent.SessionsUpsert) { +// SetToken(v+v). +// }). +// Exec(ctx) +func (scb *SessionsCreateBulk) OnConflict(opts ...sql.ConflictOption) *SessionsUpsertBulk { + scb.conflict = opts + return &SessionsUpsertBulk{ + create: scb, + } +} + +// OnConflictColumns calls `OnConflict` and configures the columns +// as conflict target. Using this option is equivalent to using: +// +// client.Sessions.Create(). +// OnConflict(sql.ConflictColumns(columns...)). +// Exec(ctx) +func (scb *SessionsCreateBulk) OnConflictColumns(columns ...string) *SessionsUpsertBulk { + scb.conflict = append(scb.conflict, sql.ConflictColumns(columns...)) + return &SessionsUpsertBulk{ + create: scb, + } +} + +// SessionsUpsertBulk is the builder for "upsert"-ing +// a bulk of Sessions nodes. +type SessionsUpsertBulk struct { + create *SessionsCreateBulk +} + +// UpdateNewValues updates the mutable fields using the new values that +// were set on create. Using this option is equivalent to using: +// +// client.Sessions.Create(). +// OnConflict( +// sql.ResolveWithNewValues(), +// ). +// Exec(ctx) +func (u *SessionsUpsertBulk) UpdateNewValues() *SessionsUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { + for _, b := range u.create.builders { + if _, exists := b.mutation.Token(); exists { + s.SetIgnore(sessions.FieldToken) + } + } + })) + return u +} + +// Ignore sets each column to itself in case of conflict. +// Using this option is equivalent to using: +// +// client.Sessions.Create(). +// OnConflict(sql.ResolveWithIgnore()). +// Exec(ctx) +func (u *SessionsUpsertBulk) Ignore() *SessionsUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) + return u +} + +// DoNothing configures the conflict_action to `DO NOTHING`. +// Supported only by SQLite and PostgreSQL. +func (u *SessionsUpsertBulk) DoNothing() *SessionsUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.DoNothing()) + return u +} + +// Update allows overriding fields `UPDATE` values. See the SessionsCreateBulk.OnConflict +// documentation for more info. +func (u *SessionsUpsertBulk) Update(set func(*SessionsUpsert)) *SessionsUpsertBulk { + u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { + set(&SessionsUpsert{UpdateSet: update}) + })) + return u +} + +// SetData sets the "data" field. +func (u *SessionsUpsertBulk) SetData(v []byte) *SessionsUpsertBulk { + return u.Update(func(s *SessionsUpsert) { + s.SetData(v) + }) +} + +// UpdateData sets the "data" field to the value that was provided on create. +func (u *SessionsUpsertBulk) UpdateData() *SessionsUpsertBulk { + return u.Update(func(s *SessionsUpsert) { + s.UpdateData() + }) +} + +// SetExpiry sets the "expiry" field. +func (u *SessionsUpsertBulk) SetExpiry(v time.Time) *SessionsUpsertBulk { + return u.Update(func(s *SessionsUpsert) { + s.SetExpiry(v) + }) +} + +// UpdateExpiry sets the "expiry" field to the value that was provided on create. +func (u *SessionsUpsertBulk) UpdateExpiry() *SessionsUpsertBulk { + return u.Update(func(s *SessionsUpsert) { + s.UpdateExpiry() + }) +} + +// Exec executes the query. +func (u *SessionsUpsertBulk) Exec(ctx context.Context) error { + if u.create.err != nil { + return u.create.err + } + for i, b := range u.create.builders { + if len(b.conflict) != 0 { + return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the SessionsCreateBulk instead", i) + } + } + if len(u.create.conflict) == 0 { + return errors.New("ent: missing options for SessionsCreateBulk.OnConflict") + } + return u.create.Exec(ctx) +} + +// ExecX is like Exec, but panics if an error occurs. +func (u *SessionsUpsertBulk) ExecX(ctx context.Context) { + if err := u.create.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/sessions_delete.go b/ent/sessions_delete.go new file mode 100644 index 00000000..98dde758 --- /dev/null +++ b/ent/sessions_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/zibbp/ganymede/ent/predicate" + "github.com/zibbp/ganymede/ent/sessions" +) + +// SessionsDelete is the builder for deleting a Sessions entity. +type SessionsDelete struct { + config + hooks []Hook + mutation *SessionsMutation +} + +// Where appends a list predicates to the SessionsDelete builder. +func (sd *SessionsDelete) Where(ps ...predicate.Sessions) *SessionsDelete { + sd.mutation.Where(ps...) + return sd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (sd *SessionsDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, sd.sqlExec, sd.mutation, sd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (sd *SessionsDelete) ExecX(ctx context.Context) int { + n, err := sd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (sd *SessionsDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(sessions.Table, sqlgraph.NewFieldSpec(sessions.FieldID, field.TypeInt)) + if ps := sd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + sd.mutation.done = true + return affected, err +} + +// SessionsDeleteOne is the builder for deleting a single Sessions entity. +type SessionsDeleteOne struct { + sd *SessionsDelete +} + +// Where appends a list predicates to the SessionsDelete builder. +func (sdo *SessionsDeleteOne) Where(ps ...predicate.Sessions) *SessionsDeleteOne { + sdo.sd.mutation.Where(ps...) + return sdo +} + +// Exec executes the deletion query. +func (sdo *SessionsDeleteOne) Exec(ctx context.Context) error { + n, err := sdo.sd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{sessions.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (sdo *SessionsDeleteOne) ExecX(ctx context.Context) { + if err := sdo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/sessions_query.go b/ent/sessions_query.go new file mode 100644 index 00000000..7e904227 --- /dev/null +++ b/ent/sessions_query.go @@ -0,0 +1,526 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/zibbp/ganymede/ent/predicate" + "github.com/zibbp/ganymede/ent/sessions" +) + +// SessionsQuery is the builder for querying Sessions entities. +type SessionsQuery struct { + config + ctx *QueryContext + order []sessions.OrderOption + inters []Interceptor + predicates []predicate.Sessions + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the SessionsQuery builder. +func (sq *SessionsQuery) Where(ps ...predicate.Sessions) *SessionsQuery { + sq.predicates = append(sq.predicates, ps...) + return sq +} + +// Limit the number of records to be returned by this query. +func (sq *SessionsQuery) Limit(limit int) *SessionsQuery { + sq.ctx.Limit = &limit + return sq +} + +// Offset to start from. +func (sq *SessionsQuery) Offset(offset int) *SessionsQuery { + sq.ctx.Offset = &offset + return sq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (sq *SessionsQuery) Unique(unique bool) *SessionsQuery { + sq.ctx.Unique = &unique + return sq +} + +// Order specifies how the records should be ordered. +func (sq *SessionsQuery) Order(o ...sessions.OrderOption) *SessionsQuery { + sq.order = append(sq.order, o...) + return sq +} + +// First returns the first Sessions entity from the query. +// Returns a *NotFoundError when no Sessions was found. +func (sq *SessionsQuery) First(ctx context.Context) (*Sessions, error) { + nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First")) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{sessions.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (sq *SessionsQuery) FirstX(ctx context.Context) *Sessions { + node, err := sq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Sessions ID from the query. +// Returns a *NotFoundError when no Sessions ID was found. +func (sq *SessionsQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{sessions.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (sq *SessionsQuery) FirstIDX(ctx context.Context) int { + id, err := sq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Sessions entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Sessions entity is found. +// Returns a *NotFoundError when no Sessions entities are found. +func (sq *SessionsQuery) Only(ctx context.Context) (*Sessions, error) { + nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only")) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{sessions.Label} + default: + return nil, &NotSingularError{sessions.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (sq *SessionsQuery) OnlyX(ctx context.Context) *Sessions { + node, err := sq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Sessions ID in the query. +// Returns a *NotSingularError when more than one Sessions ID is found. +// Returns a *NotFoundError when no entities are found. +func (sq *SessionsQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{sessions.Label} + default: + err = &NotSingularError{sessions.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (sq *SessionsQuery) OnlyIDX(ctx context.Context) int { + id, err := sq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of SessionsSlice. +func (sq *SessionsQuery) All(ctx context.Context) ([]*Sessions, error) { + ctx = setContextOp(ctx, sq.ctx, "All") + if err := sq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Sessions, *SessionsQuery]() + return withInterceptors[[]*Sessions](ctx, sq, qr, sq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (sq *SessionsQuery) AllX(ctx context.Context) []*Sessions { + nodes, err := sq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Sessions IDs. +func (sq *SessionsQuery) IDs(ctx context.Context) (ids []int, err error) { + if sq.ctx.Unique == nil && sq.path != nil { + sq.Unique(true) + } + ctx = setContextOp(ctx, sq.ctx, "IDs") + if err = sq.Select(sessions.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (sq *SessionsQuery) IDsX(ctx context.Context) []int { + ids, err := sq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (sq *SessionsQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, sq.ctx, "Count") + if err := sq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, sq, querierCount[*SessionsQuery](), sq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (sq *SessionsQuery) CountX(ctx context.Context) int { + count, err := sq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (sq *SessionsQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, sq.ctx, "Exist") + switch _, err := sq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (sq *SessionsQuery) ExistX(ctx context.Context) bool { + exist, err := sq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the SessionsQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (sq *SessionsQuery) Clone() *SessionsQuery { + if sq == nil { + return nil + } + return &SessionsQuery{ + config: sq.config, + ctx: sq.ctx.Clone(), + order: append([]sessions.OrderOption{}, sq.order...), + inters: append([]Interceptor{}, sq.inters...), + predicates: append([]predicate.Sessions{}, sq.predicates...), + // clone intermediate query. + sql: sq.sql.Clone(), + path: sq.path, + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// Token string `json:"token,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Sessions.Query(). +// GroupBy(sessions.FieldToken). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (sq *SessionsQuery) GroupBy(field string, fields ...string) *SessionsGroupBy { + sq.ctx.Fields = append([]string{field}, fields...) + grbuild := &SessionsGroupBy{build: sq} + grbuild.flds = &sq.ctx.Fields + grbuild.label = sessions.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// Token string `json:"token,omitempty"` +// } +// +// client.Sessions.Query(). +// Select(sessions.FieldToken). +// Scan(ctx, &v) +func (sq *SessionsQuery) Select(fields ...string) *SessionsSelect { + sq.ctx.Fields = append(sq.ctx.Fields, fields...) + sbuild := &SessionsSelect{SessionsQuery: sq} + sbuild.label = sessions.Label + sbuild.flds, sbuild.scan = &sq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a SessionsSelect configured with the given aggregations. +func (sq *SessionsQuery) Aggregate(fns ...AggregateFunc) *SessionsSelect { + return sq.Select().Aggregate(fns...) +} + +func (sq *SessionsQuery) prepareQuery(ctx context.Context) error { + for _, inter := range sq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, sq); err != nil { + return err + } + } + } + for _, f := range sq.ctx.Fields { + if !sessions.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if sq.path != nil { + prev, err := sq.path(ctx) + if err != nil { + return err + } + sq.sql = prev + } + return nil +} + +func (sq *SessionsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Sessions, error) { + var ( + nodes = []*Sessions{} + _spec = sq.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Sessions).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Sessions{config: sq.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (sq *SessionsQuery) sqlCount(ctx context.Context) (int, error) { + _spec := sq.querySpec() + _spec.Node.Columns = sq.ctx.Fields + if len(sq.ctx.Fields) > 0 { + _spec.Unique = sq.ctx.Unique != nil && *sq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, sq.driver, _spec) +} + +func (sq *SessionsQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(sessions.Table, sessions.Columns, sqlgraph.NewFieldSpec(sessions.FieldID, field.TypeInt)) + _spec.From = sq.sql + if unique := sq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if sq.path != nil { + _spec.Unique = true + } + if fields := sq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, sessions.FieldID) + for i := range fields { + if fields[i] != sessions.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := sq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := sq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := sq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := sq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (sq *SessionsQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(sq.driver.Dialect()) + t1 := builder.Table(sessions.Table) + columns := sq.ctx.Fields + if len(columns) == 0 { + columns = sessions.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if sq.sql != nil { + selector = sq.sql + selector.Select(selector.Columns(columns...)...) + } + if sq.ctx.Unique != nil && *sq.ctx.Unique { + selector.Distinct() + } + for _, p := range sq.predicates { + p(selector) + } + for _, p := range sq.order { + p(selector) + } + if offset := sq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := sq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// SessionsGroupBy is the group-by builder for Sessions entities. +type SessionsGroupBy struct { + selector + build *SessionsQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (sgb *SessionsGroupBy) Aggregate(fns ...AggregateFunc) *SessionsGroupBy { + sgb.fns = append(sgb.fns, fns...) + return sgb +} + +// Scan applies the selector query and scans the result into the given value. +func (sgb *SessionsGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy") + if err := sgb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*SessionsQuery, *SessionsGroupBy](ctx, sgb.build, sgb, sgb.build.inters, v) +} + +func (sgb *SessionsGroupBy) sqlScan(ctx context.Context, root *SessionsQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(sgb.fns)) + for _, fn := range sgb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*sgb.flds)+len(sgb.fns)) + for _, f := range *sgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*sgb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := sgb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// SessionsSelect is the builder for selecting fields of Sessions entities. +type SessionsSelect struct { + *SessionsQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (ss *SessionsSelect) Aggregate(fns ...AggregateFunc) *SessionsSelect { + ss.fns = append(ss.fns, fns...) + return ss +} + +// Scan applies the selector query and scans the result into the given value. +func (ss *SessionsSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ss.ctx, "Select") + if err := ss.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*SessionsQuery, *SessionsSelect](ctx, ss.SessionsQuery, ss, ss.inters, v) +} + +func (ss *SessionsSelect) sqlScan(ctx context.Context, root *SessionsQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(ss.fns)) + for _, fn := range ss.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*ss.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ss.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/ent/sessions_update.go b/ent/sessions_update.go new file mode 100644 index 00000000..08e7652d --- /dev/null +++ b/ent/sessions_update.go @@ -0,0 +1,254 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" + "github.com/zibbp/ganymede/ent/predicate" + "github.com/zibbp/ganymede/ent/sessions" +) + +// SessionsUpdate is the builder for updating Sessions entities. +type SessionsUpdate struct { + config + hooks []Hook + mutation *SessionsMutation +} + +// Where appends a list predicates to the SessionsUpdate builder. +func (su *SessionsUpdate) Where(ps ...predicate.Sessions) *SessionsUpdate { + su.mutation.Where(ps...) + return su +} + +// SetData sets the "data" field. +func (su *SessionsUpdate) SetData(b []byte) *SessionsUpdate { + su.mutation.SetData(b) + return su +} + +// SetExpiry sets the "expiry" field. +func (su *SessionsUpdate) SetExpiry(t time.Time) *SessionsUpdate { + su.mutation.SetExpiry(t) + return su +} + +// SetNillableExpiry sets the "expiry" field if the given value is not nil. +func (su *SessionsUpdate) SetNillableExpiry(t *time.Time) *SessionsUpdate { + if t != nil { + su.SetExpiry(*t) + } + return su +} + +// Mutation returns the SessionsMutation object of the builder. +func (su *SessionsUpdate) Mutation() *SessionsMutation { + return su.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (su *SessionsUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, su.sqlSave, su.mutation, su.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (su *SessionsUpdate) SaveX(ctx context.Context) int { + affected, err := su.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (su *SessionsUpdate) Exec(ctx context.Context) error { + _, err := su.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (su *SessionsUpdate) ExecX(ctx context.Context) { + if err := su.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (su *SessionsUpdate) check() error { + if v, ok := su.mutation.Data(); ok { + if err := sessions.DataValidator(v); err != nil { + return &ValidationError{Name: "data", err: fmt.Errorf(`ent: validator failed for field "Sessions.data": %w`, err)} + } + } + return nil +} + +func (su *SessionsUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := su.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(sessions.Table, sessions.Columns, sqlgraph.NewFieldSpec(sessions.FieldID, field.TypeInt)) + if ps := su.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := su.mutation.Data(); ok { + _spec.SetField(sessions.FieldData, field.TypeBytes, value) + } + if value, ok := su.mutation.Expiry(); ok { + _spec.SetField(sessions.FieldExpiry, field.TypeTime, value) + } + if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{sessions.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + su.mutation.done = true + return n, nil +} + +// SessionsUpdateOne is the builder for updating a single Sessions entity. +type SessionsUpdateOne struct { + config + fields []string + hooks []Hook + mutation *SessionsMutation +} + +// SetData sets the "data" field. +func (suo *SessionsUpdateOne) SetData(b []byte) *SessionsUpdateOne { + suo.mutation.SetData(b) + return suo +} + +// SetExpiry sets the "expiry" field. +func (suo *SessionsUpdateOne) SetExpiry(t time.Time) *SessionsUpdateOne { + suo.mutation.SetExpiry(t) + return suo +} + +// SetNillableExpiry sets the "expiry" field if the given value is not nil. +func (suo *SessionsUpdateOne) SetNillableExpiry(t *time.Time) *SessionsUpdateOne { + if t != nil { + suo.SetExpiry(*t) + } + return suo +} + +// Mutation returns the SessionsMutation object of the builder. +func (suo *SessionsUpdateOne) Mutation() *SessionsMutation { + return suo.mutation +} + +// Where appends a list predicates to the SessionsUpdate builder. +func (suo *SessionsUpdateOne) Where(ps ...predicate.Sessions) *SessionsUpdateOne { + suo.mutation.Where(ps...) + return suo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (suo *SessionsUpdateOne) Select(field string, fields ...string) *SessionsUpdateOne { + suo.fields = append([]string{field}, fields...) + return suo +} + +// Save executes the query and returns the updated Sessions entity. +func (suo *SessionsUpdateOne) Save(ctx context.Context) (*Sessions, error) { + return withHooks(ctx, suo.sqlSave, suo.mutation, suo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (suo *SessionsUpdateOne) SaveX(ctx context.Context) *Sessions { + node, err := suo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (suo *SessionsUpdateOne) Exec(ctx context.Context) error { + _, err := suo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (suo *SessionsUpdateOne) ExecX(ctx context.Context) { + if err := suo.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (suo *SessionsUpdateOne) check() error { + if v, ok := suo.mutation.Data(); ok { + if err := sessions.DataValidator(v); err != nil { + return &ValidationError{Name: "data", err: fmt.Errorf(`ent: validator failed for field "Sessions.data": %w`, err)} + } + } + return nil +} + +func (suo *SessionsUpdateOne) sqlSave(ctx context.Context) (_node *Sessions, err error) { + if err := suo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(sessions.Table, sessions.Columns, sqlgraph.NewFieldSpec(sessions.FieldID, field.TypeInt)) + id, ok := suo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Sessions.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := suo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, sessions.FieldID) + for _, f := range fields { + if !sessions.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != sessions.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := suo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := suo.mutation.Data(); ok { + _spec.SetField(sessions.FieldData, field.TypeBytes, value) + } + if value, ok := suo.mutation.Expiry(); ok { + _spec.SetField(sessions.FieldExpiry, field.TypeTime, value) + } + _node = &Sessions{config: suo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{sessions.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + suo.mutation.done = true + return _node, nil +} diff --git a/ent/tx.go b/ent/tx.go index 0456ac0d..454bb269 100644 --- a/ent/tx.go +++ b/ent/tx.go @@ -34,6 +34,8 @@ type Tx struct { Playlist *PlaylistClient // Queue is the client for interacting with the Queue builders. Queue *QueueClient + // Sessions is the client for interacting with the Sessions builders. + Sessions *SessionsClient // TwitchCategory is the client for interacting with the TwitchCategory builders. TwitchCategory *TwitchCategoryClient // User is the client for interacting with the User builders. @@ -182,6 +184,7 @@ func (tx *Tx) init() { tx.Playback = NewPlaybackClient(tx.config) tx.Playlist = NewPlaylistClient(tx.config) tx.Queue = NewQueueClient(tx.config) + tx.Sessions = NewSessionsClient(tx.config) tx.TwitchCategory = NewTwitchCategoryClient(tx.config) tx.User = NewUserClient(tx.config) tx.Vod = NewVodClient(tx.config) diff --git a/ent/vod.go b/ent/vod.go index 34acb2de..b747bf8c 100644 --- a/ent/vod.go +++ b/ent/vod.go @@ -3,6 +3,7 @@ package ent import ( + "encoding/json" "fmt" "strings" "time" @@ -23,6 +24,8 @@ type Vod struct { ID uuid.UUID `json:"id,omitempty"` // The ID of the video on the external platform. ExtID string `json:"ext_id,omitempty"` + // The external VOD ID of a clip. This is only populated if the clip is linked to a video. + ClipExtVodID string `json:"clip_ext_vod_id,omitempty"` // The ID of the stream on the external platform, if applicable. ExtStreamID string `json:"ext_stream_id,omitempty"` // The platform the VOD is from, takes an enum. @@ -33,6 +36,8 @@ type Vod struct { Title string `json:"title,omitempty"` // Duration holds the value of the "duration" field. Duration int `json:"duration,omitempty"` + // The offset in seconds to where the clip starts in the VOD. This is only populdated if the video is a clip. + ClipVodOffset int `json:"clip_vod_offset,omitempty"` // Views holds the value of the "views" field. Views int `json:"views,omitempty"` // Resolution holds the value of the "resolution" field. @@ -81,6 +86,20 @@ type Vod struct { Locked bool `json:"locked,omitempty"` // LocalViews holds the value of the "local_views" field. LocalViews int `json:"local_views,omitempty"` + // SpriteThumbnailsEnabled holds the value of the "sprite_thumbnails_enabled" field. + SpriteThumbnailsEnabled bool `json:"sprite_thumbnails_enabled,omitempty"` + // SpriteThumbnailsImages holds the value of the "sprite_thumbnails_images" field. + SpriteThumbnailsImages []string `json:"sprite_thumbnails_images,omitempty"` + // SpriteThumbnailsInterval holds the value of the "sprite_thumbnails_interval" field. + SpriteThumbnailsInterval int `json:"sprite_thumbnails_interval,omitempty"` + // SpriteThumbnailsWidth holds the value of the "sprite_thumbnails_width" field. + SpriteThumbnailsWidth int `json:"sprite_thumbnails_width,omitempty"` + // SpriteThumbnailsHeight holds the value of the "sprite_thumbnails_height" field. + SpriteThumbnailsHeight int `json:"sprite_thumbnails_height,omitempty"` + // SpriteThumbnailsRows holds the value of the "sprite_thumbnails_rows" field. + SpriteThumbnailsRows int `json:"sprite_thumbnails_rows,omitempty"` + // SpriteThumbnailsColumns holds the value of the "sprite_thumbnails_columns" field. + SpriteThumbnailsColumns int `json:"sprite_thumbnails_columns,omitempty"` // The time the VOD was streamed. StreamedAt time.Time `json:"streamed_at,omitempty"` // UpdatedAt holds the value of the "updated_at" field. @@ -176,11 +195,13 @@ func (*Vod) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case vod.FieldProcessing, vod.FieldLocked: + case vod.FieldSpriteThumbnailsImages: + values[i] = new([]byte) + case vod.FieldProcessing, vod.FieldLocked, vod.FieldSpriteThumbnailsEnabled: values[i] = new(sql.NullBool) - case vod.FieldDuration, vod.FieldViews, vod.FieldLocalViews: + case vod.FieldDuration, vod.FieldClipVodOffset, vod.FieldViews, vod.FieldLocalViews, vod.FieldSpriteThumbnailsInterval, vod.FieldSpriteThumbnailsWidth, vod.FieldSpriteThumbnailsHeight, vod.FieldSpriteThumbnailsRows, vod.FieldSpriteThumbnailsColumns: values[i] = new(sql.NullInt64) - case vod.FieldExtID, vod.FieldExtStreamID, vod.FieldPlatform, vod.FieldType, vod.FieldTitle, vod.FieldResolution, vod.FieldThumbnailPath, vod.FieldWebThumbnailPath, vod.FieldVideoPath, vod.FieldVideoHlsPath, vod.FieldChatPath, vod.FieldLiveChatPath, vod.FieldLiveChatConvertPath, vod.FieldChatVideoPath, vod.FieldInfoPath, vod.FieldCaptionPath, vod.FieldFolderName, vod.FieldFileName, vod.FieldTmpVideoDownloadPath, vod.FieldTmpVideoConvertPath, vod.FieldTmpChatDownloadPath, vod.FieldTmpLiveChatDownloadPath, vod.FieldTmpLiveChatConvertPath, vod.FieldTmpChatRenderPath, vod.FieldTmpVideoHlsPath: + case vod.FieldExtID, vod.FieldClipExtVodID, vod.FieldExtStreamID, vod.FieldPlatform, vod.FieldType, vod.FieldTitle, vod.FieldResolution, vod.FieldThumbnailPath, vod.FieldWebThumbnailPath, vod.FieldVideoPath, vod.FieldVideoHlsPath, vod.FieldChatPath, vod.FieldLiveChatPath, vod.FieldLiveChatConvertPath, vod.FieldChatVideoPath, vod.FieldInfoPath, vod.FieldCaptionPath, vod.FieldFolderName, vod.FieldFileName, vod.FieldTmpVideoDownloadPath, vod.FieldTmpVideoConvertPath, vod.FieldTmpChatDownloadPath, vod.FieldTmpLiveChatDownloadPath, vod.FieldTmpLiveChatConvertPath, vod.FieldTmpChatRenderPath, vod.FieldTmpVideoHlsPath: values[i] = new(sql.NullString) case vod.FieldStreamedAt, vod.FieldUpdatedAt, vod.FieldCreatedAt: values[i] = new(sql.NullTime) @@ -215,6 +236,12 @@ func (v *Vod) assignValues(columns []string, values []any) error { } else if value.Valid { v.ExtID = value.String } + case vod.FieldClipExtVodID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field clip_ext_vod_id", values[i]) + } else if value.Valid { + v.ClipExtVodID = value.String + } case vod.FieldExtStreamID: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field ext_stream_id", values[i]) @@ -245,6 +272,12 @@ func (v *Vod) assignValues(columns []string, values []any) error { } else if value.Valid { v.Duration = int(value.Int64) } + case vod.FieldClipVodOffset: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field clip_vod_offset", values[i]) + } else if value.Valid { + v.ClipVodOffset = int(value.Int64) + } case vod.FieldViews: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field views", values[i]) @@ -389,6 +422,50 @@ func (v *Vod) assignValues(columns []string, values []any) error { } else if value.Valid { v.LocalViews = int(value.Int64) } + case vod.FieldSpriteThumbnailsEnabled: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field sprite_thumbnails_enabled", values[i]) + } else if value.Valid { + v.SpriteThumbnailsEnabled = value.Bool + } + case vod.FieldSpriteThumbnailsImages: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field sprite_thumbnails_images", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &v.SpriteThumbnailsImages); err != nil { + return fmt.Errorf("unmarshal field sprite_thumbnails_images: %w", err) + } + } + case vod.FieldSpriteThumbnailsInterval: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field sprite_thumbnails_interval", values[i]) + } else if value.Valid { + v.SpriteThumbnailsInterval = int(value.Int64) + } + case vod.FieldSpriteThumbnailsWidth: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field sprite_thumbnails_width", values[i]) + } else if value.Valid { + v.SpriteThumbnailsWidth = int(value.Int64) + } + case vod.FieldSpriteThumbnailsHeight: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field sprite_thumbnails_height", values[i]) + } else if value.Valid { + v.SpriteThumbnailsHeight = int(value.Int64) + } + case vod.FieldSpriteThumbnailsRows: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field sprite_thumbnails_rows", values[i]) + } else if value.Valid { + v.SpriteThumbnailsRows = int(value.Int64) + } + case vod.FieldSpriteThumbnailsColumns: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field sprite_thumbnails_columns", values[i]) + } else if value.Valid { + v.SpriteThumbnailsColumns = int(value.Int64) + } case vod.FieldStreamedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field streamed_at", values[i]) @@ -483,6 +560,9 @@ func (v *Vod) String() string { builder.WriteString("ext_id=") builder.WriteString(v.ExtID) builder.WriteString(", ") + builder.WriteString("clip_ext_vod_id=") + builder.WriteString(v.ClipExtVodID) + builder.WriteString(", ") builder.WriteString("ext_stream_id=") builder.WriteString(v.ExtStreamID) builder.WriteString(", ") @@ -498,6 +578,9 @@ func (v *Vod) String() string { builder.WriteString("duration=") builder.WriteString(fmt.Sprintf("%v", v.Duration)) builder.WriteString(", ") + builder.WriteString("clip_vod_offset=") + builder.WriteString(fmt.Sprintf("%v", v.ClipVodOffset)) + builder.WriteString(", ") builder.WriteString("views=") builder.WriteString(fmt.Sprintf("%v", v.Views)) builder.WriteString(", ") @@ -570,6 +653,27 @@ func (v *Vod) String() string { builder.WriteString("local_views=") builder.WriteString(fmt.Sprintf("%v", v.LocalViews)) builder.WriteString(", ") + builder.WriteString("sprite_thumbnails_enabled=") + builder.WriteString(fmt.Sprintf("%v", v.SpriteThumbnailsEnabled)) + builder.WriteString(", ") + builder.WriteString("sprite_thumbnails_images=") + builder.WriteString(fmt.Sprintf("%v", v.SpriteThumbnailsImages)) + builder.WriteString(", ") + builder.WriteString("sprite_thumbnails_interval=") + builder.WriteString(fmt.Sprintf("%v", v.SpriteThumbnailsInterval)) + builder.WriteString(", ") + builder.WriteString("sprite_thumbnails_width=") + builder.WriteString(fmt.Sprintf("%v", v.SpriteThumbnailsWidth)) + builder.WriteString(", ") + builder.WriteString("sprite_thumbnails_height=") + builder.WriteString(fmt.Sprintf("%v", v.SpriteThumbnailsHeight)) + builder.WriteString(", ") + builder.WriteString("sprite_thumbnails_rows=") + builder.WriteString(fmt.Sprintf("%v", v.SpriteThumbnailsRows)) + builder.WriteString(", ") + builder.WriteString("sprite_thumbnails_columns=") + builder.WriteString(fmt.Sprintf("%v", v.SpriteThumbnailsColumns)) + builder.WriteString(", ") builder.WriteString("streamed_at=") builder.WriteString(v.StreamedAt.Format(time.ANSIC)) builder.WriteString(", ") diff --git a/ent/vod/vod.go b/ent/vod/vod.go index a6684544..d4c7f233 100644 --- a/ent/vod/vod.go +++ b/ent/vod/vod.go @@ -19,6 +19,8 @@ const ( FieldID = "id" // FieldExtID holds the string denoting the ext_id field in the database. FieldExtID = "ext_id" + // FieldClipExtVodID holds the string denoting the clip_ext_vod_id field in the database. + FieldClipExtVodID = "clip_ext_vod_id" // FieldExtStreamID holds the string denoting the ext_stream_id field in the database. FieldExtStreamID = "ext_stream_id" // FieldPlatform holds the string denoting the platform field in the database. @@ -29,6 +31,8 @@ const ( FieldTitle = "title" // FieldDuration holds the string denoting the duration field in the database. FieldDuration = "duration" + // FieldClipVodOffset holds the string denoting the clip_vod_offset field in the database. + FieldClipVodOffset = "clip_vod_offset" // FieldViews holds the string denoting the views field in the database. FieldViews = "views" // FieldResolution holds the string denoting the resolution field in the database. @@ -77,6 +81,20 @@ const ( FieldLocked = "locked" // FieldLocalViews holds the string denoting the local_views field in the database. FieldLocalViews = "local_views" + // FieldSpriteThumbnailsEnabled holds the string denoting the sprite_thumbnails_enabled field in the database. + FieldSpriteThumbnailsEnabled = "sprite_thumbnails_enabled" + // FieldSpriteThumbnailsImages holds the string denoting the sprite_thumbnails_images field in the database. + FieldSpriteThumbnailsImages = "sprite_thumbnails_images" + // FieldSpriteThumbnailsInterval holds the string denoting the sprite_thumbnails_interval field in the database. + FieldSpriteThumbnailsInterval = "sprite_thumbnails_interval" + // FieldSpriteThumbnailsWidth holds the string denoting the sprite_thumbnails_width field in the database. + FieldSpriteThumbnailsWidth = "sprite_thumbnails_width" + // FieldSpriteThumbnailsHeight holds the string denoting the sprite_thumbnails_height field in the database. + FieldSpriteThumbnailsHeight = "sprite_thumbnails_height" + // FieldSpriteThumbnailsRows holds the string denoting the sprite_thumbnails_rows field in the database. + FieldSpriteThumbnailsRows = "sprite_thumbnails_rows" + // FieldSpriteThumbnailsColumns holds the string denoting the sprite_thumbnails_columns field in the database. + FieldSpriteThumbnailsColumns = "sprite_thumbnails_columns" // FieldStreamedAt holds the string denoting the streamed_at field in the database. FieldStreamedAt = "streamed_at" // FieldUpdatedAt holds the string denoting the updated_at field in the database. @@ -143,11 +161,13 @@ const ( var Columns = []string{ FieldID, FieldExtID, + FieldClipExtVodID, FieldExtStreamID, FieldPlatform, FieldType, FieldTitle, FieldDuration, + FieldClipVodOffset, FieldViews, FieldResolution, FieldProcessing, @@ -172,6 +192,13 @@ var Columns = []string{ FieldTmpVideoHlsPath, FieldLocked, FieldLocalViews, + FieldSpriteThumbnailsEnabled, + FieldSpriteThumbnailsImages, + FieldSpriteThumbnailsInterval, + FieldSpriteThumbnailsWidth, + FieldSpriteThumbnailsHeight, + FieldSpriteThumbnailsRows, + FieldSpriteThumbnailsColumns, FieldStreamedAt, FieldUpdatedAt, FieldCreatedAt, @@ -215,6 +242,8 @@ var ( DefaultLocked bool // DefaultLocalViews holds the default value on creation for the "local_views" field. DefaultLocalViews int + // DefaultSpriteThumbnailsEnabled holds the default value on creation for the "sprite_thumbnails_enabled" field. + DefaultSpriteThumbnailsEnabled bool // DefaultStreamedAt holds the default value on creation for the "streamed_at" field. DefaultStreamedAt func() time.Time // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. @@ -264,6 +293,11 @@ func ByExtID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldExtID, opts...).ToFunc() } +// ByClipExtVodID orders the results by the clip_ext_vod_id field. +func ByClipExtVodID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldClipExtVodID, opts...).ToFunc() +} + // ByExtStreamID orders the results by the ext_stream_id field. func ByExtStreamID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldExtStreamID, opts...).ToFunc() @@ -289,6 +323,11 @@ func ByDuration(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDuration, opts...).ToFunc() } +// ByClipVodOffset orders the results by the clip_vod_offset field. +func ByClipVodOffset(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldClipVodOffset, opts...).ToFunc() +} + // ByViews orders the results by the views field. func ByViews(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldViews, opts...).ToFunc() @@ -409,6 +448,36 @@ func ByLocalViews(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldLocalViews, opts...).ToFunc() } +// BySpriteThumbnailsEnabled orders the results by the sprite_thumbnails_enabled field. +func BySpriteThumbnailsEnabled(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSpriteThumbnailsEnabled, opts...).ToFunc() +} + +// BySpriteThumbnailsInterval orders the results by the sprite_thumbnails_interval field. +func BySpriteThumbnailsInterval(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSpriteThumbnailsInterval, opts...).ToFunc() +} + +// BySpriteThumbnailsWidth orders the results by the sprite_thumbnails_width field. +func BySpriteThumbnailsWidth(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSpriteThumbnailsWidth, opts...).ToFunc() +} + +// BySpriteThumbnailsHeight orders the results by the sprite_thumbnails_height field. +func BySpriteThumbnailsHeight(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSpriteThumbnailsHeight, opts...).ToFunc() +} + +// BySpriteThumbnailsRows orders the results by the sprite_thumbnails_rows field. +func BySpriteThumbnailsRows(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSpriteThumbnailsRows, opts...).ToFunc() +} + +// BySpriteThumbnailsColumns orders the results by the sprite_thumbnails_columns field. +func BySpriteThumbnailsColumns(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSpriteThumbnailsColumns, opts...).ToFunc() +} + // ByStreamedAt orders the results by the streamed_at field. func ByStreamedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldStreamedAt, opts...).ToFunc() diff --git a/ent/vod/where.go b/ent/vod/where.go index eacad8f1..a2dc8f10 100644 --- a/ent/vod/where.go +++ b/ent/vod/where.go @@ -62,6 +62,11 @@ func ExtID(v string) predicate.Vod { return predicate.Vod(sql.FieldEQ(FieldExtID, v)) } +// ClipExtVodID applies equality check predicate on the "clip_ext_vod_id" field. It's identical to ClipExtVodIDEQ. +func ClipExtVodID(v string) predicate.Vod { + return predicate.Vod(sql.FieldEQ(FieldClipExtVodID, v)) +} + // ExtStreamID applies equality check predicate on the "ext_stream_id" field. It's identical to ExtStreamIDEQ. func ExtStreamID(v string) predicate.Vod { return predicate.Vod(sql.FieldEQ(FieldExtStreamID, v)) @@ -77,6 +82,11 @@ func Duration(v int) predicate.Vod { return predicate.Vod(sql.FieldEQ(FieldDuration, v)) } +// ClipVodOffset applies equality check predicate on the "clip_vod_offset" field. It's identical to ClipVodOffsetEQ. +func ClipVodOffset(v int) predicate.Vod { + return predicate.Vod(sql.FieldEQ(FieldClipVodOffset, v)) +} + // Views applies equality check predicate on the "views" field. It's identical to ViewsEQ. func Views(v int) predicate.Vod { return predicate.Vod(sql.FieldEQ(FieldViews, v)) @@ -197,6 +207,36 @@ func LocalViews(v int) predicate.Vod { return predicate.Vod(sql.FieldEQ(FieldLocalViews, v)) } +// SpriteThumbnailsEnabled applies equality check predicate on the "sprite_thumbnails_enabled" field. It's identical to SpriteThumbnailsEnabledEQ. +func SpriteThumbnailsEnabled(v bool) predicate.Vod { + return predicate.Vod(sql.FieldEQ(FieldSpriteThumbnailsEnabled, v)) +} + +// SpriteThumbnailsInterval applies equality check predicate on the "sprite_thumbnails_interval" field. It's identical to SpriteThumbnailsIntervalEQ. +func SpriteThumbnailsInterval(v int) predicate.Vod { + return predicate.Vod(sql.FieldEQ(FieldSpriteThumbnailsInterval, v)) +} + +// SpriteThumbnailsWidth applies equality check predicate on the "sprite_thumbnails_width" field. It's identical to SpriteThumbnailsWidthEQ. +func SpriteThumbnailsWidth(v int) predicate.Vod { + return predicate.Vod(sql.FieldEQ(FieldSpriteThumbnailsWidth, v)) +} + +// SpriteThumbnailsHeight applies equality check predicate on the "sprite_thumbnails_height" field. It's identical to SpriteThumbnailsHeightEQ. +func SpriteThumbnailsHeight(v int) predicate.Vod { + return predicate.Vod(sql.FieldEQ(FieldSpriteThumbnailsHeight, v)) +} + +// SpriteThumbnailsRows applies equality check predicate on the "sprite_thumbnails_rows" field. It's identical to SpriteThumbnailsRowsEQ. +func SpriteThumbnailsRows(v int) predicate.Vod { + return predicate.Vod(sql.FieldEQ(FieldSpriteThumbnailsRows, v)) +} + +// SpriteThumbnailsColumns applies equality check predicate on the "sprite_thumbnails_columns" field. It's identical to SpriteThumbnailsColumnsEQ. +func SpriteThumbnailsColumns(v int) predicate.Vod { + return predicate.Vod(sql.FieldEQ(FieldSpriteThumbnailsColumns, v)) +} + // StreamedAt applies equality check predicate on the "streamed_at" field. It's identical to StreamedAtEQ. func StreamedAt(v time.Time) predicate.Vod { return predicate.Vod(sql.FieldEQ(FieldStreamedAt, v)) @@ -277,6 +317,81 @@ func ExtIDContainsFold(v string) predicate.Vod { return predicate.Vod(sql.FieldContainsFold(FieldExtID, v)) } +// ClipExtVodIDEQ applies the EQ predicate on the "clip_ext_vod_id" field. +func ClipExtVodIDEQ(v string) predicate.Vod { + return predicate.Vod(sql.FieldEQ(FieldClipExtVodID, v)) +} + +// ClipExtVodIDNEQ applies the NEQ predicate on the "clip_ext_vod_id" field. +func ClipExtVodIDNEQ(v string) predicate.Vod { + return predicate.Vod(sql.FieldNEQ(FieldClipExtVodID, v)) +} + +// ClipExtVodIDIn applies the In predicate on the "clip_ext_vod_id" field. +func ClipExtVodIDIn(vs ...string) predicate.Vod { + return predicate.Vod(sql.FieldIn(FieldClipExtVodID, vs...)) +} + +// ClipExtVodIDNotIn applies the NotIn predicate on the "clip_ext_vod_id" field. +func ClipExtVodIDNotIn(vs ...string) predicate.Vod { + return predicate.Vod(sql.FieldNotIn(FieldClipExtVodID, vs...)) +} + +// ClipExtVodIDGT applies the GT predicate on the "clip_ext_vod_id" field. +func ClipExtVodIDGT(v string) predicate.Vod { + return predicate.Vod(sql.FieldGT(FieldClipExtVodID, v)) +} + +// ClipExtVodIDGTE applies the GTE predicate on the "clip_ext_vod_id" field. +func ClipExtVodIDGTE(v string) predicate.Vod { + return predicate.Vod(sql.FieldGTE(FieldClipExtVodID, v)) +} + +// ClipExtVodIDLT applies the LT predicate on the "clip_ext_vod_id" field. +func ClipExtVodIDLT(v string) predicate.Vod { + return predicate.Vod(sql.FieldLT(FieldClipExtVodID, v)) +} + +// ClipExtVodIDLTE applies the LTE predicate on the "clip_ext_vod_id" field. +func ClipExtVodIDLTE(v string) predicate.Vod { + return predicate.Vod(sql.FieldLTE(FieldClipExtVodID, v)) +} + +// ClipExtVodIDContains applies the Contains predicate on the "clip_ext_vod_id" field. +func ClipExtVodIDContains(v string) predicate.Vod { + return predicate.Vod(sql.FieldContains(FieldClipExtVodID, v)) +} + +// ClipExtVodIDHasPrefix applies the HasPrefix predicate on the "clip_ext_vod_id" field. +func ClipExtVodIDHasPrefix(v string) predicate.Vod { + return predicate.Vod(sql.FieldHasPrefix(FieldClipExtVodID, v)) +} + +// ClipExtVodIDHasSuffix applies the HasSuffix predicate on the "clip_ext_vod_id" field. +func ClipExtVodIDHasSuffix(v string) predicate.Vod { + return predicate.Vod(sql.FieldHasSuffix(FieldClipExtVodID, v)) +} + +// ClipExtVodIDIsNil applies the IsNil predicate on the "clip_ext_vod_id" field. +func ClipExtVodIDIsNil() predicate.Vod { + return predicate.Vod(sql.FieldIsNull(FieldClipExtVodID)) +} + +// ClipExtVodIDNotNil applies the NotNil predicate on the "clip_ext_vod_id" field. +func ClipExtVodIDNotNil() predicate.Vod { + return predicate.Vod(sql.FieldNotNull(FieldClipExtVodID)) +} + +// ClipExtVodIDEqualFold applies the EqualFold predicate on the "clip_ext_vod_id" field. +func ClipExtVodIDEqualFold(v string) predicate.Vod { + return predicate.Vod(sql.FieldEqualFold(FieldClipExtVodID, v)) +} + +// ClipExtVodIDContainsFold applies the ContainsFold predicate on the "clip_ext_vod_id" field. +func ClipExtVodIDContainsFold(v string) predicate.Vod { + return predicate.Vod(sql.FieldContainsFold(FieldClipExtVodID, v)) +} + // ExtStreamIDEQ applies the EQ predicate on the "ext_stream_id" field. func ExtStreamIDEQ(v string) predicate.Vod { return predicate.Vod(sql.FieldEQ(FieldExtStreamID, v)) @@ -517,6 +632,56 @@ func DurationLTE(v int) predicate.Vod { return predicate.Vod(sql.FieldLTE(FieldDuration, v)) } +// ClipVodOffsetEQ applies the EQ predicate on the "clip_vod_offset" field. +func ClipVodOffsetEQ(v int) predicate.Vod { + return predicate.Vod(sql.FieldEQ(FieldClipVodOffset, v)) +} + +// ClipVodOffsetNEQ applies the NEQ predicate on the "clip_vod_offset" field. +func ClipVodOffsetNEQ(v int) predicate.Vod { + return predicate.Vod(sql.FieldNEQ(FieldClipVodOffset, v)) +} + +// ClipVodOffsetIn applies the In predicate on the "clip_vod_offset" field. +func ClipVodOffsetIn(vs ...int) predicate.Vod { + return predicate.Vod(sql.FieldIn(FieldClipVodOffset, vs...)) +} + +// ClipVodOffsetNotIn applies the NotIn predicate on the "clip_vod_offset" field. +func ClipVodOffsetNotIn(vs ...int) predicate.Vod { + return predicate.Vod(sql.FieldNotIn(FieldClipVodOffset, vs...)) +} + +// ClipVodOffsetGT applies the GT predicate on the "clip_vod_offset" field. +func ClipVodOffsetGT(v int) predicate.Vod { + return predicate.Vod(sql.FieldGT(FieldClipVodOffset, v)) +} + +// ClipVodOffsetGTE applies the GTE predicate on the "clip_vod_offset" field. +func ClipVodOffsetGTE(v int) predicate.Vod { + return predicate.Vod(sql.FieldGTE(FieldClipVodOffset, v)) +} + +// ClipVodOffsetLT applies the LT predicate on the "clip_vod_offset" field. +func ClipVodOffsetLT(v int) predicate.Vod { + return predicate.Vod(sql.FieldLT(FieldClipVodOffset, v)) +} + +// ClipVodOffsetLTE applies the LTE predicate on the "clip_vod_offset" field. +func ClipVodOffsetLTE(v int) predicate.Vod { + return predicate.Vod(sql.FieldLTE(FieldClipVodOffset, v)) +} + +// ClipVodOffsetIsNil applies the IsNil predicate on the "clip_vod_offset" field. +func ClipVodOffsetIsNil() predicate.Vod { + return predicate.Vod(sql.FieldIsNull(FieldClipVodOffset)) +} + +// ClipVodOffsetNotNil applies the NotNil predicate on the "clip_vod_offset" field. +func ClipVodOffsetNotNil() predicate.Vod { + return predicate.Vod(sql.FieldNotNull(FieldClipVodOffset)) +} + // ViewsEQ applies the EQ predicate on the "views" field. func ViewsEQ(v int) predicate.Vod { return predicate.Vod(sql.FieldEQ(FieldViews, v)) @@ -2097,6 +2262,276 @@ func LocalViewsLTE(v int) predicate.Vod { return predicate.Vod(sql.FieldLTE(FieldLocalViews, v)) } +// SpriteThumbnailsEnabledEQ applies the EQ predicate on the "sprite_thumbnails_enabled" field. +func SpriteThumbnailsEnabledEQ(v bool) predicate.Vod { + return predicate.Vod(sql.FieldEQ(FieldSpriteThumbnailsEnabled, v)) +} + +// SpriteThumbnailsEnabledNEQ applies the NEQ predicate on the "sprite_thumbnails_enabled" field. +func SpriteThumbnailsEnabledNEQ(v bool) predicate.Vod { + return predicate.Vod(sql.FieldNEQ(FieldSpriteThumbnailsEnabled, v)) +} + +// SpriteThumbnailsImagesIsNil applies the IsNil predicate on the "sprite_thumbnails_images" field. +func SpriteThumbnailsImagesIsNil() predicate.Vod { + return predicate.Vod(sql.FieldIsNull(FieldSpriteThumbnailsImages)) +} + +// SpriteThumbnailsImagesNotNil applies the NotNil predicate on the "sprite_thumbnails_images" field. +func SpriteThumbnailsImagesNotNil() predicate.Vod { + return predicate.Vod(sql.FieldNotNull(FieldSpriteThumbnailsImages)) +} + +// SpriteThumbnailsIntervalEQ applies the EQ predicate on the "sprite_thumbnails_interval" field. +func SpriteThumbnailsIntervalEQ(v int) predicate.Vod { + return predicate.Vod(sql.FieldEQ(FieldSpriteThumbnailsInterval, v)) +} + +// SpriteThumbnailsIntervalNEQ applies the NEQ predicate on the "sprite_thumbnails_interval" field. +func SpriteThumbnailsIntervalNEQ(v int) predicate.Vod { + return predicate.Vod(sql.FieldNEQ(FieldSpriteThumbnailsInterval, v)) +} + +// SpriteThumbnailsIntervalIn applies the In predicate on the "sprite_thumbnails_interval" field. +func SpriteThumbnailsIntervalIn(vs ...int) predicate.Vod { + return predicate.Vod(sql.FieldIn(FieldSpriteThumbnailsInterval, vs...)) +} + +// SpriteThumbnailsIntervalNotIn applies the NotIn predicate on the "sprite_thumbnails_interval" field. +func SpriteThumbnailsIntervalNotIn(vs ...int) predicate.Vod { + return predicate.Vod(sql.FieldNotIn(FieldSpriteThumbnailsInterval, vs...)) +} + +// SpriteThumbnailsIntervalGT applies the GT predicate on the "sprite_thumbnails_interval" field. +func SpriteThumbnailsIntervalGT(v int) predicate.Vod { + return predicate.Vod(sql.FieldGT(FieldSpriteThumbnailsInterval, v)) +} + +// SpriteThumbnailsIntervalGTE applies the GTE predicate on the "sprite_thumbnails_interval" field. +func SpriteThumbnailsIntervalGTE(v int) predicate.Vod { + return predicate.Vod(sql.FieldGTE(FieldSpriteThumbnailsInterval, v)) +} + +// SpriteThumbnailsIntervalLT applies the LT predicate on the "sprite_thumbnails_interval" field. +func SpriteThumbnailsIntervalLT(v int) predicate.Vod { + return predicate.Vod(sql.FieldLT(FieldSpriteThumbnailsInterval, v)) +} + +// SpriteThumbnailsIntervalLTE applies the LTE predicate on the "sprite_thumbnails_interval" field. +func SpriteThumbnailsIntervalLTE(v int) predicate.Vod { + return predicate.Vod(sql.FieldLTE(FieldSpriteThumbnailsInterval, v)) +} + +// SpriteThumbnailsIntervalIsNil applies the IsNil predicate on the "sprite_thumbnails_interval" field. +func SpriteThumbnailsIntervalIsNil() predicate.Vod { + return predicate.Vod(sql.FieldIsNull(FieldSpriteThumbnailsInterval)) +} + +// SpriteThumbnailsIntervalNotNil applies the NotNil predicate on the "sprite_thumbnails_interval" field. +func SpriteThumbnailsIntervalNotNil() predicate.Vod { + return predicate.Vod(sql.FieldNotNull(FieldSpriteThumbnailsInterval)) +} + +// SpriteThumbnailsWidthEQ applies the EQ predicate on the "sprite_thumbnails_width" field. +func SpriteThumbnailsWidthEQ(v int) predicate.Vod { + return predicate.Vod(sql.FieldEQ(FieldSpriteThumbnailsWidth, v)) +} + +// SpriteThumbnailsWidthNEQ applies the NEQ predicate on the "sprite_thumbnails_width" field. +func SpriteThumbnailsWidthNEQ(v int) predicate.Vod { + return predicate.Vod(sql.FieldNEQ(FieldSpriteThumbnailsWidth, v)) +} + +// SpriteThumbnailsWidthIn applies the In predicate on the "sprite_thumbnails_width" field. +func SpriteThumbnailsWidthIn(vs ...int) predicate.Vod { + return predicate.Vod(sql.FieldIn(FieldSpriteThumbnailsWidth, vs...)) +} + +// SpriteThumbnailsWidthNotIn applies the NotIn predicate on the "sprite_thumbnails_width" field. +func SpriteThumbnailsWidthNotIn(vs ...int) predicate.Vod { + return predicate.Vod(sql.FieldNotIn(FieldSpriteThumbnailsWidth, vs...)) +} + +// SpriteThumbnailsWidthGT applies the GT predicate on the "sprite_thumbnails_width" field. +func SpriteThumbnailsWidthGT(v int) predicate.Vod { + return predicate.Vod(sql.FieldGT(FieldSpriteThumbnailsWidth, v)) +} + +// SpriteThumbnailsWidthGTE applies the GTE predicate on the "sprite_thumbnails_width" field. +func SpriteThumbnailsWidthGTE(v int) predicate.Vod { + return predicate.Vod(sql.FieldGTE(FieldSpriteThumbnailsWidth, v)) +} + +// SpriteThumbnailsWidthLT applies the LT predicate on the "sprite_thumbnails_width" field. +func SpriteThumbnailsWidthLT(v int) predicate.Vod { + return predicate.Vod(sql.FieldLT(FieldSpriteThumbnailsWidth, v)) +} + +// SpriteThumbnailsWidthLTE applies the LTE predicate on the "sprite_thumbnails_width" field. +func SpriteThumbnailsWidthLTE(v int) predicate.Vod { + return predicate.Vod(sql.FieldLTE(FieldSpriteThumbnailsWidth, v)) +} + +// SpriteThumbnailsWidthIsNil applies the IsNil predicate on the "sprite_thumbnails_width" field. +func SpriteThumbnailsWidthIsNil() predicate.Vod { + return predicate.Vod(sql.FieldIsNull(FieldSpriteThumbnailsWidth)) +} + +// SpriteThumbnailsWidthNotNil applies the NotNil predicate on the "sprite_thumbnails_width" field. +func SpriteThumbnailsWidthNotNil() predicate.Vod { + return predicate.Vod(sql.FieldNotNull(FieldSpriteThumbnailsWidth)) +} + +// SpriteThumbnailsHeightEQ applies the EQ predicate on the "sprite_thumbnails_height" field. +func SpriteThumbnailsHeightEQ(v int) predicate.Vod { + return predicate.Vod(sql.FieldEQ(FieldSpriteThumbnailsHeight, v)) +} + +// SpriteThumbnailsHeightNEQ applies the NEQ predicate on the "sprite_thumbnails_height" field. +func SpriteThumbnailsHeightNEQ(v int) predicate.Vod { + return predicate.Vod(sql.FieldNEQ(FieldSpriteThumbnailsHeight, v)) +} + +// SpriteThumbnailsHeightIn applies the In predicate on the "sprite_thumbnails_height" field. +func SpriteThumbnailsHeightIn(vs ...int) predicate.Vod { + return predicate.Vod(sql.FieldIn(FieldSpriteThumbnailsHeight, vs...)) +} + +// SpriteThumbnailsHeightNotIn applies the NotIn predicate on the "sprite_thumbnails_height" field. +func SpriteThumbnailsHeightNotIn(vs ...int) predicate.Vod { + return predicate.Vod(sql.FieldNotIn(FieldSpriteThumbnailsHeight, vs...)) +} + +// SpriteThumbnailsHeightGT applies the GT predicate on the "sprite_thumbnails_height" field. +func SpriteThumbnailsHeightGT(v int) predicate.Vod { + return predicate.Vod(sql.FieldGT(FieldSpriteThumbnailsHeight, v)) +} + +// SpriteThumbnailsHeightGTE applies the GTE predicate on the "sprite_thumbnails_height" field. +func SpriteThumbnailsHeightGTE(v int) predicate.Vod { + return predicate.Vod(sql.FieldGTE(FieldSpriteThumbnailsHeight, v)) +} + +// SpriteThumbnailsHeightLT applies the LT predicate on the "sprite_thumbnails_height" field. +func SpriteThumbnailsHeightLT(v int) predicate.Vod { + return predicate.Vod(sql.FieldLT(FieldSpriteThumbnailsHeight, v)) +} + +// SpriteThumbnailsHeightLTE applies the LTE predicate on the "sprite_thumbnails_height" field. +func SpriteThumbnailsHeightLTE(v int) predicate.Vod { + return predicate.Vod(sql.FieldLTE(FieldSpriteThumbnailsHeight, v)) +} + +// SpriteThumbnailsHeightIsNil applies the IsNil predicate on the "sprite_thumbnails_height" field. +func SpriteThumbnailsHeightIsNil() predicate.Vod { + return predicate.Vod(sql.FieldIsNull(FieldSpriteThumbnailsHeight)) +} + +// SpriteThumbnailsHeightNotNil applies the NotNil predicate on the "sprite_thumbnails_height" field. +func SpriteThumbnailsHeightNotNil() predicate.Vod { + return predicate.Vod(sql.FieldNotNull(FieldSpriteThumbnailsHeight)) +} + +// SpriteThumbnailsRowsEQ applies the EQ predicate on the "sprite_thumbnails_rows" field. +func SpriteThumbnailsRowsEQ(v int) predicate.Vod { + return predicate.Vod(sql.FieldEQ(FieldSpriteThumbnailsRows, v)) +} + +// SpriteThumbnailsRowsNEQ applies the NEQ predicate on the "sprite_thumbnails_rows" field. +func SpriteThumbnailsRowsNEQ(v int) predicate.Vod { + return predicate.Vod(sql.FieldNEQ(FieldSpriteThumbnailsRows, v)) +} + +// SpriteThumbnailsRowsIn applies the In predicate on the "sprite_thumbnails_rows" field. +func SpriteThumbnailsRowsIn(vs ...int) predicate.Vod { + return predicate.Vod(sql.FieldIn(FieldSpriteThumbnailsRows, vs...)) +} + +// SpriteThumbnailsRowsNotIn applies the NotIn predicate on the "sprite_thumbnails_rows" field. +func SpriteThumbnailsRowsNotIn(vs ...int) predicate.Vod { + return predicate.Vod(sql.FieldNotIn(FieldSpriteThumbnailsRows, vs...)) +} + +// SpriteThumbnailsRowsGT applies the GT predicate on the "sprite_thumbnails_rows" field. +func SpriteThumbnailsRowsGT(v int) predicate.Vod { + return predicate.Vod(sql.FieldGT(FieldSpriteThumbnailsRows, v)) +} + +// SpriteThumbnailsRowsGTE applies the GTE predicate on the "sprite_thumbnails_rows" field. +func SpriteThumbnailsRowsGTE(v int) predicate.Vod { + return predicate.Vod(sql.FieldGTE(FieldSpriteThumbnailsRows, v)) +} + +// SpriteThumbnailsRowsLT applies the LT predicate on the "sprite_thumbnails_rows" field. +func SpriteThumbnailsRowsLT(v int) predicate.Vod { + return predicate.Vod(sql.FieldLT(FieldSpriteThumbnailsRows, v)) +} + +// SpriteThumbnailsRowsLTE applies the LTE predicate on the "sprite_thumbnails_rows" field. +func SpriteThumbnailsRowsLTE(v int) predicate.Vod { + return predicate.Vod(sql.FieldLTE(FieldSpriteThumbnailsRows, v)) +} + +// SpriteThumbnailsRowsIsNil applies the IsNil predicate on the "sprite_thumbnails_rows" field. +func SpriteThumbnailsRowsIsNil() predicate.Vod { + return predicate.Vod(sql.FieldIsNull(FieldSpriteThumbnailsRows)) +} + +// SpriteThumbnailsRowsNotNil applies the NotNil predicate on the "sprite_thumbnails_rows" field. +func SpriteThumbnailsRowsNotNil() predicate.Vod { + return predicate.Vod(sql.FieldNotNull(FieldSpriteThumbnailsRows)) +} + +// SpriteThumbnailsColumnsEQ applies the EQ predicate on the "sprite_thumbnails_columns" field. +func SpriteThumbnailsColumnsEQ(v int) predicate.Vod { + return predicate.Vod(sql.FieldEQ(FieldSpriteThumbnailsColumns, v)) +} + +// SpriteThumbnailsColumnsNEQ applies the NEQ predicate on the "sprite_thumbnails_columns" field. +func SpriteThumbnailsColumnsNEQ(v int) predicate.Vod { + return predicate.Vod(sql.FieldNEQ(FieldSpriteThumbnailsColumns, v)) +} + +// SpriteThumbnailsColumnsIn applies the In predicate on the "sprite_thumbnails_columns" field. +func SpriteThumbnailsColumnsIn(vs ...int) predicate.Vod { + return predicate.Vod(sql.FieldIn(FieldSpriteThumbnailsColumns, vs...)) +} + +// SpriteThumbnailsColumnsNotIn applies the NotIn predicate on the "sprite_thumbnails_columns" field. +func SpriteThumbnailsColumnsNotIn(vs ...int) predicate.Vod { + return predicate.Vod(sql.FieldNotIn(FieldSpriteThumbnailsColumns, vs...)) +} + +// SpriteThumbnailsColumnsGT applies the GT predicate on the "sprite_thumbnails_columns" field. +func SpriteThumbnailsColumnsGT(v int) predicate.Vod { + return predicate.Vod(sql.FieldGT(FieldSpriteThumbnailsColumns, v)) +} + +// SpriteThumbnailsColumnsGTE applies the GTE predicate on the "sprite_thumbnails_columns" field. +func SpriteThumbnailsColumnsGTE(v int) predicate.Vod { + return predicate.Vod(sql.FieldGTE(FieldSpriteThumbnailsColumns, v)) +} + +// SpriteThumbnailsColumnsLT applies the LT predicate on the "sprite_thumbnails_columns" field. +func SpriteThumbnailsColumnsLT(v int) predicate.Vod { + return predicate.Vod(sql.FieldLT(FieldSpriteThumbnailsColumns, v)) +} + +// SpriteThumbnailsColumnsLTE applies the LTE predicate on the "sprite_thumbnails_columns" field. +func SpriteThumbnailsColumnsLTE(v int) predicate.Vod { + return predicate.Vod(sql.FieldLTE(FieldSpriteThumbnailsColumns, v)) +} + +// SpriteThumbnailsColumnsIsNil applies the IsNil predicate on the "sprite_thumbnails_columns" field. +func SpriteThumbnailsColumnsIsNil() predicate.Vod { + return predicate.Vod(sql.FieldIsNull(FieldSpriteThumbnailsColumns)) +} + +// SpriteThumbnailsColumnsNotNil applies the NotNil predicate on the "sprite_thumbnails_columns" field. +func SpriteThumbnailsColumnsNotNil() predicate.Vod { + return predicate.Vod(sql.FieldNotNull(FieldSpriteThumbnailsColumns)) +} + // StreamedAtEQ applies the EQ predicate on the "streamed_at" field. func StreamedAtEQ(v time.Time) predicate.Vod { return predicate.Vod(sql.FieldEQ(FieldStreamedAt, v)) diff --git a/ent/vod_create.go b/ent/vod_create.go index b7638eaf..f323b500 100644 --- a/ent/vod_create.go +++ b/ent/vod_create.go @@ -37,6 +37,20 @@ func (vc *VodCreate) SetExtID(s string) *VodCreate { return vc } +// SetClipExtVodID sets the "clip_ext_vod_id" field. +func (vc *VodCreate) SetClipExtVodID(s string) *VodCreate { + vc.mutation.SetClipExtVodID(s) + return vc +} + +// SetNillableClipExtVodID sets the "clip_ext_vod_id" field if the given value is not nil. +func (vc *VodCreate) SetNillableClipExtVodID(s *string) *VodCreate { + if s != nil { + vc.SetClipExtVodID(*s) + } + return vc +} + // SetExtStreamID sets the "ext_stream_id" field. func (vc *VodCreate) SetExtStreamID(s string) *VodCreate { vc.mutation.SetExtStreamID(s) @@ -99,6 +113,20 @@ func (vc *VodCreate) SetNillableDuration(i *int) *VodCreate { return vc } +// SetClipVodOffset sets the "clip_vod_offset" field. +func (vc *VodCreate) SetClipVodOffset(i int) *VodCreate { + vc.mutation.SetClipVodOffset(i) + return vc +} + +// SetNillableClipVodOffset sets the "clip_vod_offset" field if the given value is not nil. +func (vc *VodCreate) SetNillableClipVodOffset(i *int) *VodCreate { + if i != nil { + vc.SetClipVodOffset(*i) + } + return vc +} + // SetViews sets the "views" field. func (vc *VodCreate) SetViews(i int) *VodCreate { vc.mutation.SetViews(i) @@ -419,6 +447,96 @@ func (vc *VodCreate) SetNillableLocalViews(i *int) *VodCreate { return vc } +// SetSpriteThumbnailsEnabled sets the "sprite_thumbnails_enabled" field. +func (vc *VodCreate) SetSpriteThumbnailsEnabled(b bool) *VodCreate { + vc.mutation.SetSpriteThumbnailsEnabled(b) + return vc +} + +// SetNillableSpriteThumbnailsEnabled sets the "sprite_thumbnails_enabled" field if the given value is not nil. +func (vc *VodCreate) SetNillableSpriteThumbnailsEnabled(b *bool) *VodCreate { + if b != nil { + vc.SetSpriteThumbnailsEnabled(*b) + } + return vc +} + +// SetSpriteThumbnailsImages sets the "sprite_thumbnails_images" field. +func (vc *VodCreate) SetSpriteThumbnailsImages(s []string) *VodCreate { + vc.mutation.SetSpriteThumbnailsImages(s) + return vc +} + +// SetSpriteThumbnailsInterval sets the "sprite_thumbnails_interval" field. +func (vc *VodCreate) SetSpriteThumbnailsInterval(i int) *VodCreate { + vc.mutation.SetSpriteThumbnailsInterval(i) + return vc +} + +// SetNillableSpriteThumbnailsInterval sets the "sprite_thumbnails_interval" field if the given value is not nil. +func (vc *VodCreate) SetNillableSpriteThumbnailsInterval(i *int) *VodCreate { + if i != nil { + vc.SetSpriteThumbnailsInterval(*i) + } + return vc +} + +// SetSpriteThumbnailsWidth sets the "sprite_thumbnails_width" field. +func (vc *VodCreate) SetSpriteThumbnailsWidth(i int) *VodCreate { + vc.mutation.SetSpriteThumbnailsWidth(i) + return vc +} + +// SetNillableSpriteThumbnailsWidth sets the "sprite_thumbnails_width" field if the given value is not nil. +func (vc *VodCreate) SetNillableSpriteThumbnailsWidth(i *int) *VodCreate { + if i != nil { + vc.SetSpriteThumbnailsWidth(*i) + } + return vc +} + +// SetSpriteThumbnailsHeight sets the "sprite_thumbnails_height" field. +func (vc *VodCreate) SetSpriteThumbnailsHeight(i int) *VodCreate { + vc.mutation.SetSpriteThumbnailsHeight(i) + return vc +} + +// SetNillableSpriteThumbnailsHeight sets the "sprite_thumbnails_height" field if the given value is not nil. +func (vc *VodCreate) SetNillableSpriteThumbnailsHeight(i *int) *VodCreate { + if i != nil { + vc.SetSpriteThumbnailsHeight(*i) + } + return vc +} + +// SetSpriteThumbnailsRows sets the "sprite_thumbnails_rows" field. +func (vc *VodCreate) SetSpriteThumbnailsRows(i int) *VodCreate { + vc.mutation.SetSpriteThumbnailsRows(i) + return vc +} + +// SetNillableSpriteThumbnailsRows sets the "sprite_thumbnails_rows" field if the given value is not nil. +func (vc *VodCreate) SetNillableSpriteThumbnailsRows(i *int) *VodCreate { + if i != nil { + vc.SetSpriteThumbnailsRows(*i) + } + return vc +} + +// SetSpriteThumbnailsColumns sets the "sprite_thumbnails_columns" field. +func (vc *VodCreate) SetSpriteThumbnailsColumns(i int) *VodCreate { + vc.mutation.SetSpriteThumbnailsColumns(i) + return vc +} + +// SetNillableSpriteThumbnailsColumns sets the "sprite_thumbnails_columns" field if the given value is not nil. +func (vc *VodCreate) SetNillableSpriteThumbnailsColumns(i *int) *VodCreate { + if i != nil { + vc.SetSpriteThumbnailsColumns(*i) + } + return vc +} + // SetStreamedAt sets the "streamed_at" field. func (vc *VodCreate) SetStreamedAt(t time.Time) *VodCreate { vc.mutation.SetStreamedAt(t) @@ -628,6 +746,10 @@ func (vc *VodCreate) defaults() { v := vod.DefaultLocalViews vc.mutation.SetLocalViews(v) } + if _, ok := vc.mutation.SpriteThumbnailsEnabled(); !ok { + v := vod.DefaultSpriteThumbnailsEnabled + vc.mutation.SetSpriteThumbnailsEnabled(v) + } if _, ok := vc.mutation.StreamedAt(); !ok { v := vod.DefaultStreamedAt() vc.mutation.SetStreamedAt(v) @@ -691,6 +813,9 @@ func (vc *VodCreate) check() error { if _, ok := vc.mutation.LocalViews(); !ok { return &ValidationError{Name: "local_views", err: errors.New(`ent: missing required field "Vod.local_views"`)} } + if _, ok := vc.mutation.SpriteThumbnailsEnabled(); !ok { + return &ValidationError{Name: "sprite_thumbnails_enabled", err: errors.New(`ent: missing required field "Vod.sprite_thumbnails_enabled"`)} + } if _, ok := vc.mutation.StreamedAt(); !ok { return &ValidationError{Name: "streamed_at", err: errors.New(`ent: missing required field "Vod.streamed_at"`)} } @@ -743,6 +868,10 @@ func (vc *VodCreate) createSpec() (*Vod, *sqlgraph.CreateSpec) { _spec.SetField(vod.FieldExtID, field.TypeString, value) _node.ExtID = value } + if value, ok := vc.mutation.ClipExtVodID(); ok { + _spec.SetField(vod.FieldClipExtVodID, field.TypeString, value) + _node.ClipExtVodID = value + } if value, ok := vc.mutation.ExtStreamID(); ok { _spec.SetField(vod.FieldExtStreamID, field.TypeString, value) _node.ExtStreamID = value @@ -763,6 +892,10 @@ func (vc *VodCreate) createSpec() (*Vod, *sqlgraph.CreateSpec) { _spec.SetField(vod.FieldDuration, field.TypeInt, value) _node.Duration = value } + if value, ok := vc.mutation.ClipVodOffset(); ok { + _spec.SetField(vod.FieldClipVodOffset, field.TypeInt, value) + _node.ClipVodOffset = value + } if value, ok := vc.mutation.Views(); ok { _spec.SetField(vod.FieldViews, field.TypeInt, value) _node.Views = value @@ -859,6 +992,34 @@ func (vc *VodCreate) createSpec() (*Vod, *sqlgraph.CreateSpec) { _spec.SetField(vod.FieldLocalViews, field.TypeInt, value) _node.LocalViews = value } + if value, ok := vc.mutation.SpriteThumbnailsEnabled(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsEnabled, field.TypeBool, value) + _node.SpriteThumbnailsEnabled = value + } + if value, ok := vc.mutation.SpriteThumbnailsImages(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsImages, field.TypeJSON, value) + _node.SpriteThumbnailsImages = value + } + if value, ok := vc.mutation.SpriteThumbnailsInterval(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsInterval, field.TypeInt, value) + _node.SpriteThumbnailsInterval = value + } + if value, ok := vc.mutation.SpriteThumbnailsWidth(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsWidth, field.TypeInt, value) + _node.SpriteThumbnailsWidth = value + } + if value, ok := vc.mutation.SpriteThumbnailsHeight(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsHeight, field.TypeInt, value) + _node.SpriteThumbnailsHeight = value + } + if value, ok := vc.mutation.SpriteThumbnailsRows(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsRows, field.TypeInt, value) + _node.SpriteThumbnailsRows = value + } + if value, ok := vc.mutation.SpriteThumbnailsColumns(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsColumns, field.TypeInt, value) + _node.SpriteThumbnailsColumns = value + } if value, ok := vc.mutation.StreamedAt(); ok { _spec.SetField(vod.FieldStreamedAt, field.TypeTime, value) _node.StreamedAt = value @@ -1032,6 +1193,24 @@ func (u *VodUpsert) UpdateExtID() *VodUpsert { return u } +// SetClipExtVodID sets the "clip_ext_vod_id" field. +func (u *VodUpsert) SetClipExtVodID(v string) *VodUpsert { + u.Set(vod.FieldClipExtVodID, v) + return u +} + +// UpdateClipExtVodID sets the "clip_ext_vod_id" field to the value that was provided on create. +func (u *VodUpsert) UpdateClipExtVodID() *VodUpsert { + u.SetExcluded(vod.FieldClipExtVodID) + return u +} + +// ClearClipExtVodID clears the value of the "clip_ext_vod_id" field. +func (u *VodUpsert) ClearClipExtVodID() *VodUpsert { + u.SetNull(vod.FieldClipExtVodID) + return u +} + // SetExtStreamID sets the "ext_stream_id" field. func (u *VodUpsert) SetExtStreamID(v string) *VodUpsert { u.Set(vod.FieldExtStreamID, v) @@ -1104,6 +1283,30 @@ func (u *VodUpsert) AddDuration(v int) *VodUpsert { return u } +// SetClipVodOffset sets the "clip_vod_offset" field. +func (u *VodUpsert) SetClipVodOffset(v int) *VodUpsert { + u.Set(vod.FieldClipVodOffset, v) + return u +} + +// UpdateClipVodOffset sets the "clip_vod_offset" field to the value that was provided on create. +func (u *VodUpsert) UpdateClipVodOffset() *VodUpsert { + u.SetExcluded(vod.FieldClipVodOffset) + return u +} + +// AddClipVodOffset adds v to the "clip_vod_offset" field. +func (u *VodUpsert) AddClipVodOffset(v int) *VodUpsert { + u.Add(vod.FieldClipVodOffset, v) + return u +} + +// ClearClipVodOffset clears the value of the "clip_vod_offset" field. +func (u *VodUpsert) ClearClipVodOffset() *VodUpsert { + u.SetNull(vod.FieldClipVodOffset) + return u +} + // SetViews sets the "views" field. func (u *VodUpsert) SetViews(v int) *VodUpsert { u.Set(vod.FieldViews, v) @@ -1512,6 +1715,156 @@ func (u *VodUpsert) AddLocalViews(v int) *VodUpsert { return u } +// SetSpriteThumbnailsEnabled sets the "sprite_thumbnails_enabled" field. +func (u *VodUpsert) SetSpriteThumbnailsEnabled(v bool) *VodUpsert { + u.Set(vod.FieldSpriteThumbnailsEnabled, v) + return u +} + +// UpdateSpriteThumbnailsEnabled sets the "sprite_thumbnails_enabled" field to the value that was provided on create. +func (u *VodUpsert) UpdateSpriteThumbnailsEnabled() *VodUpsert { + u.SetExcluded(vod.FieldSpriteThumbnailsEnabled) + return u +} + +// SetSpriteThumbnailsImages sets the "sprite_thumbnails_images" field. +func (u *VodUpsert) SetSpriteThumbnailsImages(v []string) *VodUpsert { + u.Set(vod.FieldSpriteThumbnailsImages, v) + return u +} + +// UpdateSpriteThumbnailsImages sets the "sprite_thumbnails_images" field to the value that was provided on create. +func (u *VodUpsert) UpdateSpriteThumbnailsImages() *VodUpsert { + u.SetExcluded(vod.FieldSpriteThumbnailsImages) + return u +} + +// ClearSpriteThumbnailsImages clears the value of the "sprite_thumbnails_images" field. +func (u *VodUpsert) ClearSpriteThumbnailsImages() *VodUpsert { + u.SetNull(vod.FieldSpriteThumbnailsImages) + return u +} + +// SetSpriteThumbnailsInterval sets the "sprite_thumbnails_interval" field. +func (u *VodUpsert) SetSpriteThumbnailsInterval(v int) *VodUpsert { + u.Set(vod.FieldSpriteThumbnailsInterval, v) + return u +} + +// UpdateSpriteThumbnailsInterval sets the "sprite_thumbnails_interval" field to the value that was provided on create. +func (u *VodUpsert) UpdateSpriteThumbnailsInterval() *VodUpsert { + u.SetExcluded(vod.FieldSpriteThumbnailsInterval) + return u +} + +// AddSpriteThumbnailsInterval adds v to the "sprite_thumbnails_interval" field. +func (u *VodUpsert) AddSpriteThumbnailsInterval(v int) *VodUpsert { + u.Add(vod.FieldSpriteThumbnailsInterval, v) + return u +} + +// ClearSpriteThumbnailsInterval clears the value of the "sprite_thumbnails_interval" field. +func (u *VodUpsert) ClearSpriteThumbnailsInterval() *VodUpsert { + u.SetNull(vod.FieldSpriteThumbnailsInterval) + return u +} + +// SetSpriteThumbnailsWidth sets the "sprite_thumbnails_width" field. +func (u *VodUpsert) SetSpriteThumbnailsWidth(v int) *VodUpsert { + u.Set(vod.FieldSpriteThumbnailsWidth, v) + return u +} + +// UpdateSpriteThumbnailsWidth sets the "sprite_thumbnails_width" field to the value that was provided on create. +func (u *VodUpsert) UpdateSpriteThumbnailsWidth() *VodUpsert { + u.SetExcluded(vod.FieldSpriteThumbnailsWidth) + return u +} + +// AddSpriteThumbnailsWidth adds v to the "sprite_thumbnails_width" field. +func (u *VodUpsert) AddSpriteThumbnailsWidth(v int) *VodUpsert { + u.Add(vod.FieldSpriteThumbnailsWidth, v) + return u +} + +// ClearSpriteThumbnailsWidth clears the value of the "sprite_thumbnails_width" field. +func (u *VodUpsert) ClearSpriteThumbnailsWidth() *VodUpsert { + u.SetNull(vod.FieldSpriteThumbnailsWidth) + return u +} + +// SetSpriteThumbnailsHeight sets the "sprite_thumbnails_height" field. +func (u *VodUpsert) SetSpriteThumbnailsHeight(v int) *VodUpsert { + u.Set(vod.FieldSpriteThumbnailsHeight, v) + return u +} + +// UpdateSpriteThumbnailsHeight sets the "sprite_thumbnails_height" field to the value that was provided on create. +func (u *VodUpsert) UpdateSpriteThumbnailsHeight() *VodUpsert { + u.SetExcluded(vod.FieldSpriteThumbnailsHeight) + return u +} + +// AddSpriteThumbnailsHeight adds v to the "sprite_thumbnails_height" field. +func (u *VodUpsert) AddSpriteThumbnailsHeight(v int) *VodUpsert { + u.Add(vod.FieldSpriteThumbnailsHeight, v) + return u +} + +// ClearSpriteThumbnailsHeight clears the value of the "sprite_thumbnails_height" field. +func (u *VodUpsert) ClearSpriteThumbnailsHeight() *VodUpsert { + u.SetNull(vod.FieldSpriteThumbnailsHeight) + return u +} + +// SetSpriteThumbnailsRows sets the "sprite_thumbnails_rows" field. +func (u *VodUpsert) SetSpriteThumbnailsRows(v int) *VodUpsert { + u.Set(vod.FieldSpriteThumbnailsRows, v) + return u +} + +// UpdateSpriteThumbnailsRows sets the "sprite_thumbnails_rows" field to the value that was provided on create. +func (u *VodUpsert) UpdateSpriteThumbnailsRows() *VodUpsert { + u.SetExcluded(vod.FieldSpriteThumbnailsRows) + return u +} + +// AddSpriteThumbnailsRows adds v to the "sprite_thumbnails_rows" field. +func (u *VodUpsert) AddSpriteThumbnailsRows(v int) *VodUpsert { + u.Add(vod.FieldSpriteThumbnailsRows, v) + return u +} + +// ClearSpriteThumbnailsRows clears the value of the "sprite_thumbnails_rows" field. +func (u *VodUpsert) ClearSpriteThumbnailsRows() *VodUpsert { + u.SetNull(vod.FieldSpriteThumbnailsRows) + return u +} + +// SetSpriteThumbnailsColumns sets the "sprite_thumbnails_columns" field. +func (u *VodUpsert) SetSpriteThumbnailsColumns(v int) *VodUpsert { + u.Set(vod.FieldSpriteThumbnailsColumns, v) + return u +} + +// UpdateSpriteThumbnailsColumns sets the "sprite_thumbnails_columns" field to the value that was provided on create. +func (u *VodUpsert) UpdateSpriteThumbnailsColumns() *VodUpsert { + u.SetExcluded(vod.FieldSpriteThumbnailsColumns) + return u +} + +// AddSpriteThumbnailsColumns adds v to the "sprite_thumbnails_columns" field. +func (u *VodUpsert) AddSpriteThumbnailsColumns(v int) *VodUpsert { + u.Add(vod.FieldSpriteThumbnailsColumns, v) + return u +} + +// ClearSpriteThumbnailsColumns clears the value of the "sprite_thumbnails_columns" field. +func (u *VodUpsert) ClearSpriteThumbnailsColumns() *VodUpsert { + u.SetNull(vod.FieldSpriteThumbnailsColumns) + return u +} + // SetStreamedAt sets the "streamed_at" field. func (u *VodUpsert) SetStreamedAt(v time.Time) *VodUpsert { u.Set(vod.FieldStreamedAt, v) @@ -1601,6 +1954,27 @@ func (u *VodUpsertOne) UpdateExtID() *VodUpsertOne { }) } +// SetClipExtVodID sets the "clip_ext_vod_id" field. +func (u *VodUpsertOne) SetClipExtVodID(v string) *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.SetClipExtVodID(v) + }) +} + +// UpdateClipExtVodID sets the "clip_ext_vod_id" field to the value that was provided on create. +func (u *VodUpsertOne) UpdateClipExtVodID() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.UpdateClipExtVodID() + }) +} + +// ClearClipExtVodID clears the value of the "clip_ext_vod_id" field. +func (u *VodUpsertOne) ClearClipExtVodID() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.ClearClipExtVodID() + }) +} + // SetExtStreamID sets the "ext_stream_id" field. func (u *VodUpsertOne) SetExtStreamID(v string) *VodUpsertOne { return u.Update(func(s *VodUpsert) { @@ -1685,6 +2059,34 @@ func (u *VodUpsertOne) UpdateDuration() *VodUpsertOne { }) } +// SetClipVodOffset sets the "clip_vod_offset" field. +func (u *VodUpsertOne) SetClipVodOffset(v int) *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.SetClipVodOffset(v) + }) +} + +// AddClipVodOffset adds v to the "clip_vod_offset" field. +func (u *VodUpsertOne) AddClipVodOffset(v int) *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.AddClipVodOffset(v) + }) +} + +// UpdateClipVodOffset sets the "clip_vod_offset" field to the value that was provided on create. +func (u *VodUpsertOne) UpdateClipVodOffset() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.UpdateClipVodOffset() + }) +} + +// ClearClipVodOffset clears the value of the "clip_vod_offset" field. +func (u *VodUpsertOne) ClearClipVodOffset() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.ClearClipVodOffset() + }) +} + // SetViews sets the "views" field. func (u *VodUpsertOne) SetViews(v int) *VodUpsertOne { return u.Update(func(s *VodUpsert) { @@ -2161,6 +2563,181 @@ func (u *VodUpsertOne) UpdateLocalViews() *VodUpsertOne { }) } +// SetSpriteThumbnailsEnabled sets the "sprite_thumbnails_enabled" field. +func (u *VodUpsertOne) SetSpriteThumbnailsEnabled(v bool) *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.SetSpriteThumbnailsEnabled(v) + }) +} + +// UpdateSpriteThumbnailsEnabled sets the "sprite_thumbnails_enabled" field to the value that was provided on create. +func (u *VodUpsertOne) UpdateSpriteThumbnailsEnabled() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.UpdateSpriteThumbnailsEnabled() + }) +} + +// SetSpriteThumbnailsImages sets the "sprite_thumbnails_images" field. +func (u *VodUpsertOne) SetSpriteThumbnailsImages(v []string) *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.SetSpriteThumbnailsImages(v) + }) +} + +// UpdateSpriteThumbnailsImages sets the "sprite_thumbnails_images" field to the value that was provided on create. +func (u *VodUpsertOne) UpdateSpriteThumbnailsImages() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.UpdateSpriteThumbnailsImages() + }) +} + +// ClearSpriteThumbnailsImages clears the value of the "sprite_thumbnails_images" field. +func (u *VodUpsertOne) ClearSpriteThumbnailsImages() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.ClearSpriteThumbnailsImages() + }) +} + +// SetSpriteThumbnailsInterval sets the "sprite_thumbnails_interval" field. +func (u *VodUpsertOne) SetSpriteThumbnailsInterval(v int) *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.SetSpriteThumbnailsInterval(v) + }) +} + +// AddSpriteThumbnailsInterval adds v to the "sprite_thumbnails_interval" field. +func (u *VodUpsertOne) AddSpriteThumbnailsInterval(v int) *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.AddSpriteThumbnailsInterval(v) + }) +} + +// UpdateSpriteThumbnailsInterval sets the "sprite_thumbnails_interval" field to the value that was provided on create. +func (u *VodUpsertOne) UpdateSpriteThumbnailsInterval() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.UpdateSpriteThumbnailsInterval() + }) +} + +// ClearSpriteThumbnailsInterval clears the value of the "sprite_thumbnails_interval" field. +func (u *VodUpsertOne) ClearSpriteThumbnailsInterval() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.ClearSpriteThumbnailsInterval() + }) +} + +// SetSpriteThumbnailsWidth sets the "sprite_thumbnails_width" field. +func (u *VodUpsertOne) SetSpriteThumbnailsWidth(v int) *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.SetSpriteThumbnailsWidth(v) + }) +} + +// AddSpriteThumbnailsWidth adds v to the "sprite_thumbnails_width" field. +func (u *VodUpsertOne) AddSpriteThumbnailsWidth(v int) *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.AddSpriteThumbnailsWidth(v) + }) +} + +// UpdateSpriteThumbnailsWidth sets the "sprite_thumbnails_width" field to the value that was provided on create. +func (u *VodUpsertOne) UpdateSpriteThumbnailsWidth() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.UpdateSpriteThumbnailsWidth() + }) +} + +// ClearSpriteThumbnailsWidth clears the value of the "sprite_thumbnails_width" field. +func (u *VodUpsertOne) ClearSpriteThumbnailsWidth() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.ClearSpriteThumbnailsWidth() + }) +} + +// SetSpriteThumbnailsHeight sets the "sprite_thumbnails_height" field. +func (u *VodUpsertOne) SetSpriteThumbnailsHeight(v int) *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.SetSpriteThumbnailsHeight(v) + }) +} + +// AddSpriteThumbnailsHeight adds v to the "sprite_thumbnails_height" field. +func (u *VodUpsertOne) AddSpriteThumbnailsHeight(v int) *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.AddSpriteThumbnailsHeight(v) + }) +} + +// UpdateSpriteThumbnailsHeight sets the "sprite_thumbnails_height" field to the value that was provided on create. +func (u *VodUpsertOne) UpdateSpriteThumbnailsHeight() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.UpdateSpriteThumbnailsHeight() + }) +} + +// ClearSpriteThumbnailsHeight clears the value of the "sprite_thumbnails_height" field. +func (u *VodUpsertOne) ClearSpriteThumbnailsHeight() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.ClearSpriteThumbnailsHeight() + }) +} + +// SetSpriteThumbnailsRows sets the "sprite_thumbnails_rows" field. +func (u *VodUpsertOne) SetSpriteThumbnailsRows(v int) *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.SetSpriteThumbnailsRows(v) + }) +} + +// AddSpriteThumbnailsRows adds v to the "sprite_thumbnails_rows" field. +func (u *VodUpsertOne) AddSpriteThumbnailsRows(v int) *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.AddSpriteThumbnailsRows(v) + }) +} + +// UpdateSpriteThumbnailsRows sets the "sprite_thumbnails_rows" field to the value that was provided on create. +func (u *VodUpsertOne) UpdateSpriteThumbnailsRows() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.UpdateSpriteThumbnailsRows() + }) +} + +// ClearSpriteThumbnailsRows clears the value of the "sprite_thumbnails_rows" field. +func (u *VodUpsertOne) ClearSpriteThumbnailsRows() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.ClearSpriteThumbnailsRows() + }) +} + +// SetSpriteThumbnailsColumns sets the "sprite_thumbnails_columns" field. +func (u *VodUpsertOne) SetSpriteThumbnailsColumns(v int) *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.SetSpriteThumbnailsColumns(v) + }) +} + +// AddSpriteThumbnailsColumns adds v to the "sprite_thumbnails_columns" field. +func (u *VodUpsertOne) AddSpriteThumbnailsColumns(v int) *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.AddSpriteThumbnailsColumns(v) + }) +} + +// UpdateSpriteThumbnailsColumns sets the "sprite_thumbnails_columns" field to the value that was provided on create. +func (u *VodUpsertOne) UpdateSpriteThumbnailsColumns() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.UpdateSpriteThumbnailsColumns() + }) +} + +// ClearSpriteThumbnailsColumns clears the value of the "sprite_thumbnails_columns" field. +func (u *VodUpsertOne) ClearSpriteThumbnailsColumns() *VodUpsertOne { + return u.Update(func(s *VodUpsert) { + s.ClearSpriteThumbnailsColumns() + }) +} + // SetStreamedAt sets the "streamed_at" field. func (u *VodUpsertOne) SetStreamedAt(v time.Time) *VodUpsertOne { return u.Update(func(s *VodUpsert) { @@ -2421,6 +2998,27 @@ func (u *VodUpsertBulk) UpdateExtID() *VodUpsertBulk { }) } +// SetClipExtVodID sets the "clip_ext_vod_id" field. +func (u *VodUpsertBulk) SetClipExtVodID(v string) *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.SetClipExtVodID(v) + }) +} + +// UpdateClipExtVodID sets the "clip_ext_vod_id" field to the value that was provided on create. +func (u *VodUpsertBulk) UpdateClipExtVodID() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.UpdateClipExtVodID() + }) +} + +// ClearClipExtVodID clears the value of the "clip_ext_vod_id" field. +func (u *VodUpsertBulk) ClearClipExtVodID() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.ClearClipExtVodID() + }) +} + // SetExtStreamID sets the "ext_stream_id" field. func (u *VodUpsertBulk) SetExtStreamID(v string) *VodUpsertBulk { return u.Update(func(s *VodUpsert) { @@ -2505,6 +3103,34 @@ func (u *VodUpsertBulk) UpdateDuration() *VodUpsertBulk { }) } +// SetClipVodOffset sets the "clip_vod_offset" field. +func (u *VodUpsertBulk) SetClipVodOffset(v int) *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.SetClipVodOffset(v) + }) +} + +// AddClipVodOffset adds v to the "clip_vod_offset" field. +func (u *VodUpsertBulk) AddClipVodOffset(v int) *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.AddClipVodOffset(v) + }) +} + +// UpdateClipVodOffset sets the "clip_vod_offset" field to the value that was provided on create. +func (u *VodUpsertBulk) UpdateClipVodOffset() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.UpdateClipVodOffset() + }) +} + +// ClearClipVodOffset clears the value of the "clip_vod_offset" field. +func (u *VodUpsertBulk) ClearClipVodOffset() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.ClearClipVodOffset() + }) +} + // SetViews sets the "views" field. func (u *VodUpsertBulk) SetViews(v int) *VodUpsertBulk { return u.Update(func(s *VodUpsert) { @@ -2981,6 +3607,181 @@ func (u *VodUpsertBulk) UpdateLocalViews() *VodUpsertBulk { }) } +// SetSpriteThumbnailsEnabled sets the "sprite_thumbnails_enabled" field. +func (u *VodUpsertBulk) SetSpriteThumbnailsEnabled(v bool) *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.SetSpriteThumbnailsEnabled(v) + }) +} + +// UpdateSpriteThumbnailsEnabled sets the "sprite_thumbnails_enabled" field to the value that was provided on create. +func (u *VodUpsertBulk) UpdateSpriteThumbnailsEnabled() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.UpdateSpriteThumbnailsEnabled() + }) +} + +// SetSpriteThumbnailsImages sets the "sprite_thumbnails_images" field. +func (u *VodUpsertBulk) SetSpriteThumbnailsImages(v []string) *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.SetSpriteThumbnailsImages(v) + }) +} + +// UpdateSpriteThumbnailsImages sets the "sprite_thumbnails_images" field to the value that was provided on create. +func (u *VodUpsertBulk) UpdateSpriteThumbnailsImages() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.UpdateSpriteThumbnailsImages() + }) +} + +// ClearSpriteThumbnailsImages clears the value of the "sprite_thumbnails_images" field. +func (u *VodUpsertBulk) ClearSpriteThumbnailsImages() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.ClearSpriteThumbnailsImages() + }) +} + +// SetSpriteThumbnailsInterval sets the "sprite_thumbnails_interval" field. +func (u *VodUpsertBulk) SetSpriteThumbnailsInterval(v int) *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.SetSpriteThumbnailsInterval(v) + }) +} + +// AddSpriteThumbnailsInterval adds v to the "sprite_thumbnails_interval" field. +func (u *VodUpsertBulk) AddSpriteThumbnailsInterval(v int) *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.AddSpriteThumbnailsInterval(v) + }) +} + +// UpdateSpriteThumbnailsInterval sets the "sprite_thumbnails_interval" field to the value that was provided on create. +func (u *VodUpsertBulk) UpdateSpriteThumbnailsInterval() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.UpdateSpriteThumbnailsInterval() + }) +} + +// ClearSpriteThumbnailsInterval clears the value of the "sprite_thumbnails_interval" field. +func (u *VodUpsertBulk) ClearSpriteThumbnailsInterval() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.ClearSpriteThumbnailsInterval() + }) +} + +// SetSpriteThumbnailsWidth sets the "sprite_thumbnails_width" field. +func (u *VodUpsertBulk) SetSpriteThumbnailsWidth(v int) *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.SetSpriteThumbnailsWidth(v) + }) +} + +// AddSpriteThumbnailsWidth adds v to the "sprite_thumbnails_width" field. +func (u *VodUpsertBulk) AddSpriteThumbnailsWidth(v int) *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.AddSpriteThumbnailsWidth(v) + }) +} + +// UpdateSpriteThumbnailsWidth sets the "sprite_thumbnails_width" field to the value that was provided on create. +func (u *VodUpsertBulk) UpdateSpriteThumbnailsWidth() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.UpdateSpriteThumbnailsWidth() + }) +} + +// ClearSpriteThumbnailsWidth clears the value of the "sprite_thumbnails_width" field. +func (u *VodUpsertBulk) ClearSpriteThumbnailsWidth() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.ClearSpriteThumbnailsWidth() + }) +} + +// SetSpriteThumbnailsHeight sets the "sprite_thumbnails_height" field. +func (u *VodUpsertBulk) SetSpriteThumbnailsHeight(v int) *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.SetSpriteThumbnailsHeight(v) + }) +} + +// AddSpriteThumbnailsHeight adds v to the "sprite_thumbnails_height" field. +func (u *VodUpsertBulk) AddSpriteThumbnailsHeight(v int) *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.AddSpriteThumbnailsHeight(v) + }) +} + +// UpdateSpriteThumbnailsHeight sets the "sprite_thumbnails_height" field to the value that was provided on create. +func (u *VodUpsertBulk) UpdateSpriteThumbnailsHeight() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.UpdateSpriteThumbnailsHeight() + }) +} + +// ClearSpriteThumbnailsHeight clears the value of the "sprite_thumbnails_height" field. +func (u *VodUpsertBulk) ClearSpriteThumbnailsHeight() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.ClearSpriteThumbnailsHeight() + }) +} + +// SetSpriteThumbnailsRows sets the "sprite_thumbnails_rows" field. +func (u *VodUpsertBulk) SetSpriteThumbnailsRows(v int) *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.SetSpriteThumbnailsRows(v) + }) +} + +// AddSpriteThumbnailsRows adds v to the "sprite_thumbnails_rows" field. +func (u *VodUpsertBulk) AddSpriteThumbnailsRows(v int) *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.AddSpriteThumbnailsRows(v) + }) +} + +// UpdateSpriteThumbnailsRows sets the "sprite_thumbnails_rows" field to the value that was provided on create. +func (u *VodUpsertBulk) UpdateSpriteThumbnailsRows() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.UpdateSpriteThumbnailsRows() + }) +} + +// ClearSpriteThumbnailsRows clears the value of the "sprite_thumbnails_rows" field. +func (u *VodUpsertBulk) ClearSpriteThumbnailsRows() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.ClearSpriteThumbnailsRows() + }) +} + +// SetSpriteThumbnailsColumns sets the "sprite_thumbnails_columns" field. +func (u *VodUpsertBulk) SetSpriteThumbnailsColumns(v int) *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.SetSpriteThumbnailsColumns(v) + }) +} + +// AddSpriteThumbnailsColumns adds v to the "sprite_thumbnails_columns" field. +func (u *VodUpsertBulk) AddSpriteThumbnailsColumns(v int) *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.AddSpriteThumbnailsColumns(v) + }) +} + +// UpdateSpriteThumbnailsColumns sets the "sprite_thumbnails_columns" field to the value that was provided on create. +func (u *VodUpsertBulk) UpdateSpriteThumbnailsColumns() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.UpdateSpriteThumbnailsColumns() + }) +} + +// ClearSpriteThumbnailsColumns clears the value of the "sprite_thumbnails_columns" field. +func (u *VodUpsertBulk) ClearSpriteThumbnailsColumns() *VodUpsertBulk { + return u.Update(func(s *VodUpsert) { + s.ClearSpriteThumbnailsColumns() + }) +} + // SetStreamedAt sets the "streamed_at" field. func (u *VodUpsertBulk) SetStreamedAt(v time.Time) *VodUpsertBulk { return u.Update(func(s *VodUpsert) { diff --git a/ent/vod_update.go b/ent/vod_update.go index ff1fb588..56766f8f 100644 --- a/ent/vod_update.go +++ b/ent/vod_update.go @@ -10,6 +10,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/dialect/sql/sqljson" "entgo.io/ent/schema/field" "github.com/google/uuid" "github.com/zibbp/ganymede/ent/channel" @@ -50,6 +51,26 @@ func (vu *VodUpdate) SetNillableExtID(s *string) *VodUpdate { return vu } +// SetClipExtVodID sets the "clip_ext_vod_id" field. +func (vu *VodUpdate) SetClipExtVodID(s string) *VodUpdate { + vu.mutation.SetClipExtVodID(s) + return vu +} + +// SetNillableClipExtVodID sets the "clip_ext_vod_id" field if the given value is not nil. +func (vu *VodUpdate) SetNillableClipExtVodID(s *string) *VodUpdate { + if s != nil { + vu.SetClipExtVodID(*s) + } + return vu +} + +// ClearClipExtVodID clears the value of the "clip_ext_vod_id" field. +func (vu *VodUpdate) ClearClipExtVodID() *VodUpdate { + vu.mutation.ClearClipExtVodID() + return vu +} + // SetExtStreamID sets the "ext_stream_id" field. func (vu *VodUpdate) SetExtStreamID(s string) *VodUpdate { vu.mutation.SetExtStreamID(s) @@ -133,6 +154,33 @@ func (vu *VodUpdate) AddDuration(i int) *VodUpdate { return vu } +// SetClipVodOffset sets the "clip_vod_offset" field. +func (vu *VodUpdate) SetClipVodOffset(i int) *VodUpdate { + vu.mutation.ResetClipVodOffset() + vu.mutation.SetClipVodOffset(i) + return vu +} + +// SetNillableClipVodOffset sets the "clip_vod_offset" field if the given value is not nil. +func (vu *VodUpdate) SetNillableClipVodOffset(i *int) *VodUpdate { + if i != nil { + vu.SetClipVodOffset(*i) + } + return vu +} + +// AddClipVodOffset adds i to the "clip_vod_offset" field. +func (vu *VodUpdate) AddClipVodOffset(i int) *VodUpdate { + vu.mutation.AddClipVodOffset(i) + return vu +} + +// ClearClipVodOffset clears the value of the "clip_vod_offset" field. +func (vu *VodUpdate) ClearClipVodOffset() *VodUpdate { + vu.mutation.ClearClipVodOffset() + return vu +} + // SetViews sets the "views" field. func (vu *VodUpdate) SetViews(i int) *VodUpdate { vu.mutation.ResetViews() @@ -591,6 +639,173 @@ func (vu *VodUpdate) AddLocalViews(i int) *VodUpdate { return vu } +// SetSpriteThumbnailsEnabled sets the "sprite_thumbnails_enabled" field. +func (vu *VodUpdate) SetSpriteThumbnailsEnabled(b bool) *VodUpdate { + vu.mutation.SetSpriteThumbnailsEnabled(b) + return vu +} + +// SetNillableSpriteThumbnailsEnabled sets the "sprite_thumbnails_enabled" field if the given value is not nil. +func (vu *VodUpdate) SetNillableSpriteThumbnailsEnabled(b *bool) *VodUpdate { + if b != nil { + vu.SetSpriteThumbnailsEnabled(*b) + } + return vu +} + +// SetSpriteThumbnailsImages sets the "sprite_thumbnails_images" field. +func (vu *VodUpdate) SetSpriteThumbnailsImages(s []string) *VodUpdate { + vu.mutation.SetSpriteThumbnailsImages(s) + return vu +} + +// AppendSpriteThumbnailsImages appends s to the "sprite_thumbnails_images" field. +func (vu *VodUpdate) AppendSpriteThumbnailsImages(s []string) *VodUpdate { + vu.mutation.AppendSpriteThumbnailsImages(s) + return vu +} + +// ClearSpriteThumbnailsImages clears the value of the "sprite_thumbnails_images" field. +func (vu *VodUpdate) ClearSpriteThumbnailsImages() *VodUpdate { + vu.mutation.ClearSpriteThumbnailsImages() + return vu +} + +// SetSpriteThumbnailsInterval sets the "sprite_thumbnails_interval" field. +func (vu *VodUpdate) SetSpriteThumbnailsInterval(i int) *VodUpdate { + vu.mutation.ResetSpriteThumbnailsInterval() + vu.mutation.SetSpriteThumbnailsInterval(i) + return vu +} + +// SetNillableSpriteThumbnailsInterval sets the "sprite_thumbnails_interval" field if the given value is not nil. +func (vu *VodUpdate) SetNillableSpriteThumbnailsInterval(i *int) *VodUpdate { + if i != nil { + vu.SetSpriteThumbnailsInterval(*i) + } + return vu +} + +// AddSpriteThumbnailsInterval adds i to the "sprite_thumbnails_interval" field. +func (vu *VodUpdate) AddSpriteThumbnailsInterval(i int) *VodUpdate { + vu.mutation.AddSpriteThumbnailsInterval(i) + return vu +} + +// ClearSpriteThumbnailsInterval clears the value of the "sprite_thumbnails_interval" field. +func (vu *VodUpdate) ClearSpriteThumbnailsInterval() *VodUpdate { + vu.mutation.ClearSpriteThumbnailsInterval() + return vu +} + +// SetSpriteThumbnailsWidth sets the "sprite_thumbnails_width" field. +func (vu *VodUpdate) SetSpriteThumbnailsWidth(i int) *VodUpdate { + vu.mutation.ResetSpriteThumbnailsWidth() + vu.mutation.SetSpriteThumbnailsWidth(i) + return vu +} + +// SetNillableSpriteThumbnailsWidth sets the "sprite_thumbnails_width" field if the given value is not nil. +func (vu *VodUpdate) SetNillableSpriteThumbnailsWidth(i *int) *VodUpdate { + if i != nil { + vu.SetSpriteThumbnailsWidth(*i) + } + return vu +} + +// AddSpriteThumbnailsWidth adds i to the "sprite_thumbnails_width" field. +func (vu *VodUpdate) AddSpriteThumbnailsWidth(i int) *VodUpdate { + vu.mutation.AddSpriteThumbnailsWidth(i) + return vu +} + +// ClearSpriteThumbnailsWidth clears the value of the "sprite_thumbnails_width" field. +func (vu *VodUpdate) ClearSpriteThumbnailsWidth() *VodUpdate { + vu.mutation.ClearSpriteThumbnailsWidth() + return vu +} + +// SetSpriteThumbnailsHeight sets the "sprite_thumbnails_height" field. +func (vu *VodUpdate) SetSpriteThumbnailsHeight(i int) *VodUpdate { + vu.mutation.ResetSpriteThumbnailsHeight() + vu.mutation.SetSpriteThumbnailsHeight(i) + return vu +} + +// SetNillableSpriteThumbnailsHeight sets the "sprite_thumbnails_height" field if the given value is not nil. +func (vu *VodUpdate) SetNillableSpriteThumbnailsHeight(i *int) *VodUpdate { + if i != nil { + vu.SetSpriteThumbnailsHeight(*i) + } + return vu +} + +// AddSpriteThumbnailsHeight adds i to the "sprite_thumbnails_height" field. +func (vu *VodUpdate) AddSpriteThumbnailsHeight(i int) *VodUpdate { + vu.mutation.AddSpriteThumbnailsHeight(i) + return vu +} + +// ClearSpriteThumbnailsHeight clears the value of the "sprite_thumbnails_height" field. +func (vu *VodUpdate) ClearSpriteThumbnailsHeight() *VodUpdate { + vu.mutation.ClearSpriteThumbnailsHeight() + return vu +} + +// SetSpriteThumbnailsRows sets the "sprite_thumbnails_rows" field. +func (vu *VodUpdate) SetSpriteThumbnailsRows(i int) *VodUpdate { + vu.mutation.ResetSpriteThumbnailsRows() + vu.mutation.SetSpriteThumbnailsRows(i) + return vu +} + +// SetNillableSpriteThumbnailsRows sets the "sprite_thumbnails_rows" field if the given value is not nil. +func (vu *VodUpdate) SetNillableSpriteThumbnailsRows(i *int) *VodUpdate { + if i != nil { + vu.SetSpriteThumbnailsRows(*i) + } + return vu +} + +// AddSpriteThumbnailsRows adds i to the "sprite_thumbnails_rows" field. +func (vu *VodUpdate) AddSpriteThumbnailsRows(i int) *VodUpdate { + vu.mutation.AddSpriteThumbnailsRows(i) + return vu +} + +// ClearSpriteThumbnailsRows clears the value of the "sprite_thumbnails_rows" field. +func (vu *VodUpdate) ClearSpriteThumbnailsRows() *VodUpdate { + vu.mutation.ClearSpriteThumbnailsRows() + return vu +} + +// SetSpriteThumbnailsColumns sets the "sprite_thumbnails_columns" field. +func (vu *VodUpdate) SetSpriteThumbnailsColumns(i int) *VodUpdate { + vu.mutation.ResetSpriteThumbnailsColumns() + vu.mutation.SetSpriteThumbnailsColumns(i) + return vu +} + +// SetNillableSpriteThumbnailsColumns sets the "sprite_thumbnails_columns" field if the given value is not nil. +func (vu *VodUpdate) SetNillableSpriteThumbnailsColumns(i *int) *VodUpdate { + if i != nil { + vu.SetSpriteThumbnailsColumns(*i) + } + return vu +} + +// AddSpriteThumbnailsColumns adds i to the "sprite_thumbnails_columns" field. +func (vu *VodUpdate) AddSpriteThumbnailsColumns(i int) *VodUpdate { + vu.mutation.AddSpriteThumbnailsColumns(i) + return vu +} + +// ClearSpriteThumbnailsColumns clears the value of the "sprite_thumbnails_columns" field. +func (vu *VodUpdate) ClearSpriteThumbnailsColumns() *VodUpdate { + vu.mutation.ClearSpriteThumbnailsColumns() + return vu +} + // SetStreamedAt sets the "streamed_at" field. func (vu *VodUpdate) SetStreamedAt(t time.Time) *VodUpdate { vu.mutation.SetStreamedAt(t) @@ -871,6 +1086,12 @@ func (vu *VodUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := vu.mutation.ExtID(); ok { _spec.SetField(vod.FieldExtID, field.TypeString, value) } + if value, ok := vu.mutation.ClipExtVodID(); ok { + _spec.SetField(vod.FieldClipExtVodID, field.TypeString, value) + } + if vu.mutation.ClipExtVodIDCleared() { + _spec.ClearField(vod.FieldClipExtVodID, field.TypeString) + } if value, ok := vu.mutation.ExtStreamID(); ok { _spec.SetField(vod.FieldExtStreamID, field.TypeString, value) } @@ -892,6 +1113,15 @@ func (vu *VodUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := vu.mutation.AddedDuration(); ok { _spec.AddField(vod.FieldDuration, field.TypeInt, value) } + if value, ok := vu.mutation.ClipVodOffset(); ok { + _spec.SetField(vod.FieldClipVodOffset, field.TypeInt, value) + } + if value, ok := vu.mutation.AddedClipVodOffset(); ok { + _spec.AddField(vod.FieldClipVodOffset, field.TypeInt, value) + } + if vu.mutation.ClipVodOffsetCleared() { + _spec.ClearField(vod.FieldClipVodOffset, field.TypeInt) + } if value, ok := vu.mutation.Views(); ok { _spec.SetField(vod.FieldViews, field.TypeInt, value) } @@ -1024,6 +1254,65 @@ func (vu *VodUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := vu.mutation.AddedLocalViews(); ok { _spec.AddField(vod.FieldLocalViews, field.TypeInt, value) } + if value, ok := vu.mutation.SpriteThumbnailsEnabled(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsEnabled, field.TypeBool, value) + } + if value, ok := vu.mutation.SpriteThumbnailsImages(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsImages, field.TypeJSON, value) + } + if value, ok := vu.mutation.AppendedSpriteThumbnailsImages(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, vod.FieldSpriteThumbnailsImages, value) + }) + } + if vu.mutation.SpriteThumbnailsImagesCleared() { + _spec.ClearField(vod.FieldSpriteThumbnailsImages, field.TypeJSON) + } + if value, ok := vu.mutation.SpriteThumbnailsInterval(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsInterval, field.TypeInt, value) + } + if value, ok := vu.mutation.AddedSpriteThumbnailsInterval(); ok { + _spec.AddField(vod.FieldSpriteThumbnailsInterval, field.TypeInt, value) + } + if vu.mutation.SpriteThumbnailsIntervalCleared() { + _spec.ClearField(vod.FieldSpriteThumbnailsInterval, field.TypeInt) + } + if value, ok := vu.mutation.SpriteThumbnailsWidth(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsWidth, field.TypeInt, value) + } + if value, ok := vu.mutation.AddedSpriteThumbnailsWidth(); ok { + _spec.AddField(vod.FieldSpriteThumbnailsWidth, field.TypeInt, value) + } + if vu.mutation.SpriteThumbnailsWidthCleared() { + _spec.ClearField(vod.FieldSpriteThumbnailsWidth, field.TypeInt) + } + if value, ok := vu.mutation.SpriteThumbnailsHeight(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsHeight, field.TypeInt, value) + } + if value, ok := vu.mutation.AddedSpriteThumbnailsHeight(); ok { + _spec.AddField(vod.FieldSpriteThumbnailsHeight, field.TypeInt, value) + } + if vu.mutation.SpriteThumbnailsHeightCleared() { + _spec.ClearField(vod.FieldSpriteThumbnailsHeight, field.TypeInt) + } + if value, ok := vu.mutation.SpriteThumbnailsRows(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsRows, field.TypeInt, value) + } + if value, ok := vu.mutation.AddedSpriteThumbnailsRows(); ok { + _spec.AddField(vod.FieldSpriteThumbnailsRows, field.TypeInt, value) + } + if vu.mutation.SpriteThumbnailsRowsCleared() { + _spec.ClearField(vod.FieldSpriteThumbnailsRows, field.TypeInt) + } + if value, ok := vu.mutation.SpriteThumbnailsColumns(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsColumns, field.TypeInt, value) + } + if value, ok := vu.mutation.AddedSpriteThumbnailsColumns(); ok { + _spec.AddField(vod.FieldSpriteThumbnailsColumns, field.TypeInt, value) + } + if vu.mutation.SpriteThumbnailsColumnsCleared() { + _spec.ClearField(vod.FieldSpriteThumbnailsColumns, field.TypeInt) + } if value, ok := vu.mutation.StreamedAt(); ok { _spec.SetField(vod.FieldStreamedAt, field.TypeTime, value) } @@ -1302,6 +1591,26 @@ func (vuo *VodUpdateOne) SetNillableExtID(s *string) *VodUpdateOne { return vuo } +// SetClipExtVodID sets the "clip_ext_vod_id" field. +func (vuo *VodUpdateOne) SetClipExtVodID(s string) *VodUpdateOne { + vuo.mutation.SetClipExtVodID(s) + return vuo +} + +// SetNillableClipExtVodID sets the "clip_ext_vod_id" field if the given value is not nil. +func (vuo *VodUpdateOne) SetNillableClipExtVodID(s *string) *VodUpdateOne { + if s != nil { + vuo.SetClipExtVodID(*s) + } + return vuo +} + +// ClearClipExtVodID clears the value of the "clip_ext_vod_id" field. +func (vuo *VodUpdateOne) ClearClipExtVodID() *VodUpdateOne { + vuo.mutation.ClearClipExtVodID() + return vuo +} + // SetExtStreamID sets the "ext_stream_id" field. func (vuo *VodUpdateOne) SetExtStreamID(s string) *VodUpdateOne { vuo.mutation.SetExtStreamID(s) @@ -1385,6 +1694,33 @@ func (vuo *VodUpdateOne) AddDuration(i int) *VodUpdateOne { return vuo } +// SetClipVodOffset sets the "clip_vod_offset" field. +func (vuo *VodUpdateOne) SetClipVodOffset(i int) *VodUpdateOne { + vuo.mutation.ResetClipVodOffset() + vuo.mutation.SetClipVodOffset(i) + return vuo +} + +// SetNillableClipVodOffset sets the "clip_vod_offset" field if the given value is not nil. +func (vuo *VodUpdateOne) SetNillableClipVodOffset(i *int) *VodUpdateOne { + if i != nil { + vuo.SetClipVodOffset(*i) + } + return vuo +} + +// AddClipVodOffset adds i to the "clip_vod_offset" field. +func (vuo *VodUpdateOne) AddClipVodOffset(i int) *VodUpdateOne { + vuo.mutation.AddClipVodOffset(i) + return vuo +} + +// ClearClipVodOffset clears the value of the "clip_vod_offset" field. +func (vuo *VodUpdateOne) ClearClipVodOffset() *VodUpdateOne { + vuo.mutation.ClearClipVodOffset() + return vuo +} + // SetViews sets the "views" field. func (vuo *VodUpdateOne) SetViews(i int) *VodUpdateOne { vuo.mutation.ResetViews() @@ -1843,6 +2179,173 @@ func (vuo *VodUpdateOne) AddLocalViews(i int) *VodUpdateOne { return vuo } +// SetSpriteThumbnailsEnabled sets the "sprite_thumbnails_enabled" field. +func (vuo *VodUpdateOne) SetSpriteThumbnailsEnabled(b bool) *VodUpdateOne { + vuo.mutation.SetSpriteThumbnailsEnabled(b) + return vuo +} + +// SetNillableSpriteThumbnailsEnabled sets the "sprite_thumbnails_enabled" field if the given value is not nil. +func (vuo *VodUpdateOne) SetNillableSpriteThumbnailsEnabled(b *bool) *VodUpdateOne { + if b != nil { + vuo.SetSpriteThumbnailsEnabled(*b) + } + return vuo +} + +// SetSpriteThumbnailsImages sets the "sprite_thumbnails_images" field. +func (vuo *VodUpdateOne) SetSpriteThumbnailsImages(s []string) *VodUpdateOne { + vuo.mutation.SetSpriteThumbnailsImages(s) + return vuo +} + +// AppendSpriteThumbnailsImages appends s to the "sprite_thumbnails_images" field. +func (vuo *VodUpdateOne) AppendSpriteThumbnailsImages(s []string) *VodUpdateOne { + vuo.mutation.AppendSpriteThumbnailsImages(s) + return vuo +} + +// ClearSpriteThumbnailsImages clears the value of the "sprite_thumbnails_images" field. +func (vuo *VodUpdateOne) ClearSpriteThumbnailsImages() *VodUpdateOne { + vuo.mutation.ClearSpriteThumbnailsImages() + return vuo +} + +// SetSpriteThumbnailsInterval sets the "sprite_thumbnails_interval" field. +func (vuo *VodUpdateOne) SetSpriteThumbnailsInterval(i int) *VodUpdateOne { + vuo.mutation.ResetSpriteThumbnailsInterval() + vuo.mutation.SetSpriteThumbnailsInterval(i) + return vuo +} + +// SetNillableSpriteThumbnailsInterval sets the "sprite_thumbnails_interval" field if the given value is not nil. +func (vuo *VodUpdateOne) SetNillableSpriteThumbnailsInterval(i *int) *VodUpdateOne { + if i != nil { + vuo.SetSpriteThumbnailsInterval(*i) + } + return vuo +} + +// AddSpriteThumbnailsInterval adds i to the "sprite_thumbnails_interval" field. +func (vuo *VodUpdateOne) AddSpriteThumbnailsInterval(i int) *VodUpdateOne { + vuo.mutation.AddSpriteThumbnailsInterval(i) + return vuo +} + +// ClearSpriteThumbnailsInterval clears the value of the "sprite_thumbnails_interval" field. +func (vuo *VodUpdateOne) ClearSpriteThumbnailsInterval() *VodUpdateOne { + vuo.mutation.ClearSpriteThumbnailsInterval() + return vuo +} + +// SetSpriteThumbnailsWidth sets the "sprite_thumbnails_width" field. +func (vuo *VodUpdateOne) SetSpriteThumbnailsWidth(i int) *VodUpdateOne { + vuo.mutation.ResetSpriteThumbnailsWidth() + vuo.mutation.SetSpriteThumbnailsWidth(i) + return vuo +} + +// SetNillableSpriteThumbnailsWidth sets the "sprite_thumbnails_width" field if the given value is not nil. +func (vuo *VodUpdateOne) SetNillableSpriteThumbnailsWidth(i *int) *VodUpdateOne { + if i != nil { + vuo.SetSpriteThumbnailsWidth(*i) + } + return vuo +} + +// AddSpriteThumbnailsWidth adds i to the "sprite_thumbnails_width" field. +func (vuo *VodUpdateOne) AddSpriteThumbnailsWidth(i int) *VodUpdateOne { + vuo.mutation.AddSpriteThumbnailsWidth(i) + return vuo +} + +// ClearSpriteThumbnailsWidth clears the value of the "sprite_thumbnails_width" field. +func (vuo *VodUpdateOne) ClearSpriteThumbnailsWidth() *VodUpdateOne { + vuo.mutation.ClearSpriteThumbnailsWidth() + return vuo +} + +// SetSpriteThumbnailsHeight sets the "sprite_thumbnails_height" field. +func (vuo *VodUpdateOne) SetSpriteThumbnailsHeight(i int) *VodUpdateOne { + vuo.mutation.ResetSpriteThumbnailsHeight() + vuo.mutation.SetSpriteThumbnailsHeight(i) + return vuo +} + +// SetNillableSpriteThumbnailsHeight sets the "sprite_thumbnails_height" field if the given value is not nil. +func (vuo *VodUpdateOne) SetNillableSpriteThumbnailsHeight(i *int) *VodUpdateOne { + if i != nil { + vuo.SetSpriteThumbnailsHeight(*i) + } + return vuo +} + +// AddSpriteThumbnailsHeight adds i to the "sprite_thumbnails_height" field. +func (vuo *VodUpdateOne) AddSpriteThumbnailsHeight(i int) *VodUpdateOne { + vuo.mutation.AddSpriteThumbnailsHeight(i) + return vuo +} + +// ClearSpriteThumbnailsHeight clears the value of the "sprite_thumbnails_height" field. +func (vuo *VodUpdateOne) ClearSpriteThumbnailsHeight() *VodUpdateOne { + vuo.mutation.ClearSpriteThumbnailsHeight() + return vuo +} + +// SetSpriteThumbnailsRows sets the "sprite_thumbnails_rows" field. +func (vuo *VodUpdateOne) SetSpriteThumbnailsRows(i int) *VodUpdateOne { + vuo.mutation.ResetSpriteThumbnailsRows() + vuo.mutation.SetSpriteThumbnailsRows(i) + return vuo +} + +// SetNillableSpriteThumbnailsRows sets the "sprite_thumbnails_rows" field if the given value is not nil. +func (vuo *VodUpdateOne) SetNillableSpriteThumbnailsRows(i *int) *VodUpdateOne { + if i != nil { + vuo.SetSpriteThumbnailsRows(*i) + } + return vuo +} + +// AddSpriteThumbnailsRows adds i to the "sprite_thumbnails_rows" field. +func (vuo *VodUpdateOne) AddSpriteThumbnailsRows(i int) *VodUpdateOne { + vuo.mutation.AddSpriteThumbnailsRows(i) + return vuo +} + +// ClearSpriteThumbnailsRows clears the value of the "sprite_thumbnails_rows" field. +func (vuo *VodUpdateOne) ClearSpriteThumbnailsRows() *VodUpdateOne { + vuo.mutation.ClearSpriteThumbnailsRows() + return vuo +} + +// SetSpriteThumbnailsColumns sets the "sprite_thumbnails_columns" field. +func (vuo *VodUpdateOne) SetSpriteThumbnailsColumns(i int) *VodUpdateOne { + vuo.mutation.ResetSpriteThumbnailsColumns() + vuo.mutation.SetSpriteThumbnailsColumns(i) + return vuo +} + +// SetNillableSpriteThumbnailsColumns sets the "sprite_thumbnails_columns" field if the given value is not nil. +func (vuo *VodUpdateOne) SetNillableSpriteThumbnailsColumns(i *int) *VodUpdateOne { + if i != nil { + vuo.SetSpriteThumbnailsColumns(*i) + } + return vuo +} + +// AddSpriteThumbnailsColumns adds i to the "sprite_thumbnails_columns" field. +func (vuo *VodUpdateOne) AddSpriteThumbnailsColumns(i int) *VodUpdateOne { + vuo.mutation.AddSpriteThumbnailsColumns(i) + return vuo +} + +// ClearSpriteThumbnailsColumns clears the value of the "sprite_thumbnails_columns" field. +func (vuo *VodUpdateOne) ClearSpriteThumbnailsColumns() *VodUpdateOne { + vuo.mutation.ClearSpriteThumbnailsColumns() + return vuo +} + // SetStreamedAt sets the "streamed_at" field. func (vuo *VodUpdateOne) SetStreamedAt(t time.Time) *VodUpdateOne { vuo.mutation.SetStreamedAt(t) @@ -2153,6 +2656,12 @@ func (vuo *VodUpdateOne) sqlSave(ctx context.Context) (_node *Vod, err error) { if value, ok := vuo.mutation.ExtID(); ok { _spec.SetField(vod.FieldExtID, field.TypeString, value) } + if value, ok := vuo.mutation.ClipExtVodID(); ok { + _spec.SetField(vod.FieldClipExtVodID, field.TypeString, value) + } + if vuo.mutation.ClipExtVodIDCleared() { + _spec.ClearField(vod.FieldClipExtVodID, field.TypeString) + } if value, ok := vuo.mutation.ExtStreamID(); ok { _spec.SetField(vod.FieldExtStreamID, field.TypeString, value) } @@ -2174,6 +2683,15 @@ func (vuo *VodUpdateOne) sqlSave(ctx context.Context) (_node *Vod, err error) { if value, ok := vuo.mutation.AddedDuration(); ok { _spec.AddField(vod.FieldDuration, field.TypeInt, value) } + if value, ok := vuo.mutation.ClipVodOffset(); ok { + _spec.SetField(vod.FieldClipVodOffset, field.TypeInt, value) + } + if value, ok := vuo.mutation.AddedClipVodOffset(); ok { + _spec.AddField(vod.FieldClipVodOffset, field.TypeInt, value) + } + if vuo.mutation.ClipVodOffsetCleared() { + _spec.ClearField(vod.FieldClipVodOffset, field.TypeInt) + } if value, ok := vuo.mutation.Views(); ok { _spec.SetField(vod.FieldViews, field.TypeInt, value) } @@ -2306,6 +2824,65 @@ func (vuo *VodUpdateOne) sqlSave(ctx context.Context) (_node *Vod, err error) { if value, ok := vuo.mutation.AddedLocalViews(); ok { _spec.AddField(vod.FieldLocalViews, field.TypeInt, value) } + if value, ok := vuo.mutation.SpriteThumbnailsEnabled(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsEnabled, field.TypeBool, value) + } + if value, ok := vuo.mutation.SpriteThumbnailsImages(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsImages, field.TypeJSON, value) + } + if value, ok := vuo.mutation.AppendedSpriteThumbnailsImages(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, vod.FieldSpriteThumbnailsImages, value) + }) + } + if vuo.mutation.SpriteThumbnailsImagesCleared() { + _spec.ClearField(vod.FieldSpriteThumbnailsImages, field.TypeJSON) + } + if value, ok := vuo.mutation.SpriteThumbnailsInterval(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsInterval, field.TypeInt, value) + } + if value, ok := vuo.mutation.AddedSpriteThumbnailsInterval(); ok { + _spec.AddField(vod.FieldSpriteThumbnailsInterval, field.TypeInt, value) + } + if vuo.mutation.SpriteThumbnailsIntervalCleared() { + _spec.ClearField(vod.FieldSpriteThumbnailsInterval, field.TypeInt) + } + if value, ok := vuo.mutation.SpriteThumbnailsWidth(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsWidth, field.TypeInt, value) + } + if value, ok := vuo.mutation.AddedSpriteThumbnailsWidth(); ok { + _spec.AddField(vod.FieldSpriteThumbnailsWidth, field.TypeInt, value) + } + if vuo.mutation.SpriteThumbnailsWidthCleared() { + _spec.ClearField(vod.FieldSpriteThumbnailsWidth, field.TypeInt) + } + if value, ok := vuo.mutation.SpriteThumbnailsHeight(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsHeight, field.TypeInt, value) + } + if value, ok := vuo.mutation.AddedSpriteThumbnailsHeight(); ok { + _spec.AddField(vod.FieldSpriteThumbnailsHeight, field.TypeInt, value) + } + if vuo.mutation.SpriteThumbnailsHeightCleared() { + _spec.ClearField(vod.FieldSpriteThumbnailsHeight, field.TypeInt) + } + if value, ok := vuo.mutation.SpriteThumbnailsRows(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsRows, field.TypeInt, value) + } + if value, ok := vuo.mutation.AddedSpriteThumbnailsRows(); ok { + _spec.AddField(vod.FieldSpriteThumbnailsRows, field.TypeInt, value) + } + if vuo.mutation.SpriteThumbnailsRowsCleared() { + _spec.ClearField(vod.FieldSpriteThumbnailsRows, field.TypeInt) + } + if value, ok := vuo.mutation.SpriteThumbnailsColumns(); ok { + _spec.SetField(vod.FieldSpriteThumbnailsColumns, field.TypeInt, value) + } + if value, ok := vuo.mutation.AddedSpriteThumbnailsColumns(); ok { + _spec.AddField(vod.FieldSpriteThumbnailsColumns, field.TypeInt, value) + } + if vuo.mutation.SpriteThumbnailsColumnsCleared() { + _spec.ClearField(vod.FieldSpriteThumbnailsColumns, field.TypeInt) + } if value, ok := vuo.mutation.StreamedAt(); ok { _spec.SetField(vod.FieldStreamedAt, field.TypeTime, value) } diff --git a/entrypoint.sh b/entrypoint.sh index 10bf40e2..82cc3365 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -33,15 +33,5 @@ gosu abc fc-cache -f export DOTNET_BUNDLE_EXTRACT_BASE_DIR=/tmp export FONTCONFIG_CACHE=/var/cache/fontconfig -# start api and worker as user abc -gosu abc /opt/app/ganymede-api & -api_pid=$! - -# delay 5 seconds to wait for api to start -sleep 5 - -gosu abc /opt/app/ganymede-worker & -worker_pid=$! - -# wait -wait $api_pid $worker_pid \ No newline at end of file +# start applications +/usr/bin/supervisord -c /opt/app/supervisord.conf \ No newline at end of file diff --git a/frontend/.eslintrc.json b/frontend/.eslintrc.json new file mode 100644 index 00000000..37224185 --- /dev/null +++ b/frontend/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": ["next/core-web-vitals", "next/typescript"] +} diff --git a/frontend/.gitignore b/frontend/.gitignore new file mode 100644 index 00000000..44fdeff2 --- /dev/null +++ b/frontend/.gitignore @@ -0,0 +1,42 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/versions + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# env files (can opt-in for committing if needed) +.env* + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts + +certificates \ No newline at end of file diff --git a/frontend/.vscode/extensions.json b/frontend/.vscode/extensions.json new file mode 100644 index 00000000..7d608d2a --- /dev/null +++ b/frontend/.vscode/extensions.json @@ -0,0 +1,11 @@ +{ + "recommendations": [ + "burkeholland.simple-react-snippets", + "esbenp.prettier-vscode", + "vunguyentuan.vscode-postcss", + "eamodio.gitlens", + "dbaeumer.vscode-eslint", + "vunguyentuan.vscode-css-variables", + "naumovs.color-highlight" + ] +} \ No newline at end of file diff --git a/frontend/.vscode/settings.json b/frontend/.vscode/settings.json new file mode 100644 index 00000000..076b96ee --- /dev/null +++ b/frontend/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "cssVariables.lookupFiles": [ + "**/*.css", + "**/*.scss", + "**/*.sass", + "**/*.less", + "node_modules/@mantine/core/styles.css" + ] +} \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 00000000..09f9b694 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,70 @@ +# syntax=docker.io/docker/dockerfile:1 + +FROM node:22-alpine AS base + +# Install dependencies only when needed +FROM base AS deps +# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. +RUN apk add --no-cache libc6-compat +WORKDIR /app + +# Install dependencies based on the preferred package manager +COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./ +RUN \ + if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ + elif [ -f package-lock.json ]; then npm ci --force; \ + elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ + else echo "Lockfile not found." && exit 1; \ + fi + + +# Rebuild the source code only when needed +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +# Next.js collects completely anonymous telemetry data about general usage. +# Learn more here: https://nextjs.org/telemetry +# Uncomment the following line in case you want to disable telemetry during the build. +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN \ + if [ -f yarn.lock ]; then yarn run build; \ + elif [ -f package-lock.json ]; then npm run build; \ + elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \ + else echo "Lockfile not found." && exit 1; \ + fi + +# Production image, copy all the files and run next +FROM base AS runner +WORKDIR /app + +ENV NODE_ENV=production +# Uncomment the following line in case you want to disable telemetry during runtime. +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +COPY --from=builder /app/public ./public + +# Set the correct permission for prerender cache +RUN mkdir .next +RUN chown nextjs:nodejs .next + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs + +EXPOSE 3000 + +ENV PORT=3000 + +# server.js is created by next build from the standalone output +# https://nextjs.org/docs/pages/api-reference/next-config-js/output +ENV HOSTNAME="0.0.0.0" +CMD ["node", "server.js"] \ No newline at end of file diff --git a/frontend/README.md b/frontend/README.md new file mode 100644 index 00000000..db4b38bd --- /dev/null +++ b/frontend/README.md @@ -0,0 +1,3 @@ +# Ganymede Frontend + +Ganymede frontend is a [Next.js](https://nextjs.org) project. diff --git a/frontend/app/admin/blocked-videos/AdminBlockedVideosPage.module.css b/frontend/app/admin/blocked-videos/AdminBlockedVideosPage.module.css new file mode 100644 index 00000000..96bf4254 --- /dev/null +++ b/frontend/app/admin/blocked-videos/AdminBlockedVideosPage.module.css @@ -0,0 +1,6 @@ +.actionButton { + cursor: pointer; +} +.actionButtons { + display: flex; +} diff --git a/frontend/app/admin/blocked-videos/page.tsx b/frontend/app/admin/blocked-videos/page.tsx new file mode 100644 index 00000000..c0eff2ec --- /dev/null +++ b/frontend/app/admin/blocked-videos/page.tsx @@ -0,0 +1,169 @@ +"use client" +import { ActionIcon, Container, Group, TextInput, Title, Box, Button, Drawer, Modal, Text } from "@mantine/core"; +import { useDebouncedValue, useDisclosure } from "@mantine/hooks"; +import { DataTable, DataTableSortStatus } from "mantine-datatable"; +import { useEffect, useState } from "react"; +import sortBy from "lodash/sortBy"; +import GanymedeLoadingText from "@/app/components/utils/GanymedeLoadingText"; +import { IconSearch, IconTrash } from "@tabler/icons-react"; +import dayjs from "dayjs"; + +import classes from "./AdminBlockedVideosPage.module.css" +import { BlockedVideo, useGetBlockedVideos } from "@/app/hooks/useBlockedVideos"; +import { useAxiosPrivate } from "@/app/hooks/useAxios"; +import DeleteBlockedVideoModalContent from "@/app/components/admin/blocked-videos/DeleteModalContent"; +import AdminBlockedVideosDrawerContent from "@/app/components/admin/blocked-videos/DrawerContent"; + +const AdminBlockedVideosPage = () => { + useEffect(() => { + document.title = "Admin - Blocked Videos"; + }, []); + const [page, setPage] = useState(1); + const [perPage, setPerPage] = useState(20); + const [records, setRecords] = useState([]); + const [initialRecords, setInitialRecords] = useState(false); + const [sortStatus, setSortStatus] = useState>({ + columnAccessor: "id", + direction: "asc", + }); + const [query, setQuery] = useState(""); + const [debouncedQuery] = useDebouncedValue(query, 500); + const [activeBlockedVideo, setActiveBlockedVideo] = useState(null); + + const [blockedVideoDrawerOpened, { open: openBlockedVideoDrawer, close: closeBlockedVideoDrawer }] = useDisclosure(false); + const [deleteModalOpened, { open: openDeleteModal, close: closeDeleteModal }] = useDisclosure(false); + const axiosPrivate = useAxiosPrivate() + + const { data: blockedVideos, isPending, isError } = useGetBlockedVideos(axiosPrivate) + + useEffect(() => { + if (!blockedVideos) return; + + let filteredData = [...blockedVideos] as BlockedVideo[]; + + // Apply search filter + if (debouncedQuery) { + filteredData = filteredData.filter((blockedVideo) => { + return ( + blockedVideo.id.toString().includes(debouncedQuery) + ); + }); + } + + // Apply sorting + const sortedData = sortBy(filteredData, sortStatus.columnAccessor); + filteredData = sortStatus.direction === "desc" ? sortedData.reverse() : sortedData; + + // Apply pagination + const from = (page - 1) * perPage; + const to = from + perPage; + setRecords(filteredData.slice(from, to)); + + if (!initialRecords) { + setInitialRecords(true); + } + }, [blockedVideos, page, perPage, sortStatus, debouncedQuery, initialRecords]); + + const handleDeleteModal = (blockedVideo: BlockedVideo) => { + setActiveBlockedVideo(blockedVideo); + openDeleteModal() + }; + + if (isPending) return ( + + ) + if (isError) return
Error loading blocked videos
+ + return ( +
+ + + Manage Blocked Videos + + + + + + External platform video IDs that are blocked from being archived. + + +
+ } + value={query} + onChange={(e) => setQuery(e.currentTarget.value)} + mb={10} + /> + +
+ + withTableBorder + borderRadius="sm" + withColumnBorders + striped + highlightOnHover + records={records} + columns={[ + { accessor: "id", title: "ID" }, + { + accessor: "created_at", + title: "Created At", + sortable: true, + render: ({ created_at }) => ( +
{dayjs(created_at).format("YYYY/MM/DD")}
+ ), + }, + { + accessor: "actions", + title: "Actions", + render: (blockedVideo) => ( + + handleDeleteModal(blockedVideo)} + className={classes.actionButton} + variant="light" + color="red" + > + + + + ), + }, + ]} + totalRecords={blockedVideos?.length ?? 0} + page={page} + recordsPerPage={perPage} + onPageChange={(p) => setPage(p)} + recordsPerPageOptions={[20, 40, 100]} + onRecordsPerPageChange={setPerPage} + sortStatus={sortStatus} + onSortStatusChange={setSortStatus} + /> +
+
+ + + + + + + {activeBlockedVideo && ( + + )} + + +
+ ); +} + +export default AdminBlockedVideosPage; \ No newline at end of file diff --git a/frontend/app/admin/channels/AdminChannelsPage.module.css b/frontend/app/admin/channels/AdminChannelsPage.module.css new file mode 100644 index 00000000..96bf4254 --- /dev/null +++ b/frontend/app/admin/channels/AdminChannelsPage.module.css @@ -0,0 +1,6 @@ +.actionButton { + cursor: pointer; +} +.actionButtons { + display: flex; +} diff --git a/frontend/app/admin/channels/page.tsx b/frontend/app/admin/channels/page.tsx new file mode 100644 index 00000000..bbf16ae4 --- /dev/null +++ b/frontend/app/admin/channels/page.tsx @@ -0,0 +1,208 @@ +"use client" +import { Channel, useFetchChannels } from "@/app/hooks/useChannels"; +import { ActionIcon, Container, Group, TextInput, Title, Box, Button, Drawer, Modal } from "@mantine/core"; +import { useDebouncedValue, useDisclosure } from "@mantine/hooks"; +import { DataTable, DataTableSortStatus } from "mantine-datatable"; +import { useEffect, useState } from "react"; +import sortBy from "lodash/sortBy"; +import GanymedeLoadingText from "@/app/components/utils/GanymedeLoadingText"; +import { IconPencil, IconSearch, IconTrash } from "@tabler/icons-react"; +import dayjs from "dayjs"; + +import classes from "./AdminChannelsPage.module.css" +import AdminChannelDrawerContent, { ChannelEditMode } from "@/app/components/admin/channel/DrawerContent"; +import PlatformChannelDrawerContent from "@/app/components/admin/channel/PlatformDrawerContent"; +import DeleteChannelModalContent from "@/app/components/admin/channel/DeleteModalContent"; + +const AdminChannelsPage = () => { + useEffect(() => { + document.title = "Admin - Channels"; + }, []); + const [page, setPage] = useState(1); + const [perPage, setPerPage] = useState(20); + const [records, setRecords] = useState([]); + const [initialRecords, setInitialRecords] = useState(false); + const [sortStatus, setSortStatus] = useState>({ + columnAccessor: "name", + direction: "asc", + }); + const [query, setQuery] = useState(""); + const [debouncedQuery] = useDebouncedValue(query, 500); + const [activeChannel, setActiveChannel] = useState(null); + const [drawerEditMode, setDrawerEditMode] = useState(ChannelEditMode.Create) + + const [channelDrawerOpened, { open: openChannelDrawer, close: closeChannelDrawer }] = useDisclosure(false); + const [platformChannelDrawerOpened, { open: openPlatformChannelDrawer, close: closePlatformChannelDrawer }] = useDisclosure(false); + const [deleteModalOpened, { open: openDeleteModal, close: closeDeleteModal }] = useDisclosure(false); + + + const { data: channels, isPending, isError } = useFetchChannels() + + useEffect(() => { + if (!channels) return; + + let filteredData = [...channels] as Channel[]; + + // Apply search filter + if (debouncedQuery) { + filteredData = filteredData.filter((channel) => { + return ( + channel.id.toString().includes(debouncedQuery) || + channel.name.toLowerCase().includes(debouncedQuery.toLowerCase()) || + channel.display_name.toLowerCase().includes(debouncedQuery.toLowerCase()) + ); + }); + } + + // Apply sorting + const sortedData = sortBy(filteredData, sortStatus.columnAccessor); + filteredData = sortStatus.direction === "desc" ? sortedData.reverse() : sortedData; + + // Apply pagination + const from = (page - 1) * perPage; + const to = from + perPage; + setRecords(filteredData.slice(from, to)); + + if (!initialRecords) { + setInitialRecords(true); + } + }, [channels, page, perPage, sortStatus, debouncedQuery, initialRecords]); + + const openDrawer = (mode: ChannelEditMode, channel: Channel) => { + setActiveChannel(channel); + setDrawerEditMode(ChannelEditMode.Edit) + openChannelDrawer() + // setDrawerOpened(true); + }; + + const handleDeleteModal = (channel: Channel) => { + setActiveChannel(channel); + openDeleteModal() + }; + + if (isPending) return ( + + ) + if (isError) return
Error loading channels
+ + return ( +
+ + + Manage Channels + + + + + + + +
+ } + value={query} + onChange={(e) => setQuery(e.currentTarget.value)} + mb={10} + /> + +
+ + withTableBorder + borderRadius="sm" + withColumnBorders + striped + highlightOnHover + records={records} + columns={[ + { accessor: "id", title: "ID" }, + { accessor: "ext_id", title: "External ID" }, + { accessor: "name", title: "Name", sortable: true }, + { accessor: "display_name", title: "Display Name", sortable: true }, + { + accessor: "retention", + title: "Video Retention", + sortable: false, + render: ({ retention }) => ( + retention ? ( +
+ ) : ( +
+ ) + ), + }, + { + accessor: "created_at", + title: "Created At", + sortable: true, + render: ({ created_at }) => ( +
{dayjs(created_at).format("YYYY/MM/DD")}
+ ), + }, + { + accessor: "actions", + title: "Actions", + render: (channel) => ( + + openDrawer(ChannelEditMode.Edit, channel)} + className={classes.actionButton} + variant="light" + > + + + handleDeleteModal(channel)} + className={classes.actionButton} + variant="light" + color="red" + > + + + + ), + }, + ]} + totalRecords={channels?.length ?? 0} + page={page} + recordsPerPage={perPage} + onPageChange={(p) => setPage(p)} + recordsPerPageOptions={[20, 40, 100]} + onRecordsPerPageChange={setPerPage} + sortStatus={sortStatus} + onSortStatusChange={setSortStatus} + /> +
+
+ + + + + + + + + + + + +
+ ); +} + +export default AdminChannelsPage; \ No newline at end of file diff --git a/frontend/app/admin/info/AdminInformationPage.module.css b/frontend/app/admin/info/AdminInformationPage.module.css new file mode 100644 index 00000000..affb1415 --- /dev/null +++ b/frontend/app/admin/info/AdminInformationPage.module.css @@ -0,0 +1,3 @@ +.link { + color: var(--mantine-color-blue-6); +} diff --git a/frontend/app/admin/info/page.tsx b/frontend/app/admin/info/page.tsx new file mode 100644 index 00000000..ff35b705 --- /dev/null +++ b/frontend/app/admin/info/page.tsx @@ -0,0 +1,74 @@ +"use client" +import GanymedeLoadingText from "@/app/components/utils/GanymedeLoadingText"; +import { useGetGanymedeInformation } from "@/app/hooks/useAdmin"; +import { useAxiosPrivate } from "@/app/hooks/useAxios"; +import { Card, Container, Flex, Title, Text, Code } from "@mantine/core"; +import Link from "next/link"; +import classes from "./AdminInformationPage.module.css" +import { useEffect } from "react"; + +const AdminInformationPage = () => { + useEffect(() => { + document.title = "Admin - Info"; + }, []); + const axiosPrivate = useAxiosPrivate() + + const { data, isPending, isError } = useGetGanymedeInformation(axiosPrivate) + + if (isPending) return ( + + ) + if (isError) return
Error loading Ganymede information
+ + + return ( +
+ + + {/* server info */} +
+ + Server + + + Commit: + {data.commit_hash} + + + Build Date: + {data.build_time} + + + Uptime: + {data.uptime} + +
+ {/* package info */} +
+ + Package Versions + + + TwitchDownloader: + {data.program_versions.twitch_downloader} + + + Chat-Downloader: + {data.program_versions.chat_downloader} + + + Streamlink: + {data.program_versions.streamlink} + +
+ FFmpeg: + {data.program_versions.ffmpeg} +
+
+
+
+
+ ); +} + +export default AdminInformationPage; \ No newline at end of file diff --git a/frontend/app/admin/queue/AdminQueuePage.module.css b/frontend/app/admin/queue/AdminQueuePage.module.css new file mode 100644 index 00000000..96bf4254 --- /dev/null +++ b/frontend/app/admin/queue/AdminQueuePage.module.css @@ -0,0 +1,6 @@ +.actionButton { + cursor: pointer; +} +.actionButtons { + display: flex; +} diff --git a/frontend/app/admin/queue/page.tsx b/frontend/app/admin/queue/page.tsx new file mode 100644 index 00000000..560100fb --- /dev/null +++ b/frontend/app/admin/queue/page.tsx @@ -0,0 +1,228 @@ +"use client" +import { ActionIcon, Container, Group, TextInput, Title, Box, Drawer, Modal, Tooltip, Text } from "@mantine/core"; +import { useDebouncedValue, useDisclosure } from "@mantine/hooks"; +import { DataTable, DataTableSortStatus } from "mantine-datatable"; +import { useEffect, useState } from "react"; +import sortBy from "lodash/sortBy"; +import GanymedeLoadingText from "@/app/components/utils/GanymedeLoadingText"; +import { IconEye, IconPencil, IconSearch, IconTrash } from "@tabler/icons-react"; +import dayjs from "dayjs"; +import classes from "./AdminQueuePage.module.css" +import { Queue, useGetQueueItems } from "@/app/hooks/useQueue"; +import { useAxiosPrivate } from "@/app/hooks/useAxios"; +import AdminQueueDrawerContent from "@/app/components/admin/queue/DrawerContent"; +import DeleteQueueModalContent from "@/app/components/admin/queue/DeleteModalContent"; +import Link from "next/link"; + +const AdminQueuePage = () => { + useEffect(() => { + document.title = "Admin - Queue"; + }, []); + const [page, setPage] = useState(1); + const [perPage, setPerPage] = useState(20); + const [records, setRecords] = useState([]); + const [initialRecords, setInitialRecords] = useState(false); + const [sortStatus, setSortStatus] = useState>({ + columnAccessor: "name", + direction: "asc", + }); + const [query, setQuery] = useState(""); + const [debouncedQuery] = useDebouncedValue(query, 500); + const [activeQueue, setActiveQueue] = useState(null); + + const [queueDrawerOpened, { open: openQueueDrawer, close: closeQueueDrawer }] = useDisclosure(false); + const [deleteModalOpened, { open: openDeleteModal, close: closeDeleteModal }] = useDisclosure(false); + + const axiosPrivate = useAxiosPrivate() + const { data: queues, isPending, isError } = useGetQueueItems(axiosPrivate, false) + + useEffect(() => { + if (!queues) return; + + let filteredData = [...queues] as Queue[]; + + // Apply search filter + if (debouncedQuery) { + filteredData = filteredData.filter((queue) => { + return ( + queue.id.toString().includes(debouncedQuery) + ); + }); + } + + // Apply sorting + const sortedData = sortBy(filteredData, sortStatus.columnAccessor); + filteredData = sortStatus.direction === "desc" ? sortedData.reverse() : sortedData; + + // Apply pagination + const from = (page - 1) * perPage; + const to = from + perPage; + setRecords(filteredData.slice(from, to)); + + if (!initialRecords) { + setInitialRecords(true); + } + }, [queues, page, perPage, sortStatus, debouncedQuery, initialRecords]); + + const openDrawer = (queue: Queue) => { + setActiveQueue(queue); + openQueueDrawer() + }; + + const handleDeleteModal = (queue: Queue) => { + setActiveQueue(queue); + openDeleteModal() + }; + + if (isPending) return ( + + ) + if (isError) return
Error loading queue items
+ + return ( +
+ + + Manage Queue + + + +
+ } + value={query} + onChange={(e) => setQuery(e.currentTarget.value)} + mb={10} + /> + +
+ + withTableBorder + borderRadius="sm" + withColumnBorders + striped + highlightOnHover + records={records} + columns={[ + { + accessor: "id", title: "ID", + render: ({ id }) => ( + + {id} + + ), + }, + { + accessor: "edges.vod.id", title: "Video ID", sortable: true, + render: (queue) => ( + + {queue.edges.vod.id} + + ), + }, + { + accessor: "edges.vod.ext_id", + title: "External Video ID", + sortable: true, + render: (queue) => ( + + {queue.edges.vod.ext_id} + + ), + }, + { + accessor: "processing", + title: "Processing", + sortable: true, + render: ({ processing }) => { + return processing ? "✅" : "❌"; + }, + }, + { + accessor: "on_hold", + title: "On Hold", + sortable: true, + render: ({ on_hold }) => { + return on_hold ? "✅" : "❌"; + }, + }, + { + accessor: "live_archive", + title: "Live Archive", + sortable: true, + render: ({ live_archive }) => { + return live_archive ? "✅" : "❌"; + }, + }, + { + accessor: "created_at", + title: "Created At", + sortable: true, + render: ({ created_at }) => ( +
{dayjs(created_at).format("YYYY/MM/DD")}
+ ), + }, + { + accessor: "actions", + title: "Actions", + width: "150px", + render: (queue) => ( + + + + + openDrawer(queue)} + className={classes.actionButton} + variant="light" + > + + + handleDeleteModal(queue)} + className={classes.actionButton} + variant="light" + color="red" + > + + + + ), + }, + ]} + totalRecords={queues?.length ?? 0} + page={page} + recordsPerPage={perPage} + onPageChange={(p) => setPage(p)} + recordsPerPageOptions={[20, 40, 100]} + onRecordsPerPageChange={setPerPage} + sortStatus={sortStatus} + onSortStatusChange={setSortStatus} + /> +
+
+ + + {activeQueue && ( + + )} + + + + + {activeQueue && ( + + )} + + +
+ ); +} + +export default AdminQueuePage; \ No newline at end of file diff --git a/frontend/app/admin/settings/AdminSettingsPage.module.css b/frontend/app/admin/settings/AdminSettingsPage.module.css new file mode 100644 index 00000000..7850c73c --- /dev/null +++ b/frontend/app/admin/settings/AdminSettingsPage.module.css @@ -0,0 +1,12 @@ +.link { + color: var(--mantine-color-blue-6); +} +.proxyList { + display: flex; + align-items: center; + justify-content: space-between; +} +.proxyInput { + width: 100%; + margin-right: 1rem; +} diff --git a/frontend/app/admin/settings/page.tsx b/frontend/app/admin/settings/page.tsx new file mode 100644 index 00000000..42413cff --- /dev/null +++ b/frontend/app/admin/settings/page.tsx @@ -0,0 +1,541 @@ +"use client" +import GanymedeLoadingText from "@/app/components/utils/GanymedeLoadingText" +import { useAxiosPrivate } from "@/app/hooks/useAxios" +import { Config, NotificationType, ProxyListItem, useEditConfig, useGetConfig, useTestNotification } from "@/app/hooks/useConfig" +import { ActionIcon, Button, Card, Checkbox, Code, Collapse, Container, Flex, MultiSelect, Text, Textarea, TextInput, Title } from "@mantine/core" +import { useForm } from "@mantine/form" +import { useDisclosure } from "@mantine/hooks" +import Link from "next/link" +import { useEffect, useState } from "react" +import classes from "./AdminSettingsPage.module.css" +import { IconPlus, IconTrash } from "@tabler/icons-react" +import { Channel, useFetchChannels } from "@/app/hooks/useChannels" +import { showNotification } from "@mantine/notifications" + +interface SelectOption { + label: string; + value: string; +} + +const AdminSettingsPage = () => { + useEffect(() => { + document.title = "Admin - Settings"; + }, []); + const [notificationsOpened, { toggle: toggleNotifications }] = useDisclosure(false); + const [storageTemplateOpened, { toggle: toggleStorageTemplate }] = useDisclosure(false); + const [channelSelect, setChannelSelect] = useState([]); + const axiosPrivate = useAxiosPrivate() + + const testNotificationMutate = useTestNotification() + + const editConfigMutate = useEditConfig() + + const { data, isPending, isError } = useGetConfig(axiosPrivate) + + const form = useForm({ + mode: "controlled", + initialValues: { + registration_enabled: data?.registration_enabled ?? true, + parameters: { + twitch_token: data?.parameters.twitch_token || "", + video_convert: data?.parameters.video_convert || "", + chat_render: data?.parameters.chat_render || "", + streamlink_live: data?.parameters.streamlink_live || "", + }, + archive: { + save_as_hls: data?.archive.save_as_hls ?? false, + }, + notifications: { + video_success_webhook_url: data?.notifications.video_success_webhook_url || "", + video_success_template: data?.notifications.video_success_template || "", + video_success_enabled: data?.notifications.video_success_enabled ?? false, + live_success_webhook_url: data?.notifications.live_success_webhook_url || "", + live_success_template: data?.notifications.live_success_template || "", + live_success_enabled: data?.notifications.live_success_enabled ?? false, + error_webhook_url: data?.notifications.error_webhook_url || "", + error_template: data?.notifications.error_template || "", + error_enabled: data?.notifications.error_enabled ?? false, + is_live_webhook_url: data?.notifications.is_live_webhook_url || "", + is_live_template: data?.notifications.is_live_template || "", + is_live_enabled: data?.notifications.is_live_enabled ?? false, + }, + storage_templates: { + folder_template: data?.storage_templates.folder_template || "", + file_template: data?.storage_templates.file_template || "", + }, + livestream: { + proxies: data?.livestream.proxies || [], + proxy_enabled: data?.livestream.proxy_enabled ?? true, + proxy_whitelist: data?.livestream.proxy_whitelist || [], + } + } + }) + + useEffect(() => { + if (!data || !form) return + + form.setValues(data) + form.resetDirty(data) + + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [data]) + + const folderExample1 = "{{id}}-{{uuid}}"; + const folderExample2 = "{{date}}-{{title}}-{{type}}-{{id}}-{{uuid}}"; + const fileExample1 = "{{id}}"; + + const { data: channels } = useFetchChannels(); + + useEffect(() => { + if (!channels) return; + + const transformedChannels: SelectOption[] = channels.map((channel: Channel) => ({ + label: channel.name, + value: channel.name, + })); + + setChannelSelect(transformedChannels); + }, [channels]); + + const handleSubmitForm = async () => { + try { + const formValues = form.getValues() + + const submitConfig: Config = { ...formValues } + + await editConfigMutate.mutateAsync({ + axiosPrivate, + config: submitConfig + }); + + showNotification({ + message: "Settings Saved", + color: "green" + }); + + } catch (error) { + console.error(error); + } + } + + if (isPending) return ( + + ) + if (isError) return
Error loading settings
+ + return ( +
+ + +
{ + handleSubmitForm() + })}> + Settings + Visit the wiki for documentation about each setting. + + Application + + + + + + Must be a webhook URL or an Apprise HTTP URL, visit the wiki for more information. + + {/* video archive success */} + Video Archive Success Notification + + + + + +