mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-03 14:01:47 +01:00
Fix Activity Index not showing up on Players Tables
This commit is contained in:
parent
549a26bcc8
commit
a74fb36b10
@ -137,6 +137,7 @@ public class PlayersTableJSONCreator {
|
||||
.map(player -> TablePlayerDto.builder()
|
||||
.withUuid(player.getPlayerUUID())
|
||||
.withName(player.getName().orElseGet(() -> player.getPlayerUUID().toString()))
|
||||
.withActivityIndex(player.getCurrentActivityIndex().map(ActivityIndex::getValue).orElse(0.0))
|
||||
.withSessionCount((long) player.getSessionCount().orElse(0))
|
||||
.withPlaytimeActive(player.getActivePlaytime().orElse(null))
|
||||
.withLastSeen(player.getLastSeen().orElse(null))
|
||||
|
@ -11,6 +11,8 @@ import FormattedDate from "../../text/FormattedDate";
|
||||
import FormattedTime from "../../text/FormattedTime";
|
||||
import ExtensionIcon from "../../extensions/ExtensionIcon";
|
||||
import {ExtensionValueTableCell} from "../../extensions/ExtensionCard";
|
||||
import {usePreferences} from "../../../hooks/preferencesHook";
|
||||
import {formatDecimals} from "../../../util/formatters";
|
||||
|
||||
const getActivityGroup = value => {
|
||||
const VERY_ACTIVE = 3.75;
|
||||
@ -32,6 +34,8 @@ const getActivityGroup = value => {
|
||||
|
||||
const PlayerListCard = ({data, title, justList, orderBy}) => {
|
||||
const {t} = useTranslation();
|
||||
const {preferencesLoaded, decimalFormat} = usePreferences();
|
||||
|
||||
const [options, setOptions] = useState(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
@ -73,7 +77,7 @@ const PlayerListCard = ({data, title, justList, orderBy}) => {
|
||||
uuid: player.playerUUID,
|
||||
link: <Link to={"/player/" + player.playerUUID}>{player.playerName}</Link>,
|
||||
activityIndex: player.activityIndex,
|
||||
activityIndexAndGroup: player.activityIndex + " (" + t(getActivityGroup(player.activityIndex)) + ")",
|
||||
activityIndexAndGroup: formatDecimals(player.activityIndex, decimalFormat) + " (" + t(getActivityGroup(player.activityIndex)) + ")",
|
||||
activePlaytime: player.playtimeActive,
|
||||
activePlaytimeFormatted: <FormattedTime timeMs={player.playtimeActive}/>,
|
||||
sessions: player.sessionCount,
|
||||
@ -97,13 +101,14 @@ const PlayerListCard = ({data, title, justList, orderBy}) => {
|
||||
data: rows,
|
||||
order: [[orderBy !== undefined ? orderBy : 5, "desc"]]
|
||||
});
|
||||
}, [data, orderBy, t]);
|
||||
}, [data, orderBy, t, formatDecimals, decimalFormat]);
|
||||
|
||||
const rowKeyFunction = useCallback((row, column) => {
|
||||
return row.uuid + "-" + (column ? JSON.stringify(column.data) : '');
|
||||
}, []);
|
||||
|
||||
if (!options) return <CardLoader/>
|
||||
if (!preferencesLoaded) return <></>;
|
||||
if (!options) return <CardLoader/>;
|
||||
|
||||
if (justList) {
|
||||
return (
|
||||
|
@ -122,7 +122,7 @@ const DataTablesTable = ({id, rowKeyFunction, options}) => {
|
||||
if (valA === undefined && valB === undefined) return 0;
|
||||
if (valA === undefined) return sortReversed ? 1 : -1;
|
||||
if (valB === undefined) return sortReversed ? 1 : -1;
|
||||
if (Number.isSafeInteger(valA) && Number.isSafeInteger(valB)) {
|
||||
if (typeof valA === 'number' && typeof valB === 'number') {
|
||||
return sortReversed ? valA - valB : valB - valA;
|
||||
}
|
||||
return sortReversed ? valB.localeCompare(valA) : valA.localeCompare(valB);
|
||||
|
@ -22,4 +22,11 @@ export const formatTimeAmount = (ms) => {
|
||||
out += seconds.toString() + "s ";
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
export const formatDecimals = (value, formatPattern) => {
|
||||
if (!formatPattern) return value;
|
||||
const split = formatPattern.split('.');
|
||||
if (split.length <= 1) return value.toFixed(0);
|
||||
return value.toFixed(split[1].length);
|
||||
}
|
Loading…
Reference in New Issue
Block a user