-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
73 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
-- Remove elite level from users who have expired | ||
update users set elite="" where validity < now(); | ||
update users set elite = "" where validity < now(); | ||
|
||
-- Remove warning flag from users who have made their profiles public and have under 100 flights | ||
-- (LEFT JOIN ensures that users with 0 flights are included) | ||
update users LEFT JOIN ( | ||
select uid from flights group by uid having count(*) < 100 | ||
select uid from flights group by uid having count(*) < 100 | ||
) as nice_users | ||
on (users.uid = nice_users.uid) | ||
set elite="" where elite="X" and public != 'N' and users.uid!= 1; | ||
set elite = "" where elite="X" and public != 'N' and users.uid ! = 1; | ||
|
||
-- Set warning flag for non-elite users with >=100 flights | ||
update users JOIN ( | ||
select uid from flights group by uid having count(*) >= 100 | ||
select uid from flights group by uid having count(*) >= 100 | ||
) as naughty_users | ||
on (users.uid = naughty_users.uid) | ||
set elite="X" where elite="" and users.uid!= 1; | ||
set elite = "X" where elite = "" and users.uid != 1; | ||
|
||
-- Set warning flag for non-elite users with hidden profiles | ||
update users set elite="X" where elite="" and uid!= 1 and public="N"; | ||
update users set elite = "X" where elite = "" and uid != 1 and public = "N"; | ||
|
||
-- Summarize | ||
select elite,public,count(*) from users group by elite,public; | ||
select elite, public, count(*) from users group by elite, public; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
SELECT apid, name, iata, airports.icao FROM airports | ||
INNER JOIN (SELECT icao FROM airports | ||
GROUP BY icao HAVING count(icao) > 1) dup ON airports.icao = dup.icao | ||
INNER JOIN ( | ||
SELECT icao FROM airports | ||
GROUP BY icao HAVING count(icao) > 1 | ||
) dup ON airports.icao = dup.icao | ||
WHERE airports.icao != "" | ||
ORDER BY icao; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
-- | ||
-- Refresh the "demo" flights shown when logging in | ||
-- | ||
delete from flights where uid=1; | ||
delete from flights where uid = 1; | ||
|
||
-- Select every other flight | ||
-- Note: uid forced to 0 (demo), trid forced to NULL (not in trip) | ||
insert into flights(uid,src_apid,src_date,src_time,dst_apid,distance,code,seat,seat_type,class,reason,plid,alid,trid,duration,registration,note,upd_time,opp,mode) select 1,src_apid,src_date,src_time,dst_apid,distance,code,seat,seat_type,class,reason,plid,alid,null,duration,registration,note,upd_time,opp,mode from flights where fid % 2 = 0 and date_sub(now(), interval 3 day) < upd_time order by upd_time desc limit 200; | ||
insert into flights(uid,src_apid,src_date,src_time,dst_apid,distance,code,seat,seat_type,class,reason,plid,alid,trid,duration,registration,note,upd_time,opp,mode) | ||
select 1,src_apid,src_date,src_time,dst_apid,distance,code,seat,seat_type,class,reason,plid,alid,null,duration,registration,note,upd_time,opp,mode | ||
from flights | ||
where fid % 2 = 0 and date_sub(now(), interval 3 day) < upd_time | ||
order by upd_time desc | ||
limit 200; | ||
|
||
select now(), count(*) from flights where uid=1; |