Locations Plugin

I just wanted to bring this up again as a feature request.

We are just having this in our community when planning an event. People now use Google Maps to see how far away the suggested event location is.

Also it is useful when checking out how far away the other user is. (We run a scuba diving forum and people look for diving buddies in our forum.)

3 Likes

@Roi, you might be interested in this:

With this release we introduce (experimental) natural language search for user locations with Discourse Chatbot :robot: , so you can ask it things like:

  • ā€œList the five nearest users to my locationā€ ā€¦ (if youā€™ve registered a location) ā€¦ or even
  • ā€œList all users within 500km of my location.ā€
  • ā€œList the users within 200km of Berlin.ā€

It doesnā€™t yet support Topic Locations ā€¦ but thatā€™s 2/3rds done and in the pipeline ā€¦

Thereā€™s a data migration in this release, so please let me know if anyone has any issues and I will try to help.

8 Likes

I know this is still a work-in-progress so you may already know about theseā€¦

  1. Sometimes when I open the User Map I get a blank map, i.e. countries map displayed but no users on it. If I refresh the page then the mapped users re-appear. I havenā€™t found a guaranteed way to replicate this, but I see the blank map at least 50% of the times I open the user map. The blank map only seems to appear on the user map. Iā€™ve not see it on the topic map, at least not so far.

  2. Thereā€™s a blank white box to the left of the name/username/etc radio button fields, e.g.

image

1 Like
  1. Yeah, the solution is not perfect. Itā€™s not my focus at present. PR accepted.

  2. is entirely intentional: itā€™s a search box.

1 Like

Ahhh! So it is.

I just found something else. My topic map doesnā€™t have many entries on it, but in the US I have 3 clustered on the east coast and two clustered on the west coast. If I click the east coast cluster it zooms in to display the three individual topic locations. If I click on any of those locations rather than opening the associated topic it zooms in to show the two west coast locations. This is repeatable - try it on my site Weather-Watch Forum

2 Likes

Very curious indeed! Strangely they are working fine on my data. I also note on your map, there is an error when hovering over a cluster.

Leaflet version is seriously dated ā€¦ might be an issue ā€¦

1 Like

OK Iā€™ve pushed the version of Leaflet and its popular marker cluster plugin to latest, see if that helps:

We might as well break it properly with latest code :sweat_smile:

(there is no point in even discussing such issues if we are running an old library, who knows what theyā€™ve fixed!).

3 Likes

Thanks for the quick update. On an initial test itā€™s behaving better now. Iā€™ve not got the weird east to west coast jump on the couple of tests iā€™ve tried. Iā€™ll do some more testing tomorrow.

2 Likes

Yeah, I can see. Great! Thanks for rechecking promptly.

2 Likes

After more testing today it looks like the last update has fixed the blank map on first opening and also the weird east to west coast jump from clustered locations :grinning:

4 Likes

Thank you for pointing this out to me, and sorry, that I was not around here for some days to comment.

That really sounds promising. :slight_smile: But at the moment, we do not have the AI Chatbot active in our forum. I am still struggling with guessing how much this would cost us to get an API key from OpenAI. As we run our community in a non-profit way and do not charge, we hardly get the server and domain costs out of the few donations and other stuff like this. So that is an important topic for us. :wink:

The link to the answer in the post with the example calculations does not work anymore. Can you tell me where to find it? :slight_smile:

And besides the AI Chatbot integration: Are you thinking about putting a distance information into the plugin as well? So simply showing the distance from the current logged in user to an event or to another user - if both sides have set an location? That was the simple way it was handled in the location plugin for phpBB we used before.

The cost post was deleted Iā€™m afraid as the Topic was getting stupidly long. Iā€™ll remove that from the OP. (Done)

I suggest trying it out : permission staff only initially.

No, I donā€™t plan to make it available in the Locations plugin without the Chatbot.

For all you subversive subfolder users out there, @renato has kindly PRā€™d to make sure the markers work in such a configuration:

Thanks very much @renato! :pray:

5 Likes

THANK YOU!
One quick question:
How do I update this plugin? run ./reset-all-repos seems risky.
Goal is to only update this plugin, and not lose the data of the 180 projects already entered.

1 Like

Thatā€™s not really a plugin specific question, but you will need to be running tests-passed and update to latest to get all the new stuff working.

Itā€™s always risky :sweat_smile: , unless you want to run a Stable install? (in which case this update is not yet relevant).

The online upgrade (from /admin/upgrade) might work for you, or as usual, rebuild with ./launcher rebuild app - assuming you are running a standard install?

I cannot vouch for the rest of your plugins maintenance levels, but good luck! :sweat_smile:

1 Like

Encountered the same problem.

I tried the method listed here

But not working.
Ubuntu system, reboot not working,
./launcher restart app, ./launcher start app not working.

Error Message when running ./launcher rebuild app

......
111:M 12 Dec 2023 12:11:02.199 * DB saved on disk
111:M 12 Dec 2023 12:11:02.200 # Redis is now ready to exit, bye bye...



FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 3553 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.

Thank you for @itsbhanusharma

It says caused by earlier error, I list them here

I, [2023-12-13T00:50:13.222274 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundl                e exec rake db:migrate'
2023-12-13 00:50:18.347 UTC [3597] discourse@discourse ERROR:  invalid input syntax for type double precision: ""

2023-12-13 00:50:18.347 UTC [3597] discourse@discourse STATEMENT:  INSERT INTO locations_topic                 (topic_id, latitude, longitude, name, street, district, city, state, postalcode, country, count                rycode, international_code, locationtype, boundingbox, updated_at, created_at) (
          SELECT
          tc.topic_id,
          (tc.value::json->'geo_location'->>'lat')::FLOAT,
          (tc.value::json->'geo_location'->>'lon')::FLOAT,
          tc.value::json->'geo_location'->>'name',
          tc.value::json->'geo_location'->>'street',
          tc.value::json->'geo_location'->>'district',
          tc.value::json->'geo_location'->>'city',
          tc.value::json->'geo_location'->>'state',
          tc.value::json->'geo_location'->>'postalcode',
          tc.value::json->'geo_location'->>'country',
          tc.value::json->'geo_location'->>'countrycode',
          tc.value::json->'geo_location'->>'international_code',
          tc.value::json->'geo_location'->>'type',
          ARRAY[
            (tc.value::json->'geo_location'->'boundingbox'->>0)::FLOAT,
            (tc.value::json->'geo_location'->'boundingbox'->>1)::FLOAT,
            (tc.value::json->'geo_location'->'boundingbox'->>2)::FLOAT,
            (tc.value::json->'geo_location'->'boundingbox'->>3)::FLOAT
          ],
          tc.updated_at,
          tc.created_at
        FROM topic_custom_fields tc
        WHERE tc.name = 'location'
        AND tc.value NOT IN ('"{}"', '{}', '')
        AND tc.value::json->'geo_location'->>'lat' IS NOT NULL
        AND tc.value::json->'geo_location'->>'lon' IS NOT NULL
        )
        ON CONFLICT DO NOTHING

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled: (StandardError)

ERROR:  invalid input syntax for type double precision: ""
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rack-mini-profiler-3.3.0/lib/patches/db/pg.rb: 110:in `exec'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rack-mini-profiler-3.3.0/lib/patches/db/pg.rb: 110:in `async_exec'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/mini_sql-1.5.0/lib/mini_sql/postgres/connection.rb:202:in `run'

#--------------
Caused by:
PG::InvalidTextRepresentation: ERROR:  invalid input syntax for type double precision: "" (PG:: InvalidTextRepresentation)
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rack-mini-profiler-3.3.0/lib/patches/db/pg.rb: 110:in `exec'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/rack-mini-profiler-3.3.0/lib/patches/db/pg.rb:  110:in `async_exec'
/var/www/discourse/vendor/bundle/ruby/3.2.0/gems/mini_sql-1.5.0/lib/mini_sql/postgres/connection.rb:202:in `run'

and the docker ps message

/var/discourse# docker ps
CONTAINER ID   IMAGE                 COMMAND        CREATED             STATUS         PORTS                                                                      NAMES
d3c8e85149a8   local_discourse/app   "/sbin/boot"   About an hour ago   Up 6 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   app

Your error is not the same as OP. Could you provide full log of rebuild?

Thank you Bhanu, I have redo the rebuild process, and generated the ā€œearlier errorsā€ in the former post. Could you please help understand and solve the problem?

Looks like an issue with locations plugin, Could you try rebuilding without it to see if that fixes the build issue?

1 Like

Great! I just rebuild the system, and it works.

While I have to say, location plugin is very good. So I hope relative debugging can be done.