Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,10 @@ jobs:
node-version-file: .nvmrc
cache: npm

- name: Prepare database
run: bundle exec rails db:schema:load

- name: Install node dependencies
run: npm ci

- name: Precompile assets
run: bundle exec rake assets:precompile

- name: Run unit tests
run: bundle exec rails test

- name: Set up Chrome
uses: browser-actions/setup-chrome@latest
with:
chrome-version: stable

- name: Run system tests
run: HEADLESS=1 bundle exec rails test:system
- name: Run CI
run: bin/ci
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.rbenv-vars
*.rb
*.rake
.context/
app/assets/builds/
public/vite*/
tmp/
vendor/
14 changes: 0 additions & 14 deletions app/controllers/user/views_controller.rb

This file was deleted.

22 changes: 11 additions & 11 deletions app/javascript/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ const App = ({ alert, notice }: { alert: string; notice: string }) => {
</Routes>
</ScrollToTop>
<Footer />
<Toaster
containerClassName="mt-12"
toastOptions={{
style: {
borderRadius: '10px',
background: '#0B1119',
color: '#fff',
border: '1px solid #1F2A37',
},
}}
/>
</div>
<Toaster
containerClassName="mt-12"
toastOptions={{
style: {
borderRadius: '10px',
background: '#0B1119',
color: '#fff',
border: '1px solid #1F2A37',
},
}}
/>
</ThemeProvider>
)
}
Expand Down
24 changes: 0 additions & 24 deletions app/javascript/components/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import { Avatar, Breadcrumb as BaseBreadcrumb, Button, Dropdown, Tooltip } from
import { useNavigate, useSearchParams } from 'react-router-dom'
import { useMetricWatchersCreate, useMetricWatchersDestroy } from '../queries/user/metricWatchers'

import _ from 'lodash'
import useCurrentUser from '../hooks/useCurrentUser'
import { Metric } from '../queries/user/metrics'
import { Project } from '../queries/user/projects'
import { useUsersIndex } from '../queries/user/users'
import { useViewsIndex } from '../queries/user/views'
import MetricActionsMenu from './MetricActionsMenu'
import ProjectActionsMenu from './ProjectActionsMenu'

Expand All @@ -25,10 +23,6 @@ const Breadcrumb = ({ projects, metrics }: { projects: Project[]; metrics: Metri
const metricId = parseInt(searchParams.get('metric_id') || '')
const currentMetric = metricId ? metrics.find((metric) => metric.id === metricId) : null

const { data: views } = useViewsIndex({ metricId })
const viewerIds = views ? _.uniq(views.map((view) => view.user_id)) : []
const { data: viewers } = useUsersIndex({ ids: viewerIds, enabled: !!currentMetric })

const { data: watchers } = useUsersIndex({ ids: currentMetric?.watcher_ids, enabled: !!currentMetric })

if (!user) return null
Expand Down Expand Up @@ -95,24 +89,6 @@ const Breadcrumb = ({ projects, metrics }: { projects: Project[]; metrics: Metri
{currentProject && (
<div className="ml-auto flex items-center gap-3">
{!currentMetric && <ProjectActionsMenu projectId={currentProject.id} />}
{viewers && views && views.length > 0 && (
<>
<p>Seen by:</p>
<Avatar.Group>
{viewers.map((viewer) => (
<Tooltip key={viewer.id} content={viewer.name} arrow={false}>
<Avatar
img={viewer.image}
rounded
stacked
className="cursor-pointer"
onClick={() => navigate(`/user/users/${viewer.id}`)}
/>
</Tooltip>
))}
</Avatar.Group>
</>
)}
{currentMetric && <MetricActionsMenu metricId={currentMetric.id} projectId={currentProject.id} />}
</div>
)}
Expand Down
20 changes: 5 additions & 15 deletions app/javascript/components/MetricCard.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
import { Card } from 'flowbite-react'
import { useEffect } from 'react'
import { ChartKind } from '../queries/user/charts'
import { useViewsCreate } from '../queries/user/views'
import MetricChart from './MetricChart'

const MetricCard = ({ metricId, owners }: { metricId: number; owners?: string[] }) => {
const { mutate: trackView } = useViewsCreate()

useEffect(() => {
trackView(metricId)
}, [metricId, trackView])

return (
<Card className="mb-3">
<MetricChart kind={ChartKind.Area} metricIds={[metricId]} owners={owners} />
</Card>
)
}
const MetricCard = ({ metricId, owners }: { metricId: number; owners?: string[] }) => (
<Card className="mb-3">
<MetricChart kind={ChartKind.Area} metricIds={[metricId]} owners={owners} />
</Card>
)
export default MetricCard
26 changes: 0 additions & 26 deletions app/javascript/queries/user/views.ts

This file was deleted.

1 change: 0 additions & 1 deletion app/models/metric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class Metric < ApplicationRecord
has_many :reports, dependent: :destroy
has_many :contributions, dependent: :destroy
has_many :chart_metrics, dependent: :destroy
has_many :views, as: :viewable, dependent: :destroy

validates :name, presence: true

Expand Down
1 change: 0 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class User < ApplicationRecord
has_many :metrics, through: :projects
has_many :notifications, dependent: :destroy
has_many :owned_organizations, class_name: Organization.to_s, dependent: :restrict_with_error
has_many :views, dependent: :destroy

before_save :ensure_api_key

Expand Down
6 changes: 0 additions & 6 deletions app/models/view.rb

This file was deleted.

11 changes: 8 additions & 3 deletions bin/ci
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ else
step "Setup: Dependencies" bundle install
step "Setup: Dependencies" npm install
fi
# Kill stale connections to cherry_test so db:test:prepare can purge it
psql -d cherry_development -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'cherry_test' AND pid <> pg_backend_pid()" > /dev/null 2>&1 || true
step "Setup: Database" bin/rails db:test:prepare
if [ "${CI:-}" = "true" ]; then
# Fresh CI database — no need to purge, just create and load schema.
step "Setup: Database" bin/rails db:create db:schema:load
else
# Kill stale connections to cherry_test so db:test:prepare can purge it.
psql -d cherry_development -c "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'cherry_test' AND pid <> pg_backend_pid()" > /dev/null 2>&1 || true
step "Setup: Database" bin/rails db:test:prepare
fi

# Linting
[ $FAILED -eq 0 ] && step "Style: Ruby" bundle exec rubocop
Expand Down
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
resource :settings, only: %i[update]
resources :subscriptions, only: %i[create]
resources :users, only: %i[index show]
resources :views, only: %i[index create]
end

constraints(->(request) { request.format == :html }) do
Expand Down
11 changes: 11 additions & 0 deletions db/migrate/20260417172507_drop_views.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

class DropViews < ActiveRecord::Migration[7.1]
def change
drop_table :views do |t|
t.references :user, null: false, foreign_key: true
t.references :viewable, polymorphic: true, null: false
t.timestamps
end
end
end
13 changes: 1 addition & 12 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading