Change `percent` to `rate` in retention metrics API (#16910)

lolsob-rspec
Claire 2022-01-23 16:01:25 +01:00 committed by GitHub
parent 06f653972a
commit 41d64ee271
3 changed files with 6 additions and 6 deletions

View File

@ -88,7 +88,7 @@ export default class Retention extends React.PureComponent {
</td> </td>
{data[0].data.slice(1).map((retention, i) => { {data[0].data.slice(1).map((retention, i) => {
const average = data.reduce((sum, cohort, k) => cohort.data[i + 1] ? sum + (cohort.data[i + 1].percent - sum)/(k + 1) : sum, 0); const average = data.reduce((sum, cohort, k) => cohort.data[i + 1] ? sum + (cohort.data[i + 1].rate - sum)/(k + 1) : sum, 0);
return ( return (
<td key={retention.date}> <td key={retention.date}>
@ -118,8 +118,8 @@ export default class Retention extends React.PureComponent {
{cohort.data.slice(1).map(retention => ( {cohort.data.slice(1).map(retention => (
<td key={retention.date}> <td key={retention.date}>
<div className={classNames('retention__table__box', `retention__table__box--${roundTo10(retention.percent * 100)}`)}> <div className={classNames('retention__table__box', `retention__table__box--${roundTo10(retention.rate * 100)}`)}>
<FormattedNumber value={retention.percent} style='percent' /> <FormattedNumber value={retention.rate} style='percent' />
</div> </div>
</td> </td>
))} ))}

View File

@ -6,7 +6,7 @@ class Admin::Metrics::Retention
end end
class CohortData < ActiveModelSerializers::Model class CohortData < ActiveModelSerializers::Model
attributes :date, :percent, :value attributes :date, :rate, :value
end end
def initialize(start_at, end_at, frequency) def initialize(start_at, end_at, frequency)
@ -59,7 +59,7 @@ class Admin::Metrics::Retention
current_cohort.data << CohortData.new( current_cohort.data << CohortData.new(
date: row['retention_period'], date: row['retention_period'],
percent: rate.to_f, rate: rate.to_f,
value: value.to_s value: value.to_s
) )
end end

View File

@ -4,7 +4,7 @@ class REST::Admin::CohortSerializer < ActiveModel::Serializer
attributes :period, :frequency attributes :period, :frequency
class CohortDataSerializer < ActiveModel::Serializer class CohortDataSerializer < ActiveModel::Serializer
attributes :date, :percent, :value attributes :date, :rate, :value
def date def date
object.date.iso8601 object.date.iso8601