-
Notifications
You must be signed in to change notification settings - Fork 2
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 invalid data #75
base: next
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,16 +7,73 @@ $(function() { | |
airline = AES.getAirlineCode(); | ||
server = AES.getServerName(); | ||
chrome.storage.local.get(['settings'], function(result) { | ||
settings = result.settings; | ||
settings = result.settings; | ||
|
||
displayDashboard(); | ||
if ((settings['flightInformationsFixed'] === undefined) || (settings['flightInformationsFixed'] !== 1)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought it might be nice to base this on version number. Perhaps we could do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of course you can do that, but i don't know when exactly the version number changes. So i used this simple "versioning" 1,2,3 in case further fixes are necessary and people already using this need to rerun this. |
||
fixAndDeleteInvalidData(); | ||
} | ||
|
||
displayDashboard(); | ||
dashboardHandle(); | ||
|
||
$("#aes-select-dashboard-main").change(function() { | ||
dashboardHandle(); | ||
$("#aes-select-dashboard-main").change(function() { | ||
dashboardHandle(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
function fixAndDeleteInvalidData() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please adjust the indent size to .editorconfig spec? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, had this set to two because the whole AES code was/is 2 spaces. |
||
chrome.storage.local.get(null, function (entries) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be nice to get the data into a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes maybe, it was just good good enough for temporary use. Do you want to change it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like you to change it, yes. |
||
const tasks = []; | ||
|
||
function cleanAndSave(entry, key) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason this function is nested? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It has access to entries then and functionallity belonged to fixAndDeleteInvalidData, nothing special. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should write code as if it were permanent. Improving the code base is a long term project :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, i think this is a code style question. Just rewrite it according to your wishes. :) |
||
return new Promise((resolve, reject) => { | ||
if (key.endsWith("routeAnalysis") || key.endsWith("schedule")) { | ||
if (entry.date) { | ||
for (const dateKey in entry.date) { | ||
if (!dateKey.startsWith("20") || dateKey.length !== 8) { | ||
delete entry.date[dateKey]; | ||
} | ||
} | ||
} | ||
} else if (key.endsWith("aircraftFleet")) { | ||
entry.fleet = entry.fleet.filter(item => item.date && item.date.startsWith("20") && item.date.length === 8); | ||
} else if (key.endsWith("personelManagement") || key.includes("flightInfo") || key.includes("aircraftFlights")) { | ||
if (entry.date && (!entry.date.startsWith("20") || entry.date.length !== 8)) { | ||
delete entries[key]; | ||
} | ||
} | ||
|
||
chrome.storage.local.set({ [key]: entry }, function () { | ||
if (chrome.runtime.lastError) { | ||
reject(new Error('Error saving cleaned data for ' + key + ': ' + chrome.runtime.lastError.message)); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
Object.keys(entries).forEach(key => { | ||
tasks.push(cleanAndSave(entries[key], key)); | ||
}); | ||
|
||
Promise.all(tasks).then(() => { | ||
chrome.storage.local.get('settings', function (result) { | ||
const settings = result.settings || {}; | ||
settings.flightInformationsFixed = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps instead of a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i added 1 one in case if it needs further fixing, see second answer above |
||
chrome.storage.local.set({ settings: settings }, function () { | ||
if (chrome.runtime.lastError) { | ||
console.error('Error setting flightInformationsFixed:', chrome.runtime.lastError.message); | ||
} | ||
}); | ||
}); | ||
}).catch(error => { | ||
console.error('Error cleaning and saving data:', error); | ||
}); | ||
}); | ||
} | ||
|
||
function displayDashboard() { | ||
let mainDiv = $("#enterprise-dashboard"); | ||
mainDiv.before( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I ask why you changed the indenting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that was not intentional