Skip to content

Commit

Permalink
Merge pull request #802 from Freika/dev
Browse files Browse the repository at this point in the history
0.23.6
  • Loading branch information
Freika authored Feb 6, 2025
2 parents ea7d08a + 6072e46 commit ca32d6e
Show file tree
Hide file tree
Showing 34 changed files with 366 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .app_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.23.5
0.23.6
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ orbs:
jobs:
test:
docker:
- image: cimg/ruby:3.3.4
- image: cimg/ruby:3.4.1
environment:
RAILS_ENV: test
- image: cimg/postgres:13.3
- image: cimg/postgres:13.3-postgis
environment:
POSTGRES_USER: postgres
POSTGRES_DB: test_database
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_and_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

jobs:
build-and-push-docker:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.4
3.4.1
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

# 0.23.6 - 2025-02-06

### Added

- Enabled Postgis extension for PostgreSQL.
- Trips are now store their paths in the database independently of the points.
- Trips are now being rendered on the map using their precalculated paths instead of list of coordinates.

### Changed

- Ruby version was updated to 3.4.1.
- Requesting photos on the Map page now uses the start and end dates from the URL params. #589

# 0.23.5 - 2025-01-22

### Added
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#### **Did you write a patch that fixes a bug?**

* Open a new GitHub pull request with the patch.
* Open a new GitHub pull request with the patch against the `dev` branch.

* Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.

Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ gem 'lograge'
gem 'oj'
gem 'pg'
gem 'prometheus_exporter'
gem 'activerecord-postgis-adapter', github: 'StoneGod/activerecord-postgis-adapter', branch: 'rails-8'
gem 'puma'
gem 'pundit'
gem 'rails', '~> 8.0'
gem 'rgeo'
gem 'rswag-api'
gem 'rswag-ui'
gem 'shrine', '~> 3.6'
Expand Down
29 changes: 22 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
GIT
remote: https://github.com/StoneGod/activerecord-postgis-adapter.git
revision: 147fd43191ef703e2a1b3654f31d9139201a87e8
branch: rails-8
specs:
activerecord-postgis-adapter (10.0.1)
activerecord (~> 8.0.0)
rgeo-activerecord (~> 8.0.0)

GIT
remote: https://github.com/alexreisner/geocoder.git
revision: 04ee2936a30b30a23ded5231d7faf6cf6c27c099
Expand Down Expand Up @@ -215,18 +224,18 @@ GEM
net-smtp (0.5.0)
net-protocol
nio4r (2.7.4)
nokogiri (1.18.2)
nokogiri (1.18.1)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.18.2-aarch64-linux-gnu)
nokogiri (1.18.1-aarch64-linux-gnu)
racc (~> 1.4)
nokogiri (1.18.2-arm-linux-gnu)
nokogiri (1.18.1-arm-linux-gnu)
racc (~> 1.4)
nokogiri (1.18.2-arm64-darwin)
nokogiri (1.18.1-arm64-darwin)
racc (~> 1.4)
nokogiri (1.18.2-x86_64-darwin)
nokogiri (1.18.1-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.18.2-x86_64-linux-gnu)
nokogiri (1.18.1-x86_64-linux-gnu)
racc (~> 1.4)
oj (3.16.9)
bigdecimal (>= 3.0)
Expand Down Expand Up @@ -318,6 +327,10 @@ GEM
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.3.8)
rgeo (3.0.1)
rgeo-activerecord (8.0.0)
activerecord (>= 7.0)
rgeo (>= 3.0)
rspec-core (3.13.2)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
Expand Down Expand Up @@ -448,6 +461,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
activerecord-postgis-adapter!
bootsnap
chartkick
data_migrate
Expand Down Expand Up @@ -475,6 +489,7 @@ DEPENDENCIES
pundit
rails (~> 8.0)
redis
rgeo
rspec-rails
rswag-api
rswag-specs
Expand All @@ -496,7 +511,7 @@ DEPENDENCIES
webmock

RUBY VERSION
ruby 3.3.4p94
ruby 3.4.1p0

BUNDLED WITH
2.5.21
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Donate using crypto: [0x6bAd13667692632f1bF926cA9B421bEe7EaEB8D4](https://ethers
- Explore statistics like the number of countries and cities visited, total distance traveled, and more!

📄 **Changelog**: Find the latest updates [here](CHANGELOG.md).

👩‍💻 **Contribute**: See [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute to Dawarich.
---

## ⚠️ Disclaimer
Expand Down
3 changes: 2 additions & 1 deletion app/assets/stylesheets/actiontext.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
background-color: white !important;
}

.trix-content {
.trix-content-editor {
min-height: 10rem;
width: 100%;
}
5 changes: 0 additions & 5 deletions app/controllers/trips_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ def index
end

def show
@coordinates = @trip.points.pluck(
:latitude, :longitude, :battery, :altitude, :timestamp, :velocity, :id,
:country
).map { [_1.to_f, _2.to_f, _3.to_s, _4.to_s, _5.to_s, _6.to_s, _7.to_s, _8.to_s] }

@photo_previews = Rails.cache.fetch("trip_photos_#{@trip.id}", expires_in: 1.day) do
@trip.photo_previews
end
Expand Down
4 changes: 4 additions & 0 deletions app/javascript/controllers/datetime_controller.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// This controller is being used on:
// - trips/new
// - trips/edit

import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/controllers/maps_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ export default class extends Controller {
}

const urlParams = new URLSearchParams(window.location.search);
const startDate = urlParams.get('start_at')?.split('T')[0] || new Date().toISOString().split('T')[0];
const endDate = urlParams.get('end_at')?.split('T')[0] || new Date().toISOString().split('T')[0];
const startDate = urlParams.get('start_at') || new Date().toISOString();
const endDate = urlParams.get('end_at')|| new Date().toISOString();
await fetchAndDisplayPhotos({
map: this.map,
photoMarkers: this.photoMarkers,
Expand Down
76 changes: 63 additions & 13 deletions app/javascript/controllers/trip_map_controller.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
// This controller is being used on:
// - trips/index

import { Controller } from "@hotwired/stimulus"
import L from "leaflet"

export default class extends Controller {
static values = {
tripId: Number,
coordinates: Array,
path: String,
apiKey: String,
userSettings: Object,
timezone: String,
distanceUnit: String
}

connect() {
console.log("TripMap controller connected")

setTimeout(() => {
this.initializeMap()
}, 100)
Expand All @@ -23,7 +28,7 @@ export default class extends Controller {
zoomControl: false,
dragging: false,
scrollWheelZoom: false,
attributionControl: true // Disable default attribution control
attributionControl: true
})

// Add the tile layer
Expand All @@ -33,24 +38,69 @@ export default class extends Controller {
}).addTo(this.map)

// If we have coordinates, show the route
if (this.hasCoordinatesValue && this.coordinatesValue.length > 0) {
if (this.hasPathValue && this.pathValue) {
this.showRoute()
} else {
console.log("No path value available")
}
}

showRoute() {
const points = this.coordinatesValue.map(coord => [coord[0], coord[1]])
const points = this.parseLineString(this.pathValue)

const polyline = L.polyline(points, {
color: 'blue',
opacity: 0.8,
weight: 3,
zIndexOffset: 400
}).addTo(this.map)
// Only create polyline if we have points
if (points.length > 0) {
const polyline = L.polyline(points, {
color: 'blue',
opacity: 0.8,
weight: 3,
zIndexOffset: 400
})

this.map.fitBounds(polyline.getBounds(), {
padding: [20, 20]
})
// Add the polyline to the map
polyline.addTo(this.map)

// Fit the map bounds
this.map.fitBounds(polyline.getBounds(), {
padding: [20, 20]
})
} else {
console.error("No valid points to create polyline")
}
}

parseLineString(linestring) {
try {
// Remove 'LINESTRING (' from start and ')' from end
const coordsString = linestring
.replace(/LINESTRING\s*\(/, '') // Remove LINESTRING and opening parenthesis
.replace(/\)$/, '') // Remove closing parenthesis
.trim() // Remove any leading/trailing whitespace

// Split into coordinate pairs and parse
const points = coordsString.split(',').map(pair => {
// Clean up any extra whitespace and remove any special characters
const cleanPair = pair.trim().replace(/[()"\s]+/g, ' ')
const [lng, lat] = cleanPair.split(' ').filter(Boolean).map(Number)

// Validate the coordinates
if (isNaN(lat) || isNaN(lng) || !lat || !lng) {
console.error("Invalid coordinates:", cleanPair)
return null
}

return [lat, lng] // Leaflet uses [lat, lng] order
}).filter(point => point !== null) // Remove any invalid points

// Validate we have points before returning
if (points.length === 0) {
return []
}

return points
} catch (error) {
return []
}
}

disconnect() {
Expand Down
Loading

0 comments on commit ca32d6e

Please sign in to comment.