INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 5 6 7 8 [9]   Go Down

Author Topic: Expression functions [HELP WANTED]  (Read 62473 times)

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42325
  • Shoes gone again!
Re: Expression functions [HELP WANTED]
« Reply #400 on: October 05, 2021, 08:16:58 am »

Logged
Matt Ashland, JRiver Media Center

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Expression functions [HELP WANTED]
« Reply #401 on: November 21, 2021, 06:49:38 am »

Using Save() / SaveAdd() seems to break ListMix

example:

Code: [Select]
Save(0, v_2021[filekey])/
Save(0, v_2020[filekey])
DATES:
ListMix(FormatDate([L1],yyyy),,44265;44520)

COUNT YEAR 2021:
Load(v_2021[filekey])

COUNT YEAR 2020:
Load(v_2020[filekey])

2020 doesn't exist in list but v_2020[filekey] is still increased on every cycle (both variables are)
ListMix(IfCase(FormatDate([L1],yyyy),2,2021,SaveAdd(v_2021[filekey], 1),2020, SaveAdd(v_2020[filekey],1)),,44265;44520)

COUNT 2021:
Load(v_2021[filekey])

COUNT 2020:
Load(v_2020[filekey])

on similar list mix WAS 2020 is not printed when Save function is not used
ListMix(IfCase(FormatDate([L1],yyyy),2,2021,WAS 2021,2020, WAS 2020),,44265;44520)
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2567
Re: Expression functions [HELP WANTED]
« Reply #402 on: November 21, 2021, 11:13:55 am »

Yeah, ListMix is finicky.
Perhaps you can get the counts you want using ListFilter to get just the items between 2 values:

listcount(listfilter([myList],0,min, max))
Code: [Select]
2020 = listcount(listfilter(44265;44520,0,43831,44197))
2021 = listcount(listfilter(44265;44520,0,44197,44562))

Regarding the ListMix issue you point out - it has to do with the order in which listmix/listmix2 processes the expression. The normal way to process any EL expression is to resolve it from the inside out; that is, process the inner sub-expressions and functions first, and work your way out with the results as you get them. So ListMix() is resolving the inner functions (saveAdd) before actually running the ListMix() function. The IfCase and FormatDate execution is delayed since they depend on [L1], which is only assigned after the ListMix unwrapping.

The difference between ListMix and ListMix2 is the order on which the execution steps are done - functions-first vs unwrapping-first. But there are other implementation details which I don't know about but can see the effects - neither implementation is "pure", they both seem to try to optimize execution with some side effects on some cases, like the one you found. I think Matt has been adding some function exceptions to ListMix(), in that those functions get to be executed after unwrapping instead of before. In that case, adding SaveAdd() to that list would solve your problem... however I don't think this is the right approach.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Expression functions [HELP WANTED]
« Reply #403 on: November 21, 2021, 11:40:55 am »

Yeah, ListMix is finicky.
Perhaps you can get the counts you want using ListFilter to get just the items between 2 values:

listcount(listfilter([myList],0,min, max))
Code: [Select]
2020 = listcount(listfilter(44265;44520,0,43831,44197))
2021 = listcount(listfilter(44265;44520,0,44197,44562))

Regarding the ListMix issue you point out - it has to do with the order in which listmix/listmix2 processes the expression. The normal way to process any EL expression is to resolve it from the inside out; that is, process the inner sub-expressions and functions first, and work your way out with the results as you get them. So ListMix() is resolving the inner functions (saveAdd) before actually running the ListMix() function. The IfCase and FormatDate execution is delayed since they depend on [L1], which is only assigned after the ListMix unwrapping.

The difference between ListMix and ListMix2 is the order on which the execution steps are done - functions-first vs unwrapping-first. But there are other implementation details which I don't know about but can see the effects - neither implementation is "pure", they both seem to try to optimize execution with some side effects on some cases, like the one you found. I think Matt has been adding some function exceptions to ListMix(), in that those functions get to be executed after unwrapping instead of before. In that case, adding SaveAdd() to that list would solve your problem... however I don't think this is the right approach.
Yup. For your suggestion: I was trying to achieve that parsing list is done only once instead of going through list multiple times. Don't know how fast it would be to take ListCount() after every year handling and ListLimit() already handled items out...
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2567
Re: Expression functions [HELP WANTED]
« Reply #404 on: November 21, 2021, 11:56:52 am »

It makes me wonder if things like this wouldn't be best done on a timer; ie, everyday at 4am a script would run, compiling all stats and storing the counts and tops in some field that would then be used in Views. Is it that important to have an up-to-the-minute number of plays for each track since forever? And things like the playcount for past years won't ever change anyway. Updating once a day seems fine for this use case.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Expression functions [HELP WANTED]
« Reply #405 on: November 21, 2021, 12:19:56 pm »

That would be great. If only someone had time to create such thing... Perhaps this kind of stuff could be done with MCUtils scriptor which could then be started with timer. Dunno if it only works for selected files or is possibly select files from scriptor.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Expression functions [HELP WANTED]
« Reply #406 on: November 22, 2021, 12:14:27 pm »

I think ListReplace(list, index, newItem) to replace one item based on index could be useful. At least i didn't notice that existing list functions support this. One could use ListCount() and ListLimit() I guess to replace item but one clean function would be nice.
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2567
Re: Expression functions [HELP WANTED]
« Reply #407 on: November 23, 2021, 06:25:11 pm »

That would be great. If only someone had time to create such thing... Perhaps this kind of stuff could be done with MCUtils scriptor which could then be started with timer. Dunno if it only works for selected files or is possibly select files from scriptor.

You have an IM  ;D
Logged
Pages: 1 ... 5 6 7 8 [9]   Go Up