Yuvipanda has uploaded a new change for review.
https://gerrit.wikimedia.org/r/182801
Change subject: Make table columns dicts instead of lists
......................................................................
Make table columns dicts instead of lists
Makes it easier to find a column by name.
Change-Id: I5c6527d0c756ee931f2a058aa9f80d4abdceb98c
---
M auditor/models.py
1 file changed, 4 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/software/labsdb-auditor
refs/changes/01/182801/1
diff --git a/auditor/models.py b/auditor/models.py
index cd467c5..96cda7b 100644
--- a/auditor/models.py
+++ b/auditor/models.py
@@ -43,14 +43,14 @@
class Table(object):
- def __init__(self, name, columns=[], where=None, table_name=None):
+ def __init__(self, name, columns={}, where=None, table_name=None):
self.name = name
self.columns = columns
self.where = where
self.table_name = table_name if table_name else name
def add_column(self, column):
- self.columns.append(column)
+ self.columns[column.name] = column
column.table = self
def to_dict(self):
@@ -60,12 +60,12 @@
tabledict = {}
if self.where:
tabledict['where'] = self.where
- if all([c.whitelisted for c in self.columns]):
+ if all([c.whitelisted for c in self.columns.values()]):
# Everything is whitelisted!
tabledict['columns'] = [c.name for c in self.columns]
else:
tabledict['columns'] = {}
- for c in self.columns:
+ for c in self.columns.items():
columndict = {}
columndict['whitelisted'] = c.whitelisted
if c.condition:
--
To view, visit https://gerrit.wikimedia.org/r/182801
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5c6527d0c756ee931f2a058aa9f80d4abdceb98c
Gerrit-PatchSet: 1
Gerrit-Project: operations/software/labsdb-auditor
Gerrit-Branch: master
Gerrit-Owner: Yuvipanda <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits