Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unused Config table from the database #927

Merged
merged 1 commit into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 getSkipPaths(self, run_id):
self.__require_access()
Expand Down Expand Up @@ -1755,31 +1725,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