Verified Commit 7eaa6264 authored by Aral Balkan's avatar Aral Balkan
Browse files

WIP: Generate deployment diff stats (correctly aggregating now)

(Using sets instead of arrays to correctly count changes without duplicates.)
parent 822a8e0e
......@@ -809,27 +809,72 @@ Better is a Safari content blocker for <a href='
# Prepare metadata
rulesAdded = []
rulesUpdated = []
rulesDeleted = []
rulesAdded = new Set()
rulesUpdated = new Set()
rulesDeleted = new Set()
sitesAdded = new Set()
sitesUpdated = new Set()
sitesDeleted = new Set()
trackersAdded = new Set()
trackersUpdated = new Set()
trackersDeleted = new Set()
TRACKERS = 'trackers'
SITES = 'sites'
for key, value of @contentCurrentModifiedTimes
uniqueIdentifier = key.replace /(.*\/*.)\/.*/, "$1"
# Added?
if (@contentPreviousModifiedTimes[key] == undefined)
rulesAdded.push key
rulesAdded.add uniqueIdentifier
if (key.indexOf TRACKERS) > -1
trackersAdded.add uniqueIdentifier
if (key.indexOf SITES) > -1
sitesAdded.add uniqueIdentifier
# Updated?
else if (@contentPreviousModifiedTimes[key] != value)
rulesUpdated.push key
rulesUpdated.add uniqueIdentifier
if (key.indexOf TRACKERS) > -1
trackersUpdated.add uniqueIdentifier
if (key.indexOf SITES) > -1
sitesUpdated.add uniqueIdentifier
for key, value of @contentPreviousModifiedTimes
uniqueIdentifier = key.replace /(.*\/*.)\/.*/, "$1"
# Deleted?
if (@contentCurrentModifiedTimes[key] == undefined)
rulesDeleted.push key
rulesDeleted.add uniqueIdentifier
if (key.indexOf TRACKERS) > -1
trackersDeleted.add uniqueIdentifier
if (key.indexOf SITES) > -1
trackersDeleted.add uniqueIdentifier
console.log("Rules added: #{rulesAdded.length}")
console.log("Rules added: #{rulesAdded.size}")
console.log("Ruled updated: #{rulesUpdated.length}")
console.log("Ruled updated: #{rulesUpdated.size}")
console.log("Rules deleted: #{rulesDeleted.length}")
console.log("Rules deleted: #{rulesDeleted.size}")
console.log("Trackers added: #{trackersAdded.size}")
console.log("Trackers updated: #{trackersUpdated.size}")
console.log("Trackers deleted: #{trackersDeleted.size}")
console.log("Sites added: #{sitesAdded.size}")
console.log("Sites updated: #{sitesUpdated.size}")
console.log("Sites deleted: #{sitesDeleted.size}")
# Calculate the last update time based on the content cache.
# Since timestamps have lexographical order, we can use a reduce
# on the values of the cache dictionary to achieve this.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment