You are on page 1of 8

<b>Step 1</b>:

Script hit and got following details :


Latitude: 22.727834-- Longitude: 75.887417
Datetime: 2011-02-18 16:09:09
UserId: 383
device_token:12eeea43eea7ee575e8c9cee952e0043fd74b830430d8951a37ee8fa8b605e66
<b>Step 2</b>:
Now following query check distance of 0.5 Miles :
SELECT branch_id,(3958*3.1415926*sqrt((latitude-'22.727834')*(latitude-'22.72783
4') +
cos(latitude/57.29578)*cos('22.727834'/5
7.29578)*(longitude-'75.887417')*(longitude-'75.887417'))/180) as distance from
ma_advertiser_branches
WHERE
(3958*3.1415926*sqrt((latitude-'22.72783
4')*(latitude-'22.727834') +
cos(latitude/57.29578)*cos('22.727834'/5
7.29578)*(longitude-'75.887417')*(longitude-'75.887417'))/180) <= 0.5
order by distance ASC
<b>Step 2</b>:
Now following query check distance of 0.5 Miles :
SELECT branch_id,(3958*3.1415926*sqrt((latitude-'22.727834')*(latitude-'22.72783
4') +
cos(latitude/57.29578)*cos('22.727834'/5
7.29578)*(longitude-'75.887417')*(longitude-'75.887417'))/180) as distance from
ma_advertiser_branches
WHERE
(3958*3.1415926*sqrt((latitude-'22.72783
4')*(latitude-'22.727834') +
cos(latitude/57.29578)*cos('22.727834'/5
7.29578)*(longitude-'75.887417')*(longitude-'75.887417'))/180) <= 0.5
order by distance ASC
<b>Step 3</b>:
Now If any branch seleted then following query select package_id_fk from ma_pac
kage_branches corresponding to branch_id:
SELECT package_id_fk FROM ma_package_branches
WHERE
branch_id_fk =
42
<b>Step 4</b>:
Now If package_id seleted then following query select advertisementId, geograp
hicalId of package and package type from ma_package corresponding to package_id
and check expiry date of package:
SELECT advmnt_id_fk,package_id, geographical_id_fk,package_type
FROM
ma_pack
age
WHERE
package
_id ='142'
AND
date_to
>= '2011-02-18'
AND dat
e_from <= '2011-02-18'
<b>Step 4</b>:
Now If package_id seleted then following query select advertisementId, geograp
hicalId of package and package type from ma_package corresponding to package_id
and check expiry date of package:
SELECT advmnt_id_fk,package_id, geographical_id_fk,package_type
FROM
ma_pack
age
WHERE
package
_id ='143'
AND
date_to
>= '2011-02-18'
AND dat
e_from <= '2011-02-18'
<b>Step 4</b>:
Now If package_id seleted then following query select advertisementId, geograp
hicalId of package and package type from ma_package corresponding to package_id
and check expiry date of package:
SELECT advmnt_id_fk,package_id, geographical_id_fk,package_type
FROM
ma_pack
age
WHERE
package
_id ='144'
AND
date_to
>= '2011-02-18'
AND dat
e_from <= '2011-02-18'
<b>Step 4</b>:
Now If package_id seleted then following query select advertisementId, geograp
hicalId of package and package type from ma_package corresponding to package_id
and check expiry date of package:
SELECT advmnt_id_fk,package_id, geographical_id_fk,package_type
FROM
ma_pack
age
WHERE
package
_id ='158'
AND
date_to
>= '2011-02-18'
AND dat
e_from <= '2011-02-18'
<b>Step 4</b>:
Now If package_id seleted then following query select advertisementId, geograp
hicalId of package and package type from ma_package corresponding to package_id
and check expiry date of package:
SELECT advmnt_id_fk,package_id, geographical_id_fk,package_type
FROM
ma_pack
age
WHERE
package
_id ='159'
AND
date_to
>= '2011-02-18'
AND dat
e_from <= '2011-02-18'
<b>Step 4</b>:
Now If package_id seleted then following query select advertisementId, geograp
hicalId of package and package type from ma_package corresponding to package_id
and check expiry date of package:
SELECT advmnt_id_fk,package_id, geographical_id_fk,package_type
FROM
ma_pack
age
WHERE
package
_id ='160'
AND
date_to
>= '2011-02-18'
AND dat
e_from <= '2011-02-18'
<b>Step 3</b>:
Now If any branch seleted then following query select package_id_fk from ma_pac
kage_branches corresponding to branch_id:
SELECT package_id_fk FROM ma_package_branches
WHERE
branch_id_fk =
45
<b>Step 4</b>:
Now If package_id seleted then following query select advertisementId, geograp
hicalId of package and package type from ma_package corresponding to package_id
and check expiry date of package:
SELECT advmnt_id_fk,package_id, geographical_id_fk,package_type
FROM
ma_pack
age
WHERE
package
_id ='165'
AND
date_to
>= '2011-02-18'
AND dat
e_from <= '2011-02-18'
<b>Step 5</b>:
If package_type is broadcast then following query select UserId and check acti
ve status of user:
SELECT
ma_mobile_holder.mobile_holder_id
FROM
ma_mobile_holder
INNER JOIN
ma_users
ON
ma_mobile_holder.user_id_fk = ma_users.user_id
WHERE
ma_users.user_id = '383'
AND
ma_users.active_status = 1
<b>Step 6</b>:
Now following query check disable time of user
SELECT mobile_holder_id FROM ma_mobile_holder
WHERE
mobile_holder_id = 304
AND
(disable_start_time > '2011-02-18 16:09:09'
OR
disable_end_time < '2011-02-18 16:09:09'
OR
disable_start_time = '0000-00-00 00:00:00')

<b>Step 7</b>:
Now following query check that notification is already sent for the day or not
SELECT * from ma_location_notification
WHERE
mobile_holder_id_fk = '304'
AND
package_id_fk = '165'
AND
date = '2011-02-18'
<b>Step 8</b>:
Now following query select advertisement and advertiser detail in order to sen
d a notification
SELECT advmnt_id,adv_id_fk,advmnt_title,advmnt_desc
FROM ma_advertisement
WHERE advmnt_id = 131
<b>Step 3</b>:
Now If any branch seleted then following query select package_id_fk from ma_pac
kage_branches corresponding to branch_id:
SELECT package_id_fk FROM ma_package_branches
WHERE
branch_id_fk =
70
<b>Step 4</b>:
Now If package_id seleted then following query select advertisementId, geograp
hicalId of package and package type from ma_package corresponding to package_id
and check expiry date of package:
SELECT advmnt_id_fk,package_id, geographical_id_fk,package_type
FROM
ma_pack
age
WHERE
package
_id ='199'
AND
date_to
>= '2011-02-18'
AND dat
e_from <= '2011-02-18'
<b>Step 5</b>:
If package_type is broadcast then following query select UserId and check acti
ve status of user:
SELECT
ma_mobile_holder.mobile_holder_id
FROM
ma_mobile_holder
INNER JOIN
ma_users
ON
ma_mobile_holder.user_id_fk = ma_users.user_id
WHERE
ma_users.user_id = '383'
AND
ma_users.active_status = 1
<b>Step 6</b>:
Now following query check disable time of user
SELECT mobile_holder_id FROM ma_mobile_holder
WHERE
mobile_holder_id = 304
AND
(disable_start_time > '2011-02-18 16:09:09'
OR
disable_end_time < '2011-02-18 16:09:09'
OR
disable_start_time = '0000-00-00 00:00:00')

<b>Step 7</b>:
Now following query check that notification is already sent for the day or not
SELECT * from ma_location_notification
WHERE
mobile_holder_id_fk = '304'
AND
package_id_fk = '199'
AND
date = '2011-02-18'
<b>Step 8</b>:
Now following query select advertisement and advertiser detail in order to sen
d a notification
SELECT advmnt_id,adv_id_fk,advmnt_title,advmnt_desc
FROM ma_advertisement
WHERE advmnt_id = 142
<b>Step 4</b>:
Now If package_id seleted then following query select advertisementId, geograp
hicalId of package and package type from ma_package corresponding to package_id
and check expiry date of package:
SELECT advmnt_id_fk,package_id, geographical_id_fk,package_type
FROM
ma_pack
age
WHERE
package
_id ='200'
AND
date_to
>= '2011-02-18'
AND dat
e_from <= '2011-02-18'
<b>Step 5</b>:
If package_type is Zone then following query select UserId and check user zone
:

SELECT mh.mobile_holder_id FROM ma_mobile_holder as mh, ma_users as m


WHERE mh.user_id_fk=m.user_id
AND m.user_id='383'
<b>Step 6</b>:
Now following query check disable time of user
SELECT mobile_holder_id FROM ma_mobile_holder
WHERE
mobile_holder_id = 304
AND
(disable_start_time > '2011-02-18 16:09:09'
OR
disable_end_time < '2011-02-18 16:09:09'
OR
disable_start_time = '0000-00-00 00:00:00')

<b>Step 7</b>:
Now following query check that notification is already sent for the day or not
SELECT * from ma_location_notification
WHERE
mobile_holder_id_fk = '304'
AND
package_id_fk = '200'
AND
date = '2011-02-18'
<b>Step 8</b>:
Now following query select advertisement and advertiser detail in order to sen
d a notification
SELECT advmnt_id,adv_id_fk,advmnt_title,advmnt_desc
FROM ma_advertisement
WHERE advmnt_id = 143

You might also like