Dog Weather module for Drupal 6.

git clone --branch 6.x-1.x jason.lopez@git.drupal.org:sandbox/jason.lopez/1412278.git dog_weather

Dog Weather Module

git clone --branch master jason.lopez@git.drupal.org:sandbox/jason.lopez/1412278.git dog_weather

The Dog Weather module is a custom module that was developed for the dogzville.com website, a social network for the dog-friendly community. It includes the ability to collect observed and forecast weather information from the noaa.gov website. For performance reasons, it was decided that observed weather from each ICAO would be downloaded, unzipped and made available only once at the top of each hour. This would eliminate the need to develop a real-time SOAP/XML request / caching facility when a user entered a zip code or city, state. The ability to associate location information with the nearest ICAO is based on a mySQL table that includes a relationship between the lat and long coordinates of each zipcode and its closest ICAO. A three day weather forecast is made available to site visitors using a real-time SOAP/XML request / caching facility. The majority of functions are utility functions that are meant to either collect the data, perform various operations on it and load it into a table once an hour or make real-time requests and cache it for future requests.

I looked at various modules including the weather.module to determine if I could use it to satisfy dogzville.com weather requirements but I found that there would be to much manipulation and overriding involved to make it work. The approach to identify the closest ICAO for a given visitor location and lack of forecast weather information for a given location were also considerations when determining the viability of an existing module.

Review of other projects:

Comments

asifnoor’s picture

Status: Needs review » Needs work

Manual review

1. Use 6.x-1.x branch instead of master for development. Check Release naming conventions
2. use a package name in your .info file to keep separation of your module with others
3. use check_plain function while retrieve and storing data from xml
4. its best you use an template file if there is lot of html and styling required instead of writing everything in the theme function.
5. in some of your sql queries you have used %d for the placeholder zipcode in single quotes and some places you did not. Please maintain consistency.

jlopez’s picture

Status: Needs work » Needs review

The changes that you outlined have been completed and the updated code has been pushed to the 6.x-1.x branch.

jlopez’s picture

bump

darrell_ulm’s picture

Status: Needs review » Needs work
StatusFileSize
new48.47 KB

There were many coding standard issues with this code.

Please see the attached file.

Also read these and follow the coding standards.

http://drupal.org/coding-standards
http://drupal.org/node/1354

jlopez’s picture

Status: Needs work » Needs review

Corrected all issues identified in the attached Review.txt file and ran a clean pareview.

bart.hanssens’s picture

Status: Needs review » Needs work

Hi,

nice module, a few suggestions though

  • instead of a long list of INSERT's in _dog_weather_fill_icao_table(), the data could be in a separate CSV file, this will reduce the size of the module (and perhaps use drupal_write_record instead of db_query("INSERT...")
  • is there a reason for _dog_weather_truncate (is round not precise enough ?)
bart.hanssens’s picture

In addition:

  • you may want to use t() in the tpl.php files, to allow the labels like Day, Night, High, Low... to be translated (e.g. in Spanish)
  • is the module limited to US cities ? if it is not limited, have you checked what happens in dog_weather_forecast_page(), $pos = strrpos($account->state, "-"); when a non-US country (without two-character State) is selected, e.g. France Nice ?
  • if it is limited to US cities, then why are the coordinates of all the other stations added to the database?
  • most non-US citizens use degree Celsius instead of Fahrenheit, and kilometer per hour instead of miles per hour, so it would be nice to make these units available as an option
  • url's in _dog_weather_get_current_observations() and _dog_weather_get_latitude_longitude() are hard-coded, would be nice to be able to change them in an admin page
jlopez’s picture

Status: Needs work » Needs review

Thank you for the feedback and taking the time to review my code.

I moved the ICAO location data from the .install file to a separate .csv file. I attempted to use drupal_write_record() to insert records into the database table but ran into issues. After debugging and performing some research, I found that I could not get away with using drupal_write_record() in the *.install file because certain data structures required by the function are not available at the time that hook_install() is triggered. I reverted back to an INSERT but .install looks much cleaner.

The round() function is precise enough but it doesn't do truncation. So I used floor and ceil to truncate but they don't have a precision capability so I had to adjust for precision.

I made the modifications to tpl.php files to use t() around all labels.

Right now the module is designed for the US only. I determine the closest ICAO to your location based on city, state or zip code. I currently don't include the same capability outside the US, so I stripped out ICAO's from the locations table for non-US stations.

Finally, I created an admin page as you suggested and now include the ability to more easily change URL's.

Thanks again!

jlopez’s picture

Priority: Normal » Critical
patrickd’s picture

Sorry for the delay! :(
We do really need more hands in the application queue and highly recommend to get a review bonus so we can come back to your application sooner.

klausi’s picture

Priority: Critical » Normal
Status: Needs review » Needs work
StatusFileSize
new5.67 KB

Sorry for the delay, but you have not listed any reviews of other project applications in your issue summary as strongly recommended in the application documentation.

Review of the 6.x-1.x branch:

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Get a review bonus and we will come back to your application sooner.

manual review:

  1. project page is too short, see http://drupal.org/node/997024
  2. dog_weather_schema(): why do you have to store data in Fahrenheit and Celsius? Couldn't you just store one value and calculate the other?
  3. "'access arguments' => user_access('access weather forecast'),": wrong usage of the hook_menu() API, you should just pass the permission string in an array.
  4. "GLOBAL $user;": the global keyword should be all lower case.
  5. "/* ELIPSE RADIUS ON X AXIS */": inline comments should use "//" comment style and should be proper sentences with standard capitalization. See http://drupal.org/node/1354#inline
  6. "'#title' => 'City, State or Zip',": all user facing text must run through t() for translation, please check all your strings.
jlopez’s picture

Status: Needs work » Needs review

Thank you for the review.

I made the necessary changes that you outlined under manual review except for removing the data stored under the two different units of measure. I receive all information provided through both noaa.gov interfaces and store them with future plans (next release) to make use of them.

I am not sure why Coder and Drupal Code Sniffer identified additional issues as I have been using the two applications to verify my code and they have both come back clean. I am also not sure why two files were listed in the attached results as the issues that were identified had already be taken care of some months ago and committed. I did verify that they were in fact made some months ago and recommitted to cover my bases.

I will be working towards doing my own reviews of other projects shortly (just have to get up to speed on the process).

jlopez’s picture

Issue summary: View changes

changed git statement to point to 6.x-1.x branch.

jlopez’s picture

Issue summary: View changes

Working on review bonus.

avpaderno’s picture

Priority: Normal » Critical
klausi’s picture

Priority: Critical » Normal
Status: Needs review » Needs work
StatusFileSize
new2.1 KB

Review of the 6.x-1.x branch:

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.

manual review:

  1. dog_weather_init(): so your module depends on the dogzville theme? Please add that requirement to the README file or move the CSS into the module.
  2. dog_weather_forecast_page(): the permission 'administrator users' does not exist, do you mean 'administer users'?
  3. dog_weather_forecast_page(): where does $user->dogzville['owner'] come from? Same for $account->zipcode.
  4. "variable_get('dog_weather_observations_url', 'http://www.nws.noaa.gov/xml/current_obs/all_xml.zip');": if your module provides its own variables you should remove them in hook_uninstall().
  5. "'src' => '/files/dogzville/images/button_go.png',": remove all hard coded paths that are not available on other drupal installations.
  6. Make sure to review more other project applications to get a review bonus as strongly recommended in the application documentation.
jlopez’s picture

Status: Needs work » Needs review

Thank you for the review.

I have made all of the changes that you outlined.

I will work on completing the review bonus right away.

webdorado’s picture

Status: Needs review » Needs work

The field icao in the table dog_weather_icao is assigned as Autoincrement primary key. You should not give a value to that field in the insert queries. MySQL will give the value automatically.

klausi’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application.

klausi’s picture

Issue summary: View changes

Working on review bonus.