Skip to content

Conversation

@holoujak
Copy link
Owner

@holoujak holoujak commented Oct 9, 2025

No description provided.

}

pub fn map_start_number_to_track_rank(&mut self) {
let tracks = self.tracks.clone();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need clone?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunatelly yes - otherwise I need to somehow specify the self.tracks is immutable in calculate_track_rank function

@holoujak holoujak force-pushed the track-rank branch 4 times, most recently from 9dad819 to a487ff4 Compare October 9, 2025 17:48
@holoujak holoujak marked this pull request as ready for review October 9, 2025 17:50
@holoujak holoujak requested a review from trnila October 9, 2025 17:50
@holoujak holoujak marked this pull request as draft October 9, 2025 18:08
@holoujak holoujak marked this pull request as draft October 9, 2025 18:08
@holoujak
Copy link
Owner Author

holoujak commented Oct 9, 2025

However I'm still not satisfied how the rank is displayed. I will most probably separate the result list from the registration lists. With info like start number, time, track rank and category rank.

@holoujak holoujak marked this pull request as ready for review October 9, 2025 19:46
@holoujak
Copy link
Owner Author

holoujak commented Oct 9, 2025

Ok, lets have it in one table for now. :)

pub racers: Vec<Racer>,
pub categories: Vec<String>,
pub tracks: Vec<String>,
pub tracks_rank: HashMap<String, HashMap<u32, u32>>, // track -> (start_number -> rank)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of comments we should do proper datatypes to ensure type-safety

struct Track(String);

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but in that case also tracks attribute shall be changed to tracks: Vec and that type shall be defined.

src/race.rs Outdated
racers,
categories: categories.into_iter().collect(),
tracks,
tracks_rank: HashMap::new(), // tracks_rank initialized as empty
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does comment add something more then HashMap::new()?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about having Track type and assigning ranks there? We will get rid of HashMap

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How you mean that? Simply have new type Track which will have attribute rank, which shall be hashmap I guess, since I need to map start_number to rank.

src/race.rs Outdated
let racer = self
.racers
.iter_mut()
.find(|r| r.tag == tag && r.start.is_some());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add r.finished.is_none() as well? ... but we should have some initial timeout if racers starts with enabled rfids

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added - timer, could be, but not necessary right now since start/finish are on different place :)

td {
"{race.tracks_rank.get(&racer.track)
.and_then(|m| m.get(&racer.start_number))
.map_or(String::new(), |rank| rank.to_string())}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map_or_else is better as it doesnt allocate String::new()

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used map and then unwrap_or_default instead

@holoujak holoujak merged commit f980fe5 into master Oct 11, 2025
2 checks passed
@holoujak holoujak deleted the track-rank branch October 11, 2025 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants