this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

day 2, lexicon changes

+66 -15
+11 -4
shared/challenges_markdown/two/part_two.md
··· 8 8 - [com.atproto.repo.applyWrites](https://docs.bsky.app/docs/api/com-atproto-repo-apply-writes) Batch endpoint for writes 9 9 that allows you to create, update, or delete multiple records. 10 10 11 - Great job beating Part 1! Now onto Part 2. 11 + Like the previous record you found at `{{at_uri}}`, you will write your own `codes.advent.challenge.day` record in your 12 + own repository at the record key `2` and set the property `partTwo` to `{{code}}`. 12 13 13 - Keeping it simple proof of concept, blah, blah will have a real one here another time. Add a new field `partTwo` to the 14 - record with the value `{{code}}` 14 + The contents of the record would look about like this: 15 + 16 + ```json 17 + { 18 + "$type": "codes.advent.challenge.day", 19 + "partTwo": "<your code>" 20 + } 21 + ``` 15 22 23 + Once you have written the record to your own repository, please click "Check answer" below to see if you got it right. 16 24 17 - [//]: # (<input type="file" id="part_one_input" placeholder="Enter your code here" />)
-3
shared/lexicons/codes/advent/day.json
··· 7 7 "key": "any", 8 8 "record": { 9 9 "type": "object", 10 - "required": [ 11 - "partOne" 12 - ], 13 10 "properties": { 14 11 "partOne": { 15 12 "type": "string"
+2 -6
shared/src/advent/challenges/day_two.rs
··· 33 33 true 34 34 } 35 35 36 - fn requires_manual_verification_part_two(&self) -> bool { 37 - true 38 - } 39 - 40 36 /// Create a record via the challenge agent and return the at_uri as additional context 41 37 async fn build_additional_context( 42 38 &self, ··· 58 54 })?; 59 55 60 56 let record_data = advent::challenge::day::RecordData { 61 - part_one: code.to_string(), 57 + part_one: Some(code.to_string()), 62 58 part_two: None, 63 59 created_at: None, 64 60 }; ··· 192 188 false => { 193 189 Ok(ChallengeCheckResponse::Incorrect(format!( 194 190 "The code {} is incorrect", 195 - record_data.part_one 191 + record_data.part_one.unwrap_or("".to_string()) 196 192 ))) 197 193 } 198 194 }
+2 -1
shared/src/lexicons/codes/advent/challenge/day.rs
··· 6 6 pub struct RecordData { 7 7 #[serde(skip_serializing_if = "core::option::Option::is_none")] 8 8 pub created_at: core::option::Option<atrium_api::types::string::Datetime>, 9 - pub part_one: String, 9 + #[serde(skip_serializing_if = "core::option::Option::is_none")] 10 + pub part_one: core::option::Option<String>, 10 11 #[serde(skip_serializing_if = "core::option::Option::is_none")] 11 12 pub part_two: core::option::Option<String>, 12 13 }
+3
shared/src/lexicons/lib.rs
··· 1 + // @generated - This file is generated by esquema-codegen (forked from atrium-codegen). DO NOT EDIT. 2 + pub mod record; 3 + pub mod codes;
+48 -1
web/src/main.rs
··· 294 294 Ok(()) 295 295 } 296 296 297 - /// Landing page showing currently unlocked days and a login button 297 + /// The default handler that will be used during the advent month, but not during amtosphere conf 298 298 async fn home_handler(State(pool): State<PgPool>, session: AxumSessionStore) -> impl IntoResponse { 299 299 //TODO make a helper function for this since it is similar to the middleware 300 300 let now = chrono::Utc::now(); ··· 337 337 is_logged_in, 338 338 }) 339 339 } 340 + 341 + /// The default handler that will be used during the advent month, but not during amtosphere conf 342 + async fn dec_home_handler( 343 + State(pool): State<PgPool>, 344 + session: AxumSessionStore, 345 + ) -> impl IntoResponse { 346 + //TODO make a helper function for this since it is similar to the middleware 347 + let now = chrono::Utc::now(); 348 + let mut unlocked: Vec<u8> = Vec::new(); 349 + 350 + //HACK Yeah I don't like it either - bt 351 + let prod: bool = env::var("PROD") 352 + .map(|val| val == "true") 353 + .unwrap_or_else(|_| true); 354 + if prod { 355 + if now.month() == 12 { 356 + let today = now.day().min(25); 357 + for d in 1..=today { 358 + unlocked.push(d as u8); 359 + } 360 + } 361 + } else { 362 + for d in 1..=25 { 363 + unlocked.push(d as u8); 364 + } 365 + } 366 + 367 + // Get completion status for all days at once 368 + let did = session.get_did(); 369 + let is_logged_in = session.logged_in(); 370 + let all_statuses = get_all_days_completion_status(&pool, did.as_ref()) 371 + .await 372 + .unwrap_or_else(|_| (1..=25).map(|day| (day, CompletionStatus::None)).collect()); 373 + 374 + // Filter to only include unlocked days 375 + let unlocked_with_status: Vec<DayStatus> = all_statuses 376 + .into_iter() 377 + .filter(|(day, _)| unlocked.contains(day)) 378 + .map(|(day, status)| DayStatus { day, status }) 379 + .collect(); 380 + 381 + HtmlTemplate(HomeTemplate { 382 + title: "at://advent", 383 + unlocked_days: unlocked_with_status, 384 + is_logged_in, 385 + }) 386 + }