1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-20 14:37:43 +01:00

Increase silly text chance and replace backend url with env var

This commit is contained in:
Cooper Ransom 2024-04-01 11:01:56 -04:00
parent 2c5c61cb70
commit f25e675f7f
4 changed files with 11 additions and 8 deletions

View file

@ -1,8 +1,8 @@
import { useCallback, useMemo } from "react";
import { useTranslation } from "react-i18next";
// 10% chance of getting a joke title
const shouldGiveJokeTitle = () => Math.floor(Math.random() * 10) === 0;
// 35% chance of getting a joke title (Cooper done changed this code!)
const shouldGiveJokeTitle = () => Math.random() < 0.35;
export function useRandomTranslation() {
const { t } = useTranslation();

View file

@ -5,6 +5,7 @@ import { useNavigate } from "react-router-dom"; // Import Link from react-router
import { ThiccContainer } from "@/components/layout/ThinContainer";
import { Divider } from "@/components/utils/Divider";
import { Heading1, Paragraph } from "@/components/utils/Text";
import { BACKEND_URL } from "@/setup/constants";
import { SubPageLayout } from "./layouts/SubPageLayout";
import { PageTitle } from "./parts/util/PageTitle";
@ -84,7 +85,7 @@ function ConfigValue(props: {
}
async function getRecentPlayedItems() {
const response = await fetch("https://backend.sudo-flix.lol/metrics");
const response = await fetch(BACKEND_URL);
const text = await response.text();
const regex =
@ -118,7 +119,7 @@ async function getRecentPlayedItems() {
}
async function getTotalViews() {
const response = await fetch("https://backend.sudo-flix.lol/metrics");
const response = await fetch(BACKEND_URL);
const text = await response.text();
// Add up all mw_media_watch_count entries
@ -138,7 +139,7 @@ async function getTotalViews() {
}
function getProcessStartTime(): Promise<string> {
return fetch("https://backend.sudo-flix.lol/metrics")
return fetch(BACKEND_URL)
.then((response) => response.text())
.then((text) => {
const regex = /process_start_time_seconds (\d+)/;

View file

@ -4,6 +4,7 @@ import { useNavigate } from "react-router-dom";
import { ThiccContainer } from "@/components/layout/ThinContainer";
import { Divider } from "@/components/utils/Divider";
import { Heading1, Paragraph } from "@/components/utils/Text";
import { BACKEND_URL } from "@/setup/constants";
import { SubPageLayout } from "./layouts/SubPageLayout";
import { PageTitle } from "./parts/util/PageTitle";
@ -24,7 +25,7 @@ function ConfigValue(props: { name: string; children?: ReactNode }) {
}
async function getTopSources() {
const response = await fetch("https://backend.sudo-flix.lol/metrics");
const response = await fetch(BACKEND_URL);
const text = await response.text();
const regex =

View file

@ -3,9 +3,10 @@ import { ReactNode, useEffect, useState } from "react";
import { Divider } from "@/components/utils/Divider";
import { Heading2 } from "@/components/utils/Text";
import { conf } from "@/setup/config";
import { BACKEND_URL } from "@/setup/constants";
async function getAccountNumber() {
const response = await fetch("https://backend.sudo-flix.lol/metrics");
const response = await fetch(BACKEND_URL);
const text = await response.text();
// Adjusted regex to match any hostname
@ -26,7 +27,7 @@ async function getAccountNumber() {
}
async function getAllAccounts() {
const response = await fetch("https://backend.sudo-flix.lol/metrics");
const response = await fetch(BACKEND_URL);
const text = await response.text();
const regex = /mw_user_count{namespace="movie-web"} (\d+)/;