Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | 2x 2x 8x 2x 2x 2x 28x 2x 2x 2x 2x 4x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 6x 2x 6x 2x 2x 2x 4x 2x 2x 2x 2x 2x 56x 28x 2x 28x 26x 12x 2x 28x | <template>
<WidgetPanel
:title="$t('telemetryScriptActivity.title')"
:meta="$t('telemetryScriptActivity.meta', { runs: MIN_RUNS, percent: failingPercent })"
:count="rows.length"
>
<ul
class="flex flex-wrap items-center gap-x-4 gap-y-1 border-b border-default px-4 py-2 text-xs text-muted"
>
<li v-for="item in legend" :key="item.id" class="flex items-center gap-1.5">
<span class="size-2.5 bg-accented/40" :style="item.style" />
{{ $t(`telemetryScriptActivity.legend.${item.id}`) }}
</li>
</ul>
<div data-scroll-x class="overflow-x-auto">
<table class="data-table">
<thead>
<tr>
<th>{{ $t("telemetryScriptActivity.columns.script") }}</th>
<th class="hidden w-full md:table-cell">
<ol class="flex min-w-xl" aria-hidden="true">
<li
v-for="column in months"
:key="column.day"
class="min-w-0 flex-1"
>
<span v-if="column.month" class="whitespace-nowrap">
{{ column.month }}
</span>
</li>
</ol>
</th>
<th class="numeric">{{ $t("telemetryScriptActivity.columns.runs") }}</th>
<th class="whitespace-nowrap">
{{ $t("telemetryScriptActivity.columns.agent") }}
</th>
<th class="numeric">{{ $t("telemetryScriptActivity.columns.failed") }}</th>
<th class="numeric whitespace-nowrap">
{{ $t("telemetryScriptActivity.columns.last") }}
</th>
</tr>
</thead>
<tbody>
<tr v-for="row in rows" :key="row.name">
<td class="font-mono whitespace-nowrap text-highlighted">{{ row.name }}</td>
<td class="hidden md:table-cell">
<TelemetryDayStrip :days :usage="row.days" :busiest />
</td>
<td class="numeric font-mono">{{ row.runs }}</td>
<td>
<span class="flex items-center gap-2">
<TelemetryCallerSplit :runs="row.total" :agent="row.agent" />
<span class="font-mono text-xs">{{ row.agentShare }}</span>
</span>
</td>
<td class="numeric font-mono" :class="row.failing && 'tone-bad'">
{{ row.failed }}
</td>
<td
class="numeric font-mono whitespace-nowrap text-muted"
:title="row.lastExact"
>
{{ row.last }}
</td>
</tr>
</tbody>
<tfoot class="border-t border-default">
<tr>
<th scope="row" class="text-xs whitespace-nowrap">
{{ $t("telemetryScriptActivity.all") }}
</th>
<td class="hidden md:table-cell">
<TelemetryDayStrip :days :usage="totals" :busiest="busiestTotal" />
</td>
<td class="numeric font-mono font-medium">{{ total.runs }}</td>
<td>
<span class="flex items-center gap-2">
<TelemetryCallerSplit :runs="total.runs" :agent="total.agent" />
<span class="font-mono text-xs">{{ total.agentShare }}</span>
</span>
</td>
<td class="numeric font-mono font-medium">{{ total.failed }}</td>
<td />
</tr>
</tfoot>
</table>
</div>
</WidgetPanel>
</template>
<script setup lang="ts">
import type { DayUsage } from "#layers/snapshot/shared/types/DayUsage.ts";
import type { UsageArtifact } from "#layers/snapshot/shared/types/UsageArtifact.ts";
import { FAILING_RATE, MIN_RUNS } from "#layers/telemetry/shared/usage.ts";
import { dailyTotals, scriptRows, shownDays, sumDays } from "#layers/telemetry/shared/usageView.ts";
interface Props {
usage: Omit<UsageArtifact, "lint">;
}
const { usage } = defineProps<Props>();
const legend = [
{ id: "runs", style: { background: "var(--usage-runs)" } },
{ id: "agent", style: { background: "var(--usage-agent)" } },
{ id: "person", style: { background: "var(--usage-person)" } },
{ id: "failed", style: { boxShadow: FAILED_MARK } },
];
const { t } = useI18n();
const failingPercent = Math.round(FAILING_RATE * 100);
const failedShare = ({ runs, failures }: DayUsage): string =>
runs ? `${percentOf(failures, runs)}%` : "—";
const agentShare = ({ runs, agent }: DayUsage): string =>
runs ? `${percentOf(agent, runs)}%` : "—";
const days = computed(() => shownDays(usage));
const scripts = computed(() => scriptRows(usage));
const rows = computed(() =>
scripts.value.map((row) => ({
name: row.name,
days: row.days,
runs: row.runs || "—",
total: row.runs,
agent: row.agent,
failing: row.failing,
failed: failedShare(row),
agentShare: agentShare(row),
last: shortAge(row.last, t),
lastExact: row.last ? calendarDay(row.last.slice(0, 10)) : "",
})),
);
const totals = computed(() => dailyTotals(scripts.value));
const total = computed(() => {
const sum = sumDays(totals.value);
return { ...sum, failed: failedShare(sum), agentShare: agentShare(sum) };
});
const busiest = computed(() =>
Math.max(1, ...scripts.value.flatMap((row) => row.days.map((day) => day.runs))),
);
const busiestTotal = computed(() => Math.max(1, ...totals.value.map((day) => day.runs)));
/** A month gets a label on its first day, or at the start when at least a week of it is shown. */
const labelsMonth = (day: string, index: number): boolean => {
if (day.endsWith("-01")) return true;
if (index !== 0) return false;
return days.value.slice(0, 7).every((next) => next.slice(0, 7) === day.slice(0, 7));
};
const months = computed(() =>
days.value.map((day, index) => ({
day,
month: labelsMonth(day, index) ? calendarDay(day, "only") : null,
})),
);
</script>
|