symfony1 enums with column aggregation inheritence - doctrine

I have a profile table that saves all profiles for all user.
I have different types of users and want each type of user to have different select options for choosing a certain field.
So both user types can choose how long they want to register for, but the have different options - one can choose 2 years and the other cant.
The schema.yml looks something like this:
UserProfile:
columns:
username:
type: string(255)
notnull: true
unique: false
WriterUserProfile:
inheritance:
type: column_aggregation
extends: UserProfile
columns:
register_time:
type: enum
values:
- 6 months
- 1 year
- 2 years
- Other
default: other
ReaderUserProfile:
inheritance:
type: column_aggregation
extends: UserProfile
columns:
register_time:
type: enum
values:
- 6 months
- 1 year
- Other
default: other
For some reason I am unable to select the '2 year' option - the form gives an 'invalid' error.
Does the '2 years' and 'Other' coincide with eachother because they are both the 3rd option?

Are there other fields which are not common? This one field only not enough cause to use column aggregation. Anyway, if the same field appears in multiple sub-classes than the field should be moved up and field names should be unique among all related classes (UserProfile, WriterUserProfile, ReaderUserProfile in your case).
You can change the options of the choice field in a form:
$choices = array('0' => 'a', '1' => 'b');
$this->getWidget('register_time')->setOption('choices', $choices);
$this->getValidator('register_time')->setOption('choices', array_keys($choices));

Related

Spotfire - KPI of multiple Boolean columns that can limit data

In the data I have there are multiple Boolean columns that categorise each row, for example:
Object
Fruit
Yellow
Round
Chair
FALSE
FALSE
FALSE
Banana
TRUE
TRUE
FALSE
Apple
TRUE
FALSE
TRUE
Ball
FALSE
FALSE
TRUE
I am trying to make a KPI chart that would go alongside a table of this data in which it would have 'Fruit', 'Yellow', & 'Round' as categories and a count of how many are true, so that when you click on them it will mark and limit the data in the table. In this example 'Fruit' would have a count value of 2, 'Yellow' 1, and 'Round' 2.
How can I make a single KPI chart look at multiple columns and count their True values? I tried making a second data table to unpivot the columns into rows and have their count, which works, but then I am unsure as to how to make a relation between the two table such that I can mark and limit the original data table?
Please let me know if you require any information. I am using Spotfire 10.10, and this is how the data is presented to me, I cannot change it.

mailchimp - how to add default value for date field?

I want add a date field into Mailchimp with default value
name: gen
type: date
value: 2019-01-01
The instructions do not explain how to do it
I tried this values:
01/01/2019
2019-01-01
but when new user subrscribes to list,
i don't see any default value
Per documentation, "Default merge tag values will only display in campaigns, and not in your list fields."

Insert older than 7 days data into partitioned BigQuery tables

The documentation attests that it is possible to insert data older than 7 days (and not older than 1 year) into partitioned tables.
But whenever I try streaming one month old data using Go BigQuery Client, it returns an error: "You can only stream to date range within 7 days in the past and 3 days in the future relative to the current date."
How can I stream data older than 7 days using the Go client?
Edit 1: Here is the table schema:
bigquery.TableMetadata{
Schema: bigquery.Schema{
{Name: "page_id", Required: true, Type: bigquery.IntegerFieldType},
{Name: "user_id", Required: false, Type: bigquery.IntegerFieldType},
{Name: "hit_time", Required: true, Type: bigquery.TimestampFieldType},
},
TimePartitioning: &bigquery.TimePartitioning{Field: "hit_time", RequirePartitionFilter: true},
}
According to this issue, this is a new feature that "should be fully rolled out very soon". I got my project whitelisted to try it and I was able to insert older data into the tables.

How to add sorting by price on Sylius ProductController::indexByTaxon method

How would I go about adding a simple 'order by price desc' or 'order by price asc' select menu to a category listing page on Sylius frontend?
In example - on demo page here: http://demo.sylius.org/t/category/mugs
There's:
- filtering by price
So far I've managed to figure out that this is done via facets and configured in sylius_search like like this:
sylius_search:
...
filters:
pre_search_filter:
enabled: true
taxonomy: category
facet_groups:
search_set:
values: [taxons, price, made_of, color]
categories_set:
values: [price, made_of, color]
all_set:
values: [taxons, price, made_of]
facets:
taxons:
display_name: 'Basic categories'
type: terms
value: ~
price:
display_name: 'Available prices'
type: range
values:
- { from: 0, to: 2000}
- { from: 2001, to: 5000}
- { from: 5001, to: 10000}
made_of:
display_name: 'Material'
type: terms
value: ~
color:
display_name: 'Available colors'
type: terms
value: ~
Any attempt to figure this out ended up as a dead end or bunch of errors.
I can override product repository and try passing request along to add custom leftJoin to Variants and then add orderBy on doctrine query builder, but I'm guessing this is hacking and wouldn't get me very far.
So in short, how do I add sorting options to product listing page(s) so I can have my products sorted using master variant price?
Any help or guide in the right direction appreciated.

Sorting content of arrays in controller

I've got a 'status' and 'type' within a 'subjects' table. This status can contain the strings: 'Open', 'In progress' and 'Closed. I want to sort the output with 'In progress' first, then 'Open', then 'Closed'.
Within the sortings of status, I want to sort on types too, which can contain four different strings too.
Is this possible (in a controller) and if yes; how?
I've solved this by using enum.
I removed the string columns and used integers instead
schema.db
t.integer "status", default: 0
t.integer "casetype", default: 0
Then I added this to my Subject model
subject.rb
enum status: ['In progress', 'Open', 'Closed']
enum casetype: %w(Info NFI RFC RFA)
Then I ordered with this:
#subjects = Subject.all.order('status ASC, casetype')
More info about enum: http://edgeapi.rubyonrails.org/classes/ActiveRecord/Enum.html

Resources