We are moving to Discord!

Join us on the Countly Community Discord Server! Engage in discussions, share your feature ideas, and learn from fellow Countly users to build exceptional apps and experiences.

What is extractChartData expecting as db argument?

Hey everybody (probably hey ar2rsawseen),

my hopefully last question; I'm struggling with extractChartData(), I wonder what the db parameter should be. My goal is to create a graph using drawTimeGraph() for all events that occured from a certain table.

What I did:

  1. Query data using common.db.collection("tablename").find({}).toArray(function(err, app_earliest_life_all){...})
  2. Pass the result to the function var extractedData = countlyCommon.extractChartData(data,countlyEvent.clearEventsObject, chartData, dataProps)
  3. Pass the extractedData to the drawing function countlyCommon.drawTimeGraph(extractedData["chartDP"], "#dashboard-time-graph");

I see the plot, but all values are 0 - what am I doing wrong? (I tried a bunch of variations of the above code)

Thanks so much,
Bernhard.

0

Comments

1 comment
  • You are still going with that approach? 😃
    Ok, and you specifically want to do it directly from the database?

    This was the system that evolved and optimized, etc, so can be quite complex

    To answer your specific question, db is basically the data you get from API endpoint (which merges multiple documents, that you get from database together)

    From your description, what is missing, is the merging document you retrieved from the database.
    Also to note, events specifically contain 2 types of documents, 1 level data (overall count, sum, duration, etc) and 2 level data (count, sum, duration per segment values)

    extractChartData works for 1 level data, so you need to retrieve only those documents, those would be documents with_id starting with "no-segment"

    Here is how API generates query to get needed documents for some period

    And then when they are read, they also need to be merged correctly into single structure, and here is how API does it:

    If you want, you can find me on community slack: http://slack.count.ly/
    and we can discuss why it has to be so complicated and find solutions that you need together

    0
    Comment actions Permalink

Please sign in to leave a comment.