azure_cdn: use subgroups, attempt 3
This commit is contained in:
parent
95a39f759a
commit
7eb2eaf36f
1 changed files with 4 additions and 2 deletions
|
@ -1,6 +1,8 @@
|
|||
import datetime
|
||||
from collections import defaultdict
|
||||
|
||||
from sqlalchemy import text
|
||||
|
||||
from app import app
|
||||
from app.extensions import db
|
||||
from app.models.base import Group
|
||||
|
@ -11,13 +13,13 @@ from app.terraform import BaseAutomation
|
|||
class ProxyAutomation(BaseAutomation):
|
||||
def get_subgroups(self):
|
||||
conn = db.engine.connect()
|
||||
result = conn.execute("""
|
||||
result = conn.execute(text("""
|
||||
SELECT origin.group_id, proxy.psg, COUNT(proxy.id) FROM proxy, origin
|
||||
WHERE proxy.origin_id = origin.id
|
||||
AND proxy.destroyed IS NULL
|
||||
AND proxy.provider = :provider
|
||||
GROUP BY origin.group_id, proxy.psg;
|
||||
""", provider=self.provider)
|
||||
"""), provider=self.provider)
|
||||
subgroups = defaultdict(lambda: defaultdict(lambda: 0))
|
||||
for row in result:
|
||||
subgroups[row[0]][row[1]] = row[2]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue