Strange bug related to counting published videos in a category

6 views
Skip to first unread message

Felix Schwarz

unread,
Jun 7, 2011, 5:40:41 PM6/7/11
to mediacore-...@googlegroups.com
Hi,

I just noticed a strange bug:
When I upload a new video (public or admin, doesn't matter) and assign
it to a category afterwards, category.media_count_published is not updated.

However if the video was already there (since MediaCore was restarted
last time), category changes affect 'media_count_published' immediately.

This is bad because it means that empty categories never get displayed
(as 'media_count_published' stays 0). However when a category is
selected, all videos (new+old) in that category are shown correctly.

Any hints how to debug this?
fs

Nathan Wright

unread,
Jun 9, 2011, 8:28:33 PM6/9/11
to mediacore-...@googlegroups.com
Hi Felix,

I just pushed a patch for this to github:

The issue was that the media_count_published subquery is generated once, when the application starts up, so media items had to be published before the application was started in order to be included in the count. Now we're relying on CURRENT_TIMESTAMP from the DB.

Glad to finally have this bug resolved! Took a few tries, that's for sure.

Cheers,
Nathan

-- 
Nathan Wright
CTO, MediaCore
--
You received this message because you are subscribed to the Google
Groups "MediaCore Developers" group.

You may also be interested in our facebook:
http://www.facebook.com/pages/MediaCore-Video-and-Podcasting-Platform/296505876256

You may follow us on twitter:
http://twitter.com/simplestation

To post to this group, send email to
mediacore-...@googlegroups.com
To unsubscribe from this group, send email to
mediacore-develo...@googlegroups.com

For more options, visit this group at
http://groups.google.com/group/mediacore-developers?hl=en?hl=en

Felix Schwarz

unread,
Jun 10, 2011, 2:42:04 AM6/10/11
to mediacore-...@googlegroups.com

Am 10.06.2011 02:28, schrieb Nathan Wright:
> I just pushed a patch for this to github:
> https://github.com/mediacore/mediacore/commit/8762e65f89205fb718b21cdc76b8023098a94370

Cool, thanks.

The only thing I'm sorry about is that you found the problem two weeks
before my and I spent some cycles again on that because the fix was not
in git.

fs

cha

unread,
Jan 13, 2013, 10:09:39 PM1/13/13
to mediacore-...@googlegroups.com
Good day!

I really need your help coz we used mediacore ce as video platform for our thesis.
I need to display all of the categories while the user played the media.

For example, in the default site, the user will watch a video, then there is the category list on the right but it only list the category on where did the video came from. My problem is on how to list all of the categories in the right. 

Please help me.. and i also saw this from the developer's guide: CategoriesController.index(*args**kwargs)
I can't understand this well. Where am i going to put this? and am i going to create another database for this??

please.please.please help me. thank you so much.

Felix Schwarz

unread,
Jan 15, 2013, 6:43:09 AM1/15/13
to mediacore-...@googlegroups.com
Hi Cha,

Am 14.01.2013 04:09, schrieb cha:
> For example, in the default site, the user will watch a video, then there is
> the category list on the right but it only list the category on where did the
> video came from. My problem is on how to list all of the categories in the right.

You should then build a custom query using Categories.query.filter(...) in
MediaController.view and pass the result to the view template.

> Please help me.. and i also saw this from the developer's
> guide: CategoriesController.index(*args, **kwargs)
> I can't understand this well. Where am i going to put this?

As I already wrote in the forum I suspect you mean the JSON API. That is very
likely the wrong tool for your issue at hand. A relatively simple SQLAlchemy
query will do the trick.

fs

PS: In the future please create a new thread instead of replying to an
existing email and think about a meaningful subject. If you just reply you'll
mess up the archive a bit.

Chalie Delligos

unread,
Jan 24, 2013, 5:51:57 AM1/24/13
to mediacore-...@googlegroups.com
good day!

i would like to ask on how to create the Categories.query.filter (...)
and where I am going to put that one?

Do I need to create another database for it?
sorry for the disturbances but I am not a good programmer and I just learned it right now. 

I would like also to ask about the cat_link...  we found it at the view template of the media but we can't trace its code and we can't also trace its database..

thank you so much and hoping for your kind consideration.

Felix Schwarz

unread,
Jan 24, 2013, 6:01:50 AM1/24/13
to mediacore-...@googlegroups.com
Hey Charlie,

Am 24.01.2013 11:51, schrieb Chalie Delligos:
> i would like to ask on how to create the Categories.query.filter (...)
> and where I am going to put that one?
>
> Do I need to create another database for it?

The database is where you store your data. So as you want to display MediaCore
data you have to use the MediaCore database - so no, please don't create a new
database.

"Categories.query.filter(...)" is an SQLAlchemy query, basically a nicely
wrapped SQL query which can return the data.

> sorry for the disturbances but I am not a good programmer and I just learned
> it right now.

Here's a quick list of things you can do to achieve the task.
- Modify the MediaController (view method) so that there is a new variable
passed to the template. Choose a nice name and use any value (for example a
string with your name). Display that variable somewhere in the template.
(So you know how to pass data to the template.)
- If you want to have a flat list of categories, you need to think about how
to flatten the category tree. In the simplest case you could just display
them ordered by name without thinking about any nesting (sub-categories).
for example "Category.query.order_by(Category.name).all()"
- Query the categories in the view() method and pass it to the template.
Modify the template so it is displayed nicely.

That's just a very brief list, so I expect you need to read up on some points
and likely talk back to your teacher if you need more help.

Also I suspect MediaCore is quite a challenging task for a non-developer as it
is quite complex (because web video is complex).

> I would like also to ask about the cat_link... we found it at the view
> template of the media but we can't trace its code and we can't also trace its
> database..

Check the view.html template. It's a Genshi template function.

fs

Chalie Delligos

unread,
Jan 24, 2013, 6:36:57 AM1/24/13
to mediacore-...@googlegroups.com
oh.. sorry for my wrong info..
what i mean is "do we need to create a new table for displaying all of the categories?"

Felix Schwarz

unread,
Jan 24, 2013, 6:40:07 AM1/24/13
to mediacore-...@googlegroups.com
No. You want to *access* existing data so you don't need to change the way it
is stored.

fs

Chalie Delligos

unread,
Jan 24, 2013, 6:42:35 AM1/24/13
to mediacore-...@googlegroups.com
thank you.. I still have a lot of questions soon..
Reply all
Reply to author
Forward
0 new messages