aboutsummaryrefslogtreecommitdiff
path: root/lib/d2/app/adapters/plot.py
blob: 451f215418d62bf0065f36ce741719f08c48c71b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from d2.app.model.static import StaticData
from d2.app.adapters import BaseAdapter
from d2.config import Config
from d2.db import Plot 

class PlotAdapter(BaseAdapter):

    def __init__(self, db, log, static, plot):
        self._db = db
        self._log = log
        self._static = static
        self._plot = plot 

    @classmethod
    def load(cls, config=None, static=None):
        config = config or Config.load()
        static = static or StaticData.load(config.db)()
        return cls(config.db, config.log, static, Plot)

    def get_all(self, plot_ids):
        return self._db.session.query(self._plot).filter(
               self._plot.id.in_(plot_ids)).all()