comparison scan.pl @ 36:704d76b67670

fixed the island cache problem
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Sat, 11 Oct 2008 05:21:06 +0800
parents 51a35c3d057e
children 5849b6fdc76c
comparison
equal deleted inserted replaced
35:d9d4aedc9e03 36:704d76b67670
26 $c->update(); 26 $c->update();
27 } else { 27 } else {
28 Ikariam::Cities->insert($city); 28 Ikariam::Cities->insert($city);
29 } 29 }
30 30
31 printf("city %d %s saved\n", $city->{cityId}, $city->{cityname}); 31 printf("city %s (%d) at island (%d) saved\n",
32 $city->{cityname},
33 $city->{cityId},
34 $island);
35
32 my $user = Ikariam::User->retrieve($city->{user}); 36 my $user = Ikariam::User->retrieve($city->{user});
33 if(!defined($user) || $user->time le (time - 60*60*12)) { 37 if(!defined($user) || $user->time le (time - 60*60*1)) {
34 # Download user profile. 38 # Download user profile.
35 foreach my $x (qw/score army_score_main trader_score_secondary/) 39 foreach my $x (qw/score army_score_main trader_score_secondary/)
36 { 40 {
37 my $users = $::i->viewScore($x, $city->{owner}, 0); 41 my $users = $::i->viewScore($x, $city->{owner}, 0);
38 saveUser($users); 42 saveUser($users);
97 } else { 101 } else {
98 $island = Ikariam::Island->insert($h_island); 102 $island = Ikariam::Island->insert($h_island);
99 } 103 }
100 104
101 # scanning the island 105 # scanning the island
102 if($island->time le (time - 60*60*12 )) 106 if($island->time le (time - 60*60*6))
103 { 107 {
104 my @cities = $i->viewIsland($h_island->{id}); 108 my @cities = $i->viewIsland($h_island->{id});
105 saveCities($h_island->{id}, @cities); 109 saveCities($h_island->{id}, @cities);
110
111 $island->set('time', time);
106 } 112 }
113 $island->update();
107 114
108 $island->set('time', time);
109 $island->update();
110 } 115 }
111 $i->logout; 116 $i->logout;
112 # $i->getCityInfo(); 117 # $i->getCityInfo();