Commit 3d63d9d5 authored by Steven's avatar Steven

chore: fix activity stats

parent 139090fb
import { Divider, Tooltip } from "@mui/joy"; import { Divider, Tooltip } from "@mui/joy";
import clsx from "clsx"; import clsx from "clsx";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { chain } from "lodash-es"; import { countBy } from "lodash-es";
import { useState } from "react"; import { useState } from "react";
import toast from "react-hot-toast"; import toast from "react-hot-toast";
import { memoServiceClient } from "@/grpcweb"; import { memoServiceClient } from "@/grpcweb";
...@@ -53,14 +53,9 @@ const UserStatisticsView = () => { ...@@ -53,14 +53,9 @@ const UserStatisticsView = () => {
memoStats.incompleteTasks += 1; memoStats.incompleteTasks += 1;
} }
}); });
const displayTimes = entities.map((entity) => entity.displayTime).filter(Boolean) as Date[];
const monthStrGroup = chain(displayTimes)
.map((date) => dayjs(date).format("YYYY-MM-DD"))
.countBy()
.value();
setMemoStats(memoStats); setMemoStats(memoStats);
setMemoAmount(entities.length); setMemoAmount(entities.length);
setActivityStats(monthStrGroup); setActivityStats(countBy(entities.map((entity) => dayjs(entity.displayTime).format("YYYY-MM-DD"))));
}, [memoStore.stateId]); }, [memoStore.stateId]);
const rebuildMemoTags = async () => { const rebuildMemoTags = async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment