rails activerecord statistics/trends/time-series graph data - ruby-on-rails

We are in the process of building dashboards for users where in they can see the trends/time series graphs of various activerecords; take a blogging site as an example. There are posts, each post has many comments and tags. There are 2 kinds of dashboards to be built.
a. trend graphs
b. time series graphs
trends graphs:
example, trending tags ( top 10, with # of posts), the ui looks like this
today [week] [month]
ruby-on-rails(20)
activerecord(10)
java(5)
When the user click on week, the trend shows the weekly data and so on.
And similarly, another trend graph is top 10 posts with highest # of comments
time series graphs:
for example, time vs # of posts, over a period of 24 hours, 1 week, 1 month etc.,
30
20 |
10 | | 10
| | | |
t1 t2 t3 t4
a visual example
Secondary Requirement:
The time series graphs cane be interactive and we may want show the actual data or additional series when a point is selected. Additional series: for example when the user selects point (t3,30) we want to show the tag name vs #count data.
ruby-on-rails(15)
activerecord(10)
java(5)
I have looked at statistics gem and it is good for generating counts but not graph data.
Question
Is there a gem(framework) to generate data for these graphs?. In our case, the graph data can be cached and refreshed every 15/30 minutes.

Is there any reason why you need a gem? A place that I've worked used Highcharts in combination with Ruby/Rails and that worked. You could also use the Google Chart API. I'm not sure how much you want to build out what you're doing, but you can create tables in a sql database that track whatever you want to be tracking, and then just feed those to the charting tool
Also, here are several services with API's that offer this kind of graphing capability.
StatsMix, Metricly, myDials, KPI Dashboard, and more

Related

I need to be able to count by hour the first iteration of each unique story

I get data from our CMS that shows all actions of staff within that system.
My challenge is to be able to show in a chart only the first iteration of each story as published and the hour in which it occurred.
A single story can be published multiple times during a day.
Using countuniquesif I can get the number of unique stories per hour by using:
=COUNTUNIQUEIFS(Sheet0!I2:I60000,Sheet0!G2:G60000,"NL_Stories/Ready",Sheet0!E2:E60000,"Webpub",Sheet0!B2:B60000,"08")
=COUNTUNIQUEIFS(Sheet0!I2:I60000,Sheet0!G2:G60000,"NL_Stories/Ready",Sheet0!E2:E60000,"Webpub",Sheet0!B2:B60000,"09")
Etc
However, if that story is published in the period from 8am-9am (08 in column B), if it is published again between 9am-10am (09 in column B) it will be counted again.
How can I limit this to just the first time it is published and excluded in any of the other hours.
I have attached a spreadsheet with two tabs, one with the raw data and two with what I currently do.
Any assistance appreciated
https://docs.google.com/spreadsheets/d/1V-kZyUUfXtaf6pMYDCxNSUjjWclOrUcW2Pk2y678RZo/edit?usp=sharing

How Calculate change rate over time with tabular dataset in google data studio?

I seek your valuable support in finding a way to calculate change rate over time with tabular dataset in google data studio. Here is the link to the dataset: https://docs.google.com/spreadsheets/d/1To1n5JJA6uVkLMgwjKhghJgCJpFmtXkqNog4DzfoEbE/edit?usp=sharing
There are many rows with data stamp and have different categories and sub categories. I have created a change rate table manually based on which I want to create charts in google data studio. The charts will be from the raw tabular data not the separate change rate table that is built only for example purpose.
So the chart could be based on a main category (as in the sample) and can also be viewed as sub-category and show change rate over time between the dates.
The dates can sometimes be months or years. I am not very savy with advanced formulas or scripting but I am hopeful someone here would be able to help me out on this. I will be ever so grateful for this :)
I can only provide you with the quotient of datasets between two days. If you need different mappings between dates (day, months, years), for each the following steps have to be done:
generate a new field "yesterday" with: DATETIME_SUB(date, INTERVAL 1 day)
blend this dataset with itself, using as dimension "date" and "yesterday".
Further dimensions are your categories fields A and B.
As metric, you can use the count of the date field.

Delphi FastReports - How to change Rows?

Delphi Tokyo, FastReports V5. I have a report that I cannot seem to get correct. The report is showing information for 1 sales rep. It contains two Master Data bands and 1 detail data band. Within Delphi, the pseudo code looks like this:
For each sales rep in table
Get Rep ID
Filter ActiveOrders DataSource based on rep ID
Load report definition
Execute report
Export Report to PDF
Next Sales Rep
This works fine for a simple report, such as one that only has a single MasterData band. My report is a little more complex. Specifically, it has two MasterData bands, which are only slightly related. The first band works fine with the pseudo code above. The second band is ONLY a graph. The graph has 4 datasources, because each datasource is tied to a series (aka each datasource adds a different line to the graph). I cannot figure out how to handle the coordination of the data.
My report looks like this.
As an example... the rep is Bob. Bob has 6 active orders, which shows up fine in the top MasterData band, as 6 rows of data. Of those 6 active orders, there are 3 separate companies. I want a graph of each company (in MasterData2). Below each graph, I want detailed data about the orders for that company. I want this to show up as
Graph of Company 1
Details of Company 1
Graph of Company 2
Details of Company 2
Graph of Company 3
Details of Company 3
I can write the queries to get the correct data. I just can't figure out HOW to coordinate the data changing. Since the MasterData2 is a graph, I can't return the data for all 3 companies, or FastReports will try to graph all the rows. How do I tell MasterData2 WHICH data to look at, and how do I tell it that there are more companies to graph (aka another Master/Detail) set to process?

Is there a dimension modeling design pattern for multi-valued dimensions

I'm working on a data warehouse that seeks to capture website visits and purchase. We have a hypothesis that by identifying patterns from previous site visits you can get insights into visitor behavior for the current site visit
The grain of my fact table is individual website visits and we assign a 1 if the customer makes a purchase and a 0 if she does not. Our fact is additive. We would like to be able explore and understand how the actions of prior visits influence the action of the current visit so I'm trying to figure out how you would go about modeling this. On a particular site visit a visitor could have 1, 2 or 12 prior site visits.
So my question is how would I model a past visit dimension that includes the past visit date, past visit activity (purchase or no purchase, time on site, etc). Is this an example of a use for a bridge table.
A bridge table in a data-warehouse is primarily (exclusively?) for dealing with many to many relationships, which you don't appear to have.
If the grain of your fact table is website visits then you don't need a 'past visit' dimension, since your fact table contains the visit history already.
You have two dimensions here:
Customer
Date
Time on site is presumably a number, and since you are treating purchase/no purchase as a boolean score (1,0) these are both measures and belong in the fact table.
The Customer dimension is for your customer attributes. Don't put measures here (e.g. prior scores). You should also consider how to handle changes (probably SCD type 2).
You could put your date field directly in the fact table but it is more powerful as a separate dimension, since you can much more easily analyze by quarters, financial years, public holidays etc.
So,
Example Fact_Website_Visit table:
Fact_Website_Visit_Key | Dim_Customer_Key | Dim_Date_Key | Purchase(1,0) | Time_On_Site
Example Dim_Customer Dimension:
Dim_Customer_Key | Customer_ID | Customer_Demographic
Example Dim_Date Dimension:
Dim_Date_Key | Full_Date | IsWeekend
To demonstrate how this works I've written an example report to see sale success and average time spent online on weekends grouped by customer demographic:
SELECT
Dim_Customer.demographic,
COUNT(fact.Fact_Website_Visit_Key) AS [# of Visits],
SUM (fact.Purchase) AS [Total Purchases],
AVG (fact.Time_On_Site) AS [Average Minutes Online],
SUM (fact.Purchase)/COUNT(fact.Fact_Website_Visit_Key)*100 AS [% sale success]
FROM
Fact_Website_Visit fact
INNER JOIN Dim_Customer ON fact.Dim_Customer_Key=Dim_Customer.Dim_Customer_Key
INNER JOIN Dim_Date ON fact.Dim_Date_Key=Dim_Date.Dim_Date_Key
WHERE
Dim_Date.IsWeekend='Y'
GROUP BY
Dim_Customer.Demographic

How to divide group of field with another group of fields in Crystal Reports graphs?

I am creating a Crystal Report which consist of a graph. As I am new to this, I might be having problem with a very simple issue.
I have a table which consist of date, actual_rev, hrs_available, etc.
Now what I need in the graph is for each date sum of the actual_rev/ sum of the hrs_available. And this should be done grouping of every single date so that graph shows bar of each date.
In the above example the revenue sums up to 2317.00 and the hours sums up to 15.33 , getting the revenue per hour 151.14, which should be shown in the graph for this date.

Resources