Skip to content

Commit

Permalink
Merge pull request #927 from gyorb/remove_config_from_db
Browse files Browse the repository at this point in the history
remove unused Config table from the database
  • Loading branch information
whisperity authored Sep 14, 2017
2 parents 82b45a4 + 0cc76ac commit 281f272
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 100 deletions.
7 changes: 0 additions & 7 deletions api/shared.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ struct SuppressBugData {
}
typedef list<SuppressBugData> SuppressBugList

struct ConfigValue {
1: string checkerName,
2: string attribute,
3: string value
}
typedef list<ConfigValue> CheckerConfigList

enum Severity{
UNSPECIFIED = 0,
STYLE = 10,
Expand Down
11 changes: 0 additions & 11 deletions api/v6/report_server.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,6 @@ service codeCheckerDBAccess {
string getCheckerDoc(1: string checkerId)
throws (1: shared.RequestFailed requestError),

// get the checker configuration values
// PERMISSION: PRODUCT_ACCESS or PRODUCT_STORE
shared.CheckerConfigList getCheckerConfigs(1: i64 runId)
throws (1: shared.RequestFailed requestError),

// get the skip list of paths
// PERMISSION: PRODUCT_ACCESS
SkipPathDataList getSkipPaths(1: i64 runId)
Expand Down Expand Up @@ -374,10 +369,4 @@ service codeCheckerDBAccess {
4: bool force)
throws (1: shared.RequestFailed requestError),

// PERMISSION: PRODUCT_STORE
bool replaceConfigInfo(
1: i64 runId,
2: shared.CheckerConfigList values)
throws (1: shared.RequestFailed requestError),

}
4 changes: 0 additions & 4 deletions libcodechecker/libclient/thrift_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,3 @@ def getMissingContentHashes(self, file_hashes):
@ThriftClientCall
def massStoreRun(self, name, version, zipdir, force):
pass

@ThriftClientCall
def replaceConfigInfo(self, run_id, values):
pass
58 changes: 0 additions & 58 deletions libcodechecker/server/client_db_access_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,36 +1066,6 @@ def getCheckerDoc(self, checkerId):
raise shared.ttypes.RequestFailed(shared.ttypes.ErrorCode.IOERROR,
msg)

def getCheckerConfigs(self, run_id):
"""
Parameters:
- run_id
"""
self.__require_permission([permissions.PRODUCT_ACCESS,
permissions.PRODUCT_STORE])
try:
session = self.__Session()

configs = session.query(Config) \
.filter(Config.run_id == run_id) \
.all()

configs = [(c.checker_name, c.attribute, c.value)
for c in configs]
res = []
for cName, attribute, value in configs:
res.append(shared.ttypes.ConfigValue(cName, attribute, value))

return res

except sqlalchemy.exc.SQLAlchemyError as alchemy_ex:
msg = str(alchemy_ex)
LOG.error(msg)
raise shared.ttypes.RequestFailed(shared.ttypes.ErrorCode.DATABASE,
msg)
finally:
session.close()

@timeit
def getSourceFileData(self, fileId, fileContent, encoding):
"""
Expand Down Expand Up @@ -1720,31 +1690,3 @@ def massStoreRun(self, name, version, b64zip, force):
shutil.rmtree(zip_dir)

return run_id

@timeit
def replaceConfigInfo(self, run_id, config_values):
"""
Removes all the previously stored config information and stores the
new values.
"""
self.__require_store()
try:
session = self.__Session()
LOG.debug("Replacing config info")
count = session.query(Config) \
.filter(Config.run_id == run_id) \
.delete()
LOG.debug('Config: ' + str(count) + ' removed item.')

configs = [Config(
run_id, info.checker_name, info.attribute, info.value) for
info in config_values]
session.bulk_save_objects(configs)
session.commit()
return True

except Exception as ex:
LOG.error(ex)
return False
finally:
session.close()
20 changes: 0 additions & 20 deletions libcodechecker/server/run_db_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ class Run(Base):
can_delete = Column(Boolean, nullable=False, server_default=true(),
default=True)

# Relationships (One to Many).
configlist = relationship('Config', cascade="all, delete-orphan",
passive_deletes=True)

def __init__(self, name, version, command):
self.date, self.name, self.version, self.command = \
datetime.now(), name, version, command
Expand All @@ -70,22 +66,6 @@ def mark_finished(self):
self.duration = ceil((datetime.now() - self.date).total_seconds())


class Config(Base):
__tablename__ = 'configs'

run_id = Column(Integer,
ForeignKey('runs.id', deferrable=True,
initially="DEFERRED", ondelete='CASCADE'),
primary_key=True)
checker_name = Column(String, primary_key=True)
attribute = Column(String, primary_key=True)
value = Column(String, primary_key=True)

def __init__(self, run_id, checker_name, attribute, value):
self.attribute, self.value = attribute, value
self.checker_name, self.run_id = checker_name, run_id


class FileContent(Base):
__tablename__ = 'file_contents'

Expand Down

0 comments on commit 281f272

Please sign in to comment.