Skip to content

Commit

Permalink
Feature/update gDrive server Id and report Id (#177)
Browse files Browse the repository at this point in the history
* Update GDrive ServerId

* Update GDrive ReportId

* Update GDrive ReportId

* Update GDrive ReportId
  • Loading branch information
dhekra-rouatbi authored Aug 29, 2024
1 parent 46eee6f commit 9427506
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions Tella/Data/Database/GDriveDatabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extension TellaDataBase {

func createGDriveServerTable() {
let columns = [
cddl(D.cId, D.integer, primaryKey: true, autoIncrement: true),
cddl(D.cServerId, D.integer, primaryKey: true, autoIncrement: true),
cddl(D.cName, D.text),
cddl(D.cRootFolder, D.text),
cddl(D.cRootFolderName, D.text)
Expand Down Expand Up @@ -50,7 +50,7 @@ extension TellaDataBase {
func deleteGDriveServer(serverId: Int) {
do {
try statementBuilder.delete(tableName: D.tGDriveServer,
primarykeyValue: [KeyValue(key: D.cId, value: serverId)])
primarykeyValue: [KeyValue(key: D.cServerId, value: serverId)])
try statementBuilder.deleteAll(tableNames: [D.tGDriveReport, D.tGDriveInstanceVaultFile])
} catch let error {
debugLog(error)
Expand All @@ -63,7 +63,7 @@ extension TellaDataBase {
extension TellaDataBase {
func createGDriveReportTable() {
let columns = [
cddl(D.cId, D.integer, primaryKey: true, autoIncrement: true),
cddl(D.cReportId, D.integer, primaryKey: true, autoIncrement: true),
cddl(D.cTitle, D.text),
cddl(D.cDescription, D.text),
cddl(D.cCreatedDate, D.float),
Expand All @@ -84,7 +84,7 @@ extension TellaDataBase {
cddl(D.cBytesSent, D.integer),
cddl(D.cCreatedDate, D.float),
cddl(D.cUpdatedDate, D.float),
cddl(D.cReportInstanceId, D.integer, tableName: D.tGDriveReport, referenceKey: D.cId)
cddl(D.cReportInstanceId, D.integer, tableName: D.tGDriveReport, referenceKey: D.cReportId)

]
statementBuilder.createTable(tableName: D.tGDriveInstanceVaultFile, columns: columns)
Expand Down Expand Up @@ -118,7 +118,7 @@ extension TellaDataBase {

let reportDict = report.dictionary
let valuesToUpdate = reportDict.compactMap({ KeyValue(key: $0.key, value: $0.value) })
let reportCondition = [KeyValue(key: D.cId, value: report.id)]
let reportCondition = [KeyValue(key: D.cReportId, value: report.id)]

try statementBuilder.update(
tableName: D.tGDriveReport,
Expand Down Expand Up @@ -177,7 +177,7 @@ extension TellaDataBase {

func getGDriveReport(id: Int) -> GDriveReport? {
do{
let reportsCondition = [KeyValue(key: D.cId, value: id)]
let reportsCondition = [KeyValue(key: D.cReportId, value: id)]
let gDriveReportsDict = try statementBuilder.getSelectQuery(tableName: D.tGDriveReport,
equalCondition: reportsCondition
)
Expand Down Expand Up @@ -219,7 +219,7 @@ extension TellaDataBase {

func deleteDriveReport(reportId: Int?) -> Result<Bool, Error> {
do {
let reportCondition = [KeyValue(key: D.cId, value: reportId)]
let reportCondition = [KeyValue(key: D.cReportId, value: reportId)]

try statementBuilder.delete(tableName: D.tGDriveReport, primarykeyValue: reportCondition)

Expand All @@ -245,7 +245,7 @@ extension TellaDataBase {
KeyValue(key: D.cUpdatedDate, value: Date().getDateDouble())
]

let reportCondition = [KeyValue(key: D.cId, value: idReport)]
let reportCondition = [KeyValue(key: D.cReportId, value: idReport)]

try statementBuilder.update(tableName: D.tGDriveReport, valuesToUpdate: valuesToUpdate, equalCondition: reportCondition)

Expand All @@ -261,7 +261,7 @@ extension TellaDataBase {
let valuesToUpdate = [KeyValue(key: D.cFolderId, value: folderId),
KeyValue(key: D.cUpdatedDate, value: Date().getDateDouble())
]
let reportCondition = [KeyValue(key: D.cId, value: idReport)]
let reportCondition = [KeyValue(key: D.cReportId, value: idReport)]

try statementBuilder.update(tableName: D.tGDriveReport, valuesToUpdate: valuesToUpdate, equalCondition: reportCondition)

Expand Down
2 changes: 1 addition & 1 deletion Tella/Domain/Entity/CommonReport/BaseReport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class BaseReport : Hashable, Codable {
var serverId: Int?

enum CodingKeys: String, CodingKey {
case id = "c_id"
case id = "c_report_id"
case title = "c_title"
case description = "c_description"
case createdDate = "c_created_date"
Expand Down
2 changes: 1 addition & 1 deletion Tella/Domain/Entity/CommonServer/Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Server: Codable, Equatable, Hashable {
var allowMultiple: Bool?

enum CodingKeys: String, CodingKey {
case id = "c_id"
case id = "c_server_id"
case name = "c_name"
}

Expand Down

0 comments on commit 9427506

Please sign in to comment.