Coder Social home page Coder Social logo

rster2002 / ed-journals Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 4.0 132.78 MB

Work in progress journal parsing and utilities for Elite Dangerous written in Rust.

Home Page: https://crates.io/crates/ed-journals

License: MIT License

Rust 96.98% JavaScript 3.02%
elite-dangerous elite-journal rust-lang

ed-journals's People

Contributors

batshalregmi avatar rster2002 avatar somfic avatar technologicalmayhem avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

ed-journals's Issues

Extend events from journal reader

Extend the JournalEvent to include additional information about the read, most importantly whether it's a 'live' read or it's a history read, which can be used to for example only flush state when reading live entries.

Ergonomy: less deeply nested modules

Hey, I've just started a small project where I need to watch screenshots events, and I'm glad ed-journals exists, thanks! Everything is working as expected in my experience, I just want to bring some API suggestions (I can give a shot to implement them, if you think they are appropriate).

I see that there are already some "module shortcuts" that exist, but I think it could be brought into a way flatter structure, leading to a more discoverable API. For instance, the screenshot event content is under: ed_journals::logs::content::log_event_content::screenshot_event::ScreenshotEvent

From the most obvious, to the most contentious, my suggestions would be:

  • screenshot_event and its friends are single struct modules, maybe invert visibility between struct and mods in log_event_content.rs
  • content only contains LogEvent and LogEventContent, I'd expose the whole content of log_event_content into content, so that LogEventContent and the struct it contains are together
  • Probably more contentious, but I'd suggest to even skip the whole content module which would mean that everything you need when watching the logs would be directly under ed_journals::logs, except for the two blocking and asynchronous modules that totally make sense to choose the reading method

I like this comment on this topic: "users of a module prefer a flat namespace, while implementers prefer hierarchical namespace"

Optimize species spawn conditions.

Currently it's quite inefficient to check which species matches criteria as it means allocating a Vec for every single species that exists and going though them one by one. A possible solutions could be something like this:

lazy_static! {
    static ref SPECIES_SPAWN_CONDITIONS: [(Species, Vec<SpawnCondition>); 100] = [
        (Species::AleoidaArcus, vec![
            SpawnCondition::ThinAtmosphere(AtmosphereType::CarbonDioxide),
            SpawnCondition::MaxGravity(0.27),
            SpawnCondition::MinMeanTemperature(175.0),
            SpawnCondition::MaxMeanTemperature(180.0),
        ]),
        // etc...
    ];
}

Which would just allocate everything once when it is first required and then keeps it allocated. This sacrifices memory usage for speed, but I think that it would be worth it.

Then to find matches you can just iterate over SPECIES_SPAWN_CONDITIONS and note down the species for the matches.

Verify species entries

Some species entries are not yet backed by any tests and they need some journal entries to make sure they are correctly mapped.

Look into optimising the way journal test files are stored

A brain dump of some options:

  • Maybe use a self-hosted runner to perform the tests and keep the files there so to minimise the number of journal files in the repo. This would however make it harder to debug failing tests locally.
  • Only include the journal files from new PR's that make the tests fail. Not really a fan of this as that would only look at the current tests and doesn't take into account any future test cases.

Move shared models out of `models` and into separate modules

The specific models is something that is left over from the start of the project when there was only the logs module. Instead, split the models into their own modules, so that things like ship type can be accessed through ed_journals::ship::{ShipType, ShipModule}; etc.

Fix capitalization for some entries

Planet class entries should be fixed and should get annotations for prevent from changing it again:

  • SudarskyClassIGasGiant
  • SudarskyClassIiGasGiant
  • SudarskyClassIiiGasGiant
  • SudarskyClassIvGasGiant
  • SudarskyClassVGasGiant

Refactor mission type enum

The mission type enum is currently a bit of a mess and not really that useful. Some work needs to be put into figuring out the logic of the format/name.

Keybindings

Hi!

Would you consider parsing the keybindings within the scope of this project? If so, I could give it a go in a PR?

State needs to be a lot smarter

The current implementation is just too slow. This is probably because it creates a lot of independent allocations which just cause a lot of overhead.

Currently it mutates a lot of state which allows us to create a single state, but means that a lot of data is cloned and lots of allocations need to happen.

One idea that was initially considered is just adding every entry that was read to a single vec and perform operations on that, but that would mean that you would need to iterate over most if not all items if you want to perform some lookup or action.

Maybe a hybrid method would work where everything is added to a single vec, but state is kept through references to the vec? This would require a lot of references and probably some unsafe code.

Blocking readers: channel-like API?

When working without an async runtime it can be a bit awkward to manage the blocking calls of the live readers. I think that the standard library channel Receiver do it really well:

  • .iter() provides the blocking API, exactly like the current live readers
  • .try_iter() provides an iterator that is non blocking and ends as soon as there is no more events

And the great thing is that you can use both as needed. As a result, this creates easy constructions to do things like watching just new events:

let _ = receiver.try_iter().last(); // flush the events that were sent before
for ev in receiver.iter() { /* do stuff with new events */}

They also provide the method recv_timeout() which is super helpful.

Anomalous event line

In journal Journal.2023-07-30T033612.01.log there's a line that is incorrectly formatted. Tracking an issue here for if this occurs multiple times.

{ "timestamp":"2023-07-30T01:54:58Z", "event":"| Scooping: {Status.Scooping}");", "Taxi":false, "Multicrew":false, "StarSystem":"HIP 84222", "SystemAddress":74325165260, "StarPos":[38.78125,46.62500,534.78125], "SystemAllegiance":"", "SystemEconomy":"$economy_None;", "SystemEconomy_Localised":"None", "SystemSecondEconomy":"$economy_None;", "SystemSecondEconomy_Localised":"None", "SystemGovernment":"$government_None;", "SystemGovernment_Localised":"None", "SystemSecurity":"$GAlAXY_MAP_INFO_state_anarchy;", "SystemSecurity_Localised":"Anarchy", "Population":0, "Body":"HIP 84222", "BodyID":0, "BodyType":"Star", "JumpDist":62.928, "FuelUsed":7.674855, "FuelLevel":21.480677 }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.