How to find out if ANY user has posted today

bryce alvord Posted in Component Development 1 month ago

How would I find out if any user at all has posted specifically on the Wall today? If this means writing a stored proc I am fine with that but could use some help understanding the schema and how to call a proc from the code. Thanks!

Replies
us Bansh33 - Replied 4 weeks ago

sure, whatever you need Arsalan, just send me an email at rishi[at]rishisco.de

Bryce, you can also feel free to email me if you need further help getting your weekly newsletter setup.

us Bryce alvord Replied 4 weeks ago

Yeah I can look at that. What are the problem areas that you have right now that you feel need to be fixed?

German Arsalan Shah Replied 4 weeks ago

That's good to find our that you are database experts, i'll need your help to optimize the current database scheme for OSSN, it would be great if any of you or both look into the current database scheme (keys, indexes etc) and provide suggestions (with a fix code)

us Bryce alvord Replied 4 weeks ago

No I understand procedures just fine and really the newsletter is an evolution of what started this question so I think now I'm going to pursue creating that and will likely have a new few questions since I have never actually created a cron job.

us Bansh33 - Replied 4 weeks ago

@Bryce, it occurred to me that you may have been asking about creating a stored proc in MySQL rather than OSSN, as I interpreted it. If that's what you want to do (maybe as an alias for the select query I posted), this should help you: http://www.mysqltutorial.org/getting-started-with-mysql-stored-procedures.aspx

once your procedure is created in your database you can call it like any other sql query.

us Bansh33 - Replied 4 weeks ago

if you want to create a weekly newsletter, I think you would HAVE to do it in a cron job. As far as I know (correct me if I'm wrong, Arsalan), there's no way to create a stored cron-like process within OSSN.

I know Arsalan doesn't like me suggesting SQL queries ;) but since you seem to know what you're doing, Bryce, I'd suggest creating a cron job that connects to your db server externally (on a weekly basis or however often) and then runs the query I posted in my initial answer. There's no reason your crontab can't run a php script from command line, but I don't think there's any way to do this from WITHIN the actual ossn framework.

us Bryce alvord Replied 4 weeks ago

Guys, I'm not at all frightened by sql and I know the discussion is now just for anyone in general but sql is what I do for my profession as a backend developer. That's why I was wondering if there was a way to create a select sp to do what I need and how to call that sp from within the ossn framework. The answers given are fine and ultimately I am leaning towards creating a cron job but knowing how ossn calls procs was really the question or how to easily obtain if any user has posted in that day. I'm kind of wanting to develop a newsletter component at this point maybe for a weekly distribution or something.

us Bansh33 - Replied 4 weeks ago

@Arsalan, on a side note, it might be easier for "non-expert" developers to understand the database schema better if you guys would switch to using the predefined MySQL timestamp fields instead of storing a unix timestamp as an integer... like practically EVERY other MySQL/PHP application does. It makes readability A LOT easier and the OP probably wouldn't have even needed to ask the question if he could see the timestamps (date_created in this case) in a format that's easily readable for humans.

us Bansh33 - Replied 4 weeks ago

@Arsalan, that's a fair point, and I do understand your hesitation in suggesting that any user run an SQL query directly. However, I would like to point out that what I posted was a SELECT query. As you obviously know, this type of query can ONLY read data, it CANNOT (in any way) modify the database.

While your anecdotal story about a user manually deleting rows and then having trouble certainly does make the point that MODIFYING the ossn database is not a good idea, it really doesn't apply here as we are discussing a SELECT query. To be perfectly honest, I probably wouldn't have even posted a direct SQL solution if the question involved any sort of database modification (as I said in my last post and have repeated here, I DO understand why modifying the database is a bad idea).

German Arsalan Shah Replied 4 weeks ago

@Bansh, yes you are right , further the community answers are public to others who are seeking answers and not all who are seeking answers expert like you. Further there are many other steps which are involved to get a complete object of any post. So my humble request you is to post the recommended way to answer the questions here as your answer will be used by many others. We do appreciate your answers and looking forward for you to contribute to community in recommended way!

@all , Just to high light one of past story (for information of all of others) , one of person delete users manually from database and then started complaining that the user counts based on gender didn't reflect the total users in users table. It won't because he done a user delete query manually which is not equal to the user delete functionality of OSSN.

I am just trying to convey the right way to use the OSSN framework because running sql query is not = to the functionality that is done by OSSN itself, and yes there are many ways to start a any car every way have own methodology. So please use the right way if you don't wanted to things break!