Changeset 393 for veekun/trunk/lib/Vee/Schema
- Timestamp:
- 12/29/07 21:29:06 (2 years ago)
- Location:
- veekun/trunk/lib/Vee/Schema
- Files:
-
- 1 added
- 3 modified
-
LocationEncounters.pm (modified) (2 diffs)
-
LocationSections.pm (added)
-
Locations.pm (modified) (1 diff)
-
Pokemon.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
veekun/trunk/lib/Vee/Schema/LocationEncounters.pm
r350 r393 13 13 __PACKAGE__->load_components('Core'); 14 14 __PACKAGE__->table('location_encounters'); 15 __PACKAGE__->add_columns(qw/ location_id rarity version section pokemon_id method min_level max_level /);16 __PACKAGE__->set_primary_key(qw/ location_id rarity /);15 __PACKAGE__->add_columns(qw/ section_id rarity version pokemon_id method min_level max_level /); 16 __PACKAGE__->set_primary_key(qw/ section_id rarity /); 17 17 18 18 __PACKAGE__->belongs_to(pokemon => 'Vee::Schema::Pokemon', 'pokemon_id'); 19 __PACKAGE__->belongs_to( location => 'Vee::Schema::Locations', 'location_id');19 __PACKAGE__->belongs_to(section => 'Vee::Schema::LocationSections', 'section_id'); 20 20 21 21 =head1 METHODS … … 30 30 sub level { 31 31 my ($self) = @_; 32 32 33 33 my $level; 34 34 my ($min, $max) = ($self->min_level, $self->max_level); -
veekun/trunk/lib/Vee/Schema/Locations.pm
r350 r393 16 16 __PACKAGE__->set_primary_key('id'); 17 17 18 __PACKAGE__->has_many( encounters => 'Vee::Schema::LocationEncounters', 'location_id');18 __PACKAGE__->has_many(sections => 'Vee::Schema::LocationSections', 'location_id'); 19 19 20 20 =head1 SEE ALSO -
veekun/trunk/lib/Vee/Schema/Pokemon.pm
r389 r393 162 162 my @encounter_sets; 163 163 164 my $ sections_rs = $self->encounters_rs( undef, {165 group_by => ' location_id, section',164 my $grouped_sections_rs = $self->encounters_rs( undef, { 165 group_by => 'section_id', 166 166 } ); 167 167 168 while (my $ section = $sections_rs->next) {169 my $encounters_rs = $ section->location->encounters_rs( {168 while (my $enc_section = $grouped_sections_rs->next) { 169 my $encounters_rs = $enc_section->section->encounters_rs( { 170 170 version => 'diamond', 171 section => $section->section,171 section_id => $enc_section->section->id, 172 172 } ); 173 173
