[api] store the last number from lastevents in the database

It is pretty much overkill to have a table for a single value,
but it might get useful in the future and the alternative is writing
a file and it feels so unrailsy
[api] remove obsolete wrapper script
[api] scan linkinfos from backend and store them (as copy) in DB