Start the LeetCode daily question from the site

A "Today's LeetCode" button on the problem list (admin only) does what
`usaco daily` does: it asks LeetCode for the daily question, runs the
clone's lib/leetcode.py to import it into solving/ (statement, starter,
driver.h and the examples as tests), commits it as "Start <slug>" and
opens its solve page. A daily question already in the repo is only
opened. The importer stays the CLI's one script rather than a Go copy
of its driver generator, so the site image now has python3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-20 11:29:39 +01:00
co-authored by Claude Opus 5.5
parent c972fa9fd9
commit af070ffcf9
9 changed files with 337 additions and 2 deletions
+24 -1
View File
@@ -7,7 +7,7 @@
*/
import { computed, onMounted, ref } from "vue";
import { RouterLink, useRoute, useRouter } from "vue-router";
import { listProblems } from "@/api";
import { listProblems, startDaily } from "@/api";
import { LANG_LABELS, STATUS_LABELS, formatDate, title } from "@/format";
const route = useRoute();
@@ -18,6 +18,22 @@ const admin = ref(false);
const loading = ref(true);
const error = ref("");
// "Today's LeetCode" imports the daily question as `usaco daily` would and
// opens it on the solve page; one already in the repo is just opened.
const starting = ref(false);
const dailyError = ref("");
async function openDaily() {
starting.value = true;
dailyError.value = "";
try {
const { name } = await startDaily();
router.push({ name: "solve", params: { name } });
} catch (e) {
dailyError.value = e.message;
starting.value = false;
}
}
const status = computed({
get: () => route.query.status || "all",
set: (v) => router.replace({ query: { ...route.query, status: v === "all" ? undefined : v } }),
@@ -110,7 +126,11 @@ const groups = computed(() => {
<option value="recent">Most recent</option>
<option value="name">Name</option>
</select>
<button v-if="admin" class="btn primary" :disabled="starting" @click="openDaily">
{{ starting ? "Fetching today's problem…" : "Today's LeetCode" }}
</button>
</div>
<p v-if="dailyError" class="error daily-error">{{ dailyError }}</p>
<p v-if="loading" class="muted">Loading…</p>
<p v-else-if="error" class="error">{{ error }}</p>
@@ -151,6 +171,9 @@ const groups = computed(() => {
.intro {
margin-bottom: 16px;
}
.daily-error {
margin: -8px 0 16px;
}
.controls {
display: flex;
flex-wrap: wrap;