aboutsummaryrefslogtreecommitdiff
path: root/lib/d2/app/adapters/plot.py
blob: ec6075d9da45509f7b9504466441688308825dad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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()


    def get_all_from_forges(self, forges):
        hold = [forge.plot_id for forge in forges]
        return self.get_all(hold)