Skip to content

Instantly share code, notes, and snippets.

@berkes
Created September 8, 2013 12:02
Show Gist options
  • Save berkes/6484228 to your computer and use it in GitHub Desktop.
Save berkes/6484228 to your computer and use it in GitHub Desktop.
Quick-n-dirty import of hamster time tracking (https://projecthamster.wordpress.com) into timetrap (https://github.com/samg/timetrap).
require "sqlite3"
hamster = SQLite3::Database.new ".local/share/hamster-applet/hamster.db"
timetrap = SQLite3::Database.new ".timetrap.db"
unparsed = hamster.execute("select * from facts inner join activities on activities.id = facts.activity_id inner join categories on categories.id = activities.category_id")
entries = unparsed.map do |e|
timetrap.execute("insert into entries (note, start, end, sheet) values (?, ?, ?, ?)",
"#{e[6]} #{e[4]}",
e[2],
e[3]||e[2], #avoid errors turning into running time-entries
e[13]||"no-sheet")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment