Preventing Users from Seeing Old Data MySQL/iOS -


i'm using app allows users upload , download pics. similar snapchat can view pics of follow. after 24 hrs these pics moved archive table users no longer able see them. i'm accomplishing aspect mysql partitions.

however, on client side need continuously update mysql query date of last gotten row photos table. store date on ios app. becomes problematic if users logs out , allows else log in. have clear data , have not reference point either user now.

i have solution around , want know how feasible is. create trigger run each time user retrieved photos. update column on users table hold last date viewed. way when user logs in have reference last date viewed. idea? i'm open suggestions on how better approach seeing how need save pictures instead of deleting them.

*note partitions work because need ensure photos last minimum of 24 hrs photos end lasting more 24hrs providing possibility users can still see photos

photos table

*id: binary 16

*users_id: foreign: binary 16

*filename: varchar

*created_at: datetime

the photos stored on amazon s3

add column

visible int not null 

set visible 1 on upload. put now() created_at datetime.

create event see below:

http://www.mysqltutorial.org/mysql-triggers/working-mysql-scheduled-event/

have event run daily or every 6 hours, whatever. can cron task instead.

when thing runs sets visible 0 on 1 day old.

when users see elses profile pictures see visible=1 pictures.

the guy posted picture sees pictures.

so automated , can asleep @ switch.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -