-
Notifications
You must be signed in to change notification settings - Fork 0
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
Trend random values #36
base: master
Are you sure you want to change the base?
Conversation
val nextEntry = products.head | ||
val product = nextEntry._1 | ||
val tsNs = nextEntry._2 | ||
|
||
|
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.
Remove duplicate newline
plan | ||
} | ||
|
||
def readTrendsFromFile(startTs: DateTime) : PriorityMap[Product, Long] = { |
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.
This function should be removed, it exists in Products.scala
|
||
object Trends extends ApplicationConfig with LazyLogging { | ||
private def parseTrendFromFile(filename: String) : Product = { |
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.
This function should be removed, it exists in Products.scala
src/main/resources/application.conf
Outdated
@@ -23,10 +23,10 @@ gen { | |||
cassandra.element.amount.max=1000 | |||
|
|||
# Scale up or scale down the amount of cdrs generated (1 for realistic values) | |||
modifier=0.01 | |||
modifier=0.001 |
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.
Modifier should be 0.01
src/main/resources/application.conf
Outdated
|
||
# Total amount of hours to generate back in time | ||
backintime=48 | ||
backintime=96 |
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.
backintime should be 48
these ++ f.listFiles.filter(_.isDirectory).flatMap(recursiveListFiles) | ||
} | ||
|
||
val trendsDirPath = Option(System.getProperty("trends.dir")) match { |
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.
This is using the old version of trendsDirPath, the one in master is now:
val trendsDirPath = Option(System.getProperty("trends.dir")).
getOrElse(getClass.getClassLoader.getResource("trends").getPath)
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.
github did not fix the indentation for that code above.
val files = recursiveListFiles(new File(trendsDirPath)) | ||
|
||
// Create a priority list out of all products with default timestamp | ||
var pmap = mutable.HashMap.empty[Product, Long] |
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.
pmap can be removed as it is not used anymore.
newDay = timeCheck + 1 | ||
if (newDay == 8) {newDay = (newDay % 7)} | ||
products = Trends.changeTrends(products) | ||
} |
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.
I don't think these variables are descriptive.
newDay
, timeCheck
?
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.
Also please write some quick comment that describes what this chunk of code does.
newDay = timeCheck + 1 | ||
if (newDay == 8) {newDay = (newDay % 7)} | ||
products = Trends.changeTrends(products) | ||
} |
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.
Also please write some quick comment that describes what this chunk of code does.
|
||
def changeTrends(maptemp: PriorityMap[Product, Long]) : PriorityMap[Product, Long] = { | ||
val e = maptemp.map(p => (p._1.copy(points = p._1.points.map(point => point.copy( | ||
cdrPerSec = (((Random.nextFloat()*0.2) + (-0.1))*point.cdrPerSec) + point.cdrPerSec))), p._2)) |
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.
Could you please re-structure this huge one-liner?
I would prefer something like
maptemp.map(p =>
(p._1.copy(
points = p._1.points.map(
point=> point.copy(
and so on
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.
Well done
hourDiffLow/hourDiffHigh | ||
} | ||
|
||
def changeTrends(maptemp: PriorityMap[Product, Long]) : PriorityMap[Product, Long] = { |
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.
Please rename to randomizeTrends or something else that is more descriptive
@@ -1,12 +1,18 @@ | |||
package se.qvantel.generator | |||
|
|||
import java.io.File |
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.
Unused imports, please remove
p => (p._1.copy( | ||
points = p._1.points.map( | ||
point => point.copy( | ||
cdrPerSec = (((Random.nextFloat()*0.2) + (-0.1))*point.cdrPerSec) + point.cdrPerSec))), p._2)) |
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.
Would be nice if the 10% value would be configurable in the application.conf file, but not necessary
Codecov Report
@@ Coverage Diff @@
## master #36 +/- ##
==========================================
- Coverage 35.31% 33.84% -1.48%
==========================================
Files 15 15
Lines 252 263 +11
Branches 12 11 -1
==========================================
Hits 89 89
- Misses 163 174 +11
Continue to review full report at Codecov.
|
Trend points will increase with a value between 0 and 10% every day. A minor bug was detected while testing and it has not been fixed. The graphs tend to "spike" at 12:00 AM when the randomizeTrends (the method which modifies the trend points) is ran. This spike is only attached to the graph which is modified first when randomizeTrends is ran. |
Trends will increase/decrease with 0-10% every day. Minor modifications in the application.conf where modifier is set from "0.01" to "0.001" and backintime from "48" to "96".