HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Top downloads for period, script help needed

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#109582 (In Topic #21643)
TQ
Avatar

Honoured member

Hi All,

I would like to make a list of the most popular download from the past week but I don't know how to draw the date range from in the db and get a reliable number of downloads.

This is what I have so far..

Code

SELECT text_original
FROM ocp_translate
LEFT JOIN ocp_download_downloads
ON ocp_translate.id = ocp_download_downloads.name
WHERE ocp_download_downloads.num_downloads > 0
ORDER BY num_downloads DESC
LIMIT 10;
This (obviously) only provides me with a lifetime list as it draws on the number of times an item has been downloaded, could anyone point me in the right direction to date range the list?

TQ
Back to the top
 
Posted
Rating:
#109587
Avatar

OTTOMH…

AND add_date>UNIX_TIMESTAMP()-60*60*24*7


That's assuming you mean downloads added in the last week. If you just want to know what was popular in the week, there's no way to do that right now as we only have the aggregate download figure. You'd need to set up some kind of tracker.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#109591
TQ
Avatar

Honoured member

Chris Graham said

OTTOMH…

AND add_date>UNIX_TIMESTAMP()-60*60*24*7


That's assuming you mean downloads added in the last week. If you just want to know what was popular in the week, there's no way to do that right now as we only have the aggregate download figure. You'd need to set up some kind of tracker.

Hi Chris,

Thanks as always for responding to my enquiry.

Popular in the week (/month whatever) is what I'm after. I'm sort of glad I didn't miss something but disappointed I cant do it directly.

The goal is to vamp-up my 'Download' email (which is letting me down quite badly right now) with pertinent/dynamic information as it's the only one that members can't opt-out of. I have a lot to do in this area as it is neither attractive or mobile friendly.

Any suggestions on the 'Tracker' approch? I'll take anything as a starting point!

Thanks

TQ
Back to the top
 
Posted
Rating:
#109595
Avatar

I just realised actually we do do fine-grained logging of downloads, and I'd forgotten.

The SQL runs, haven't tested it works right…

SELECT text_original
FROM ocp_translate t
LEFT JOIN ocp_download_downloads d
ON t.id = d.name
WHERE d.num_downloads > 0
ORDER BY (SELECT COUNT(*) FROM ocp_download_logging l WHERE l.id=d.id AND date_and_time>UNIX_TIMESTAMP()-60*60*24*7) DESC
LIMIT 10


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#109599
TQ
Avatar

Honoured member

That is useful in so may ways, thank you Chris.

But ..

Wait a minute ...

You forgot! ...

I thought you remembered every one of the 10's of thousands of lines of code that is OCPortal ...:)

Seriously, that is really useful to me and something I'd never have thought of or discovered.

You help, as always, is very much appreciated.

Thank You

TQ
Back to the top
 
Posted
Rating:
#109601
Avatar

More like 500k lines nowadays ;). I am definitely getting more forgetful about things.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#109603
TQ
Avatar

Honoured member

Wow

Fact: The shuttle's primary flight software contains about 400,000 lines of code.

TQ
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: