Question

I am stuck on how I should architect this process.

I have 100 clients, which all need a PDF report at any given day. They should be able to download individual reports at any time, but the reports would only be up to date as of midnight the previous night (I have a rake task that runs at midnight each day, which updates the database with current information).

I also need to be able to download all 100 reports for myself, in bulk, on any given day.

What's the best way to write this? I thought about writing a rake task to create 100 PDF's and store them in my app's directory, then just redirecting to that file and running that task each night. That just doesn't seem very efficient, and I could run into issues if I decide to run multiple servers and they can't find the files...

Any thoughts?

Était-ce utile?

La solution

Depending on the size of the PDF's and what database you're using, it might make sense to store them in your database, or perhaps use something like MongoDB or another document-oriented NoSQL database just for this. But any regular database that has a BLOB type would work.

Then your rake task can update them each night, they can be served to clients straight out of the database, even if you wind up running multiple servers. You could also include some metadata in the db with the reports, especially the last time the underlying data was updated and the last time the report was generated.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top