this repo has no description

moved the jokes to a shared area

+35 -22
+6 -22
shared/src/advent/challenges/day_three/repo.rs
··· 1 1 use std::io::Cursor; 2 2 3 + use crate::advent::get_a_joke; 3 4 use atrium_api::types::string::{Nsid, RecordKey}; 4 5 use atrium_crypto::keypair::P256Keypair; 5 - use atrium_repo::{Repository, blockstore::{CarStore, MemoryBlockStore}}; 6 - use rand::seq::IndexedRandom; 6 + use atrium_repo::{ 7 + Repository, 8 + blockstore::{CarStore, MemoryBlockStore}, 9 + }; 7 10 use serde::Serialize; 8 11 9 12 const CHALLENGE_DID: &str = "did:plc:3oktyyf7u4ecnvdwf3ogehpd"; 10 - 11 - const VERY_BAD_JOKE_SETUPS: &[&str] = &[ 12 - "what do you call a cow with two legs?", 13 - "what do bees do if they need a ride?", 14 - "what do you call a monkey that loves doritos?", 15 - "why did the can crusher quit her job?", 16 - "when’s the best time to go to the dentist?", 17 - "why do seagulls fly over the sea?", 18 - "what do you call a farm that makes bad jokes?", 19 - "why do fish live in saltwater?", 20 - "what kind of streets do ghosts haunt?", 21 - "what do you call it when one cow spies on another?", 22 - "what happens when a frog’s car breaks down?", 23 - "what does a zombie vegetarian eat?", 24 - "what do you call it when a snowman throws a tantrum?", 25 - "why did the scarecrow win an award?", 26 - "what did the buffalo say when his son left?", 27 - "wait, you don’t want to hear a joke about potassium?", 28 - ]; 29 13 30 14 #[derive(Debug, thiserror::Error)] 31 15 pub enum CarBuildError { ··· 66 50 // add record 67 51 let key = format!("{}/{}", collection.as_str(), rkey.as_str()); 68 52 let created_at = &chrono::Utc::now().to_rfc3339(); 69 - let joke = VERY_BAD_JOKE_SETUPS.choose(&mut rand::rng()).unwrap_or(&"no joke"); 53 + let joke = get_a_joke(); 70 54 let record = ChallengeRecord { 71 55 created_at, 72 56 verification_code,
+29
shared/src/advent/mod.rs
··· 8 8 use handlebars::{Handlebars, RenderError}; 9 9 use markdown::{CompileOptions, Options}; 10 10 use rand::distr::{Alphanumeric, SampleString}; 11 + use rand::seq::IndexedRandom; 11 12 use rust_embed::EmbeddedFile; 12 13 use serde_json::json; 13 14 use sqlx::PgPool; ··· 438 439 439 440 Ok(result) 440 441 } 442 + 443 + const VERY_BAD_JOKE_SETUPS: &[&str] = &[ 444 + "what do you call a cow with two legs?", 445 + "what do bees do if they need a ride?", 446 + "what do you call a monkey that loves doritos?", 447 + "why did the can crusher quit her job?", 448 + "when’s the best time to go to the dentist?", 449 + "why do seagulls fly over the sea?", 450 + "what do you call a farm that makes bad jokes?", 451 + "why do fish live in saltwater?", 452 + "what kind of streets do ghosts haunt?", 453 + "what do you call it when one cow spies on another?", 454 + "what happens when a frog’s car breaks down?", 455 + "what does a zombie vegetarian eat?", 456 + "what do you call it when a snowman throws a tantrum?", 457 + "why did the scarecrow win an award?", 458 + "what did the buffalo say when his son left?", 459 + "wait, you don’t want to hear a joke about potassium?", 460 + "how do you organize a space party?", 461 + "what did one casket say to the other casket?", 462 + ]; 463 + 464 + /// Gets a random joke from the VERY_BAD_JOKE_SETUPS array 465 + pub fn get_a_joke() -> &'static str { 466 + VERY_BAD_JOKE_SETUPS 467 + .choose(&mut rand::rng()) 468 + .unwrap_or(&"no joke") 469 + }