Skip to content

Commit

Permalink
🔨 incorporate PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 committed Dec 13, 2024
1 parent d220dd9 commit 7774757
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
13 changes: 6 additions & 7 deletions adminSiteClient/ChartIndexPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
highlightFunctionForSearchWords,
SearchWord,
} from "../adminShared/search.js"
import { sortNumeric, SortOrder } from "@ourworldindata/utils"

@observer
export class ChartIndexPage extends React.Component {
Expand Down Expand Up @@ -56,13 +57,11 @@ export class ChartIndexPage extends React.Component {

// Apply sorting if needed
if (sortConfig?.field === "pageviewsPerDay") {
return [...filtered].sort((a, b) => {
const aValue = a.pageviewsPerDay || 0
const bValue = b.pageviewsPerDay || 0
return sortConfig.direction === "desc"
? bValue - aValue
: aValue - bValue
})
return sortNumeric(
[...filtered],
(chart) => chart.pageviewsPerDay,
sortConfig.direction === "asc" ? SortOrder.asc : SortOrder.desc
)
}

return filtered
Expand Down
5 changes: 2 additions & 3 deletions adminSiteClient/EditorReferencesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
formatValue,
ChartRedirect,
partition,
round,
} from "@ourworldindata/utils"
import { AbstractChartEditor, References } from "./AbstractChartEditor.js"
import {
Expand Down Expand Up @@ -214,9 +215,7 @@ export class EditorReferencesTabForChart extends React.Component<{
</strong>{" "}
{this.renderPageview(
this.pageviews?.views_365d
? Math.round(
this.pageviews?.views_365d / 36.5
) / 10
? round(this.pageviews?.views_365d / 365, 1)
: undefined
)}
</div>
Expand Down

0 comments on commit 7774757

Please sign in to comment.