GithubHelp home page GithubHelp logo

Comments (3)

jcsrb avatar jcsrb commented on June 25, 2024 1

here is a helpful snippet, implementation of remove_version works on the json and depends on the exact thing one tries to achieve

subject.with_lock do
  raw_history = subject.read_attribute_before_type_cast(:log_data)

  altered_history = remove_version raw_history, version
  Logidze.without_logging do
    subject.update_column(:log_data, altered_history)
  end
end

from logidze.

palkan avatar palkan commented on June 25, 2024

Is this something that would make sense to added to the gem?

Yep, I think that could be useful. Something like record.remove_log_version(version_number).

Are there any obvious issues with my approach?

Depends on the implementation. I suggest adding a DB-side function/procedure and call it to avoid race conditions, e.g.:

update my_table set log_data = logidze_remove_version(log_data, version_number) where id = 1

from logidze.

palkan avatar palkan commented on June 25, 2024

Closing this for now.
Removing the version from the log is not straightforward as it might seem: we need to care about the log consistency, thus removing a version is closer to compaction, since we need to merge the diff from the removed version with the previous one (or the next one?).

Probably, doing such tasks manually (i.e., in Ruby, smth like Mode.find_each { |item| LogCleaner.call(item) }) is a better way.

from logidze.

Related Issues (20)

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.