Why is total_voter_count always = 1 in Telegram Bot Poll object? - telegram-bot

Bot send poll in the bot chat(not in group). After user have chose answer(in my case, rated the movie) in the Poll, my Telegram Bot receive that json with Poll object info:
{'update_id': 684537001, 'poll': {'id': '5373079957893284661', 'question': 'Оцінити фільм "The Godfather"', 'options': [{'text': '10 point', 'voter_count': 1}, {'text': '9 point', 'voter_count': 0}, {'text': '8 point', 'voter_count': 0}, {'text': '7 point', 'voter_count': 0}, {'text': '6 point', 'voter_count': 0}, {'text': '5 point', 'voter_count': 0}, {'text': '4 point', 'voter_count': 0}, {'text': '3 point', 'voter_count': 0}, {'text': '2 point', 'voter_count': 0}, {'text': '1 point', 'voter_count': 0}], 'total_voter_count': 1, 'is_closed': False, 'is_anonymous': True, 'type': 'regular', 'allows_multiple_answers': False}}
Here, you can see that total_voter_count=1 . And it repeats even, if more than one user gave the answer. This is not good for me, because I want the users, after give the answer, to see how other users rated the movie. For example: 80% give 8 point and 20% give 6 point. How I can realize it by using Poll for Telegram Bots, without using only InlineKeyboardMarkup with callback_data. So I want the total_voter_count to increase after each user answer

Related

Group By with multiple Objects vb.net

I have a list as following
list1 = [
{meal: {id: 1, version: 0}, type: {id: 2, version: 0}, adjCount: 1, systemCount: 0},
{meal: {id: 1, version: 0}, type: {id: 2, version: 0}, adjCount: 2, systemCount: 0},
{meal: {id: 2, version: 0}, type: {id: 1, version: 0}, adjCount: 4, systemCount: 0},
{meal: {id: 2, version: 0}, type: {id: 1, version: 0}, adjCount: 7, systemCount: 0},
]
I'm looking for a result such as it returns both mealId and type id with it's respective totals
As
{meal: {id: 1, version: 0}, type: {id: 2, version: 0}, adjCount: 3, systemCount: 0},
{meal: {id: 2, version: 0}, type: {id: 1, version: 0}, adjCount: 11, systemCount: 0}
I tried Using Linq with following code
List.GroupBy(Function(myItem) New MyObject With {.mealTypeId = myItem.Meal.Id, .countTypeId = MyItem.Count.Id}).
Select(Function(g) New With
{
.MealTypeId = g.Key.MealTypeId,
.CountTypeId = g.Key.CountTypeId,
.AdjustmentCount = g.Sum(Function(i) i.AdjustmentCount),
.SystemCount = g.Sum(Function(i) i.SystemCount)
}
but it doesn't return the expected output. Any Help will be greatly appreciated, I very rarely ask questions here so please forgive any mistakes I might have done in describing the issue.

Add multiple business hours for 1 day and show business hours in Month View

I am using fullcalendar.io.
businessHours: [
{
daysOfWeek: [ 1, 2, 3],
startTime: '10:00',
endTime: '12:00',
},
{
daysOfWeek: [ 1, 2, 3],
startTime: '15:00',
endTime: '18:00',
}
]
I have one custom setting for a store on my website where they are only open between 10 Am to 12 PM and from 3 pm to 6 pm, I am using the full calendar to show their timing but here when I apply this setting its not working.
How can I show grey background during other timing which is not in business hours (i.e in between 12 PM to 3 PM)?

Api gives wrong data

I use the Google AdWords API to collect information about the search volume for a specific keyword. But the data I get as a response doesn't match with the data from the keyword planner or other keyword tools. Here I check the search volume for the keyword "Hunde" in Berlin, Germany in german.
targeting_service = adwordsClient.GetService('TargetingIdeaService')
selector = {'ideaType': 'KEYWORD', 'requestType' : 'STATS'}
selector['requestedAttributeTypes'] = ['KEYWORD_TEXT', 'SEARCH_VOLUME', 'TARGETED_MONTHLY_SEARCHES']
offset = 0
selector['paging'] = {'startIndex' : str(offset), 'numberResults' : str(1)}
selector['searchParameters'] = [{
'xsi_type': 'RelatedToQuerySearchParameter',
'queries': ["hunde"]
}]
selector['searchParameters'].append({
'xsi_type': 'LocationSearchParameter',
'locations': [{'id': '1003854'}]
})
selector['searchParameters'].append({
'xsi_type': 'LanguageSearchParameter',
'languages': [{'id': '1001'}]
})
page = targeting_service.get(selector)
print(page)
As a response I get:
{
'totalNumEntries': 1,
'entries': [
{
'data': [
{
'key': 'KEYWORD_TEXT',
'value': {
'Attribute.Type': 'StringAttribute',
'value': 'hunde'
}
},
{
'key': 'TARGETED_MONTHLY_SEARCHES',
'value': {
'Attribute.Type': 'MonthlySearchVolumeAttribute',
'value': [
{
'year': 2020,
'month': 12,
'count': 4743382
},
{
'year': 2020,
'month': 11,
'count': 455583
},
{
'year': 2020,
'month': 10,
'count': 8797951
},
{
'year': 2020,
'month': 9,
'count': 5218694
},
{
'year': 2020,
'month': 8,
'count': 5089585
},
{
'year': 2020,
'month': 7,
'count': 3149591
},
{
'year': 2020,
'month': 6,
'count': 3020638
},
{
'year': 2020,
'month': 5,
'count': 4928527
},
{
'year': 2020,
'month': 4,
'count': 754959
},
{
'year': 2020,
'month': 3,
'count': 5649676
},
{
'year': 2020,
'month': 2,
'count': 1590789
},
{
'year': 2020,
'month': 1,
'count': 2506674
}
]
}
},
{
'key': 'SEARCH_VOLUME',
'value': {
'Attribute.Type': 'LongAttribute',
'value': 3825504
}
}
]
}
]
}
But this data doesn't match with the data from the keyword planer.
Avg. monthly searches (Keyword planner): 10K – 100K
Does somebody knows why the data I'm receiving is wrong?
These questions pop up somewhat frequently and are generally not easy to answer. Did you make sure that the specified searchParameters in your request correspond exactly to what you are using in the Keyword Planner?
Additionally, you could check out the KeywordPlanService of the newer Ads API. According to this post by a Google Ads API advisor, it should be closer to what you can do in the web UI than the Adwords API's TargetingIdeaService.
If OP didn't figure it out, i've had the same headaches.
I solved this when adding NetworkSearchParameter to [searchparameter] so the API only returns google data.
my code after adding in the additional argument.
selector['searchParameters'] = [{
'xsi_type' : 'RelatedToQuerySearchParameter',
'queries' : sublist,
},
{
'xsi_type':'LocationSearchParameter',
'locations' : [country_ids[country]],
},
{
'xsi_type': 'NetworkSearchParameter',
'networkSetting': {
'targetGoogleSearch': True,
'targetSearchNetwork': False,
'targetContentNetwork': False,
'targetPartnerSearchNetwork': False
}}]

Jupyter .save_to_html function does not store config

I'm trying to use the .save_to_html() function for a kepler.gl jupyter notebook map.
It all works great inside jupyter, and I can re-load the same map with a defined config.
Where it goes wrong is when I use the save_to_html() function. The map will save to an html, but the configuration reverts to the basic configuration, before I customized it.
Please help! I love kepler, when I solve this little thing, it will be our absolute go-to tool
Thanks
Have tried to change the filters, colours, and point sizes. None of this works.
map_1 = KeplerGl(height=500, data={'data': df},config=config)
map_1
config = map_1.config
config
map_1.save_to_html(data={'data_1': df},
file_name='privateers.html',config=config)
Config
{'version': 'v1',
'config': {'visState': {'filters': [{'dataId': 'data',
'id': 'x8t9c53mf',
'name': 'time_update',
'type': 'timeRange',
'value': [1565687902187.5417, 1565775465282],
'enlarged': True,
'plotType': 'histogram',
'yAxis': None},
{'dataId': 'data',
'id': 'biysqlu36',
'name': 'user_id',
'type': 'multiSelect',
'value': ['HNc0SI3WsQfhOFRF2THnUEfmqJC3'],
'enlarged': False,
'plotType': 'histogram',
'yAxis': None}],
'layers': [{'id': 'ud6168',
'type': 'point',
'config': {'dataId': 'data',
'label': 'Point',
'color': [18, 147, 154],
'columns': {'lat': 'lat', 'lng': 'lng', 'altitude': None},
'isVisible': True,
'visConfig': {'radius': 5,
'fixedRadius': False,
'opacity': 0.8,
'outline': False,
'thickness': 2,
'strokeColor': None,
'colorRange': {'name': 'Uber Viz Qualitative 1.2',
'type': 'qualitative',
'category': 'Uber',
'colors': ['#12939A',
'#DDB27C',
'#88572C',
'#FF991F',
'#F15C17',
'#223F9A'],
'reversed': False},
'strokeColorRange': {'name': 'Global Warming',
'type': 'sequential',
'category': 'Uber',
'colors': ['#5A1846',
'#900C3F',
'#C70039',
'#E3611C',
'#F1920E',
'#FFC300']},
'radiusRange': [0, 50],
'filled': True},
'textLabel': [{'field': None,
'color': [255, 255, 255],
'size': 18,
'offset': [0, 0],
'anchor': 'start',
'alignment': 'center'}]},
'visualChannels': {'colorField': {'name': 'ride_id', 'type': 'string'},
'colorScale': 'ordinal',
'strokeColorField': None,
'strokeColorScale': 'quantile',
'sizeField': None,
'sizeScale': 'linear'}},
{'id': 'an8tbef',
'type': 'point',
'config': {'dataId': 'data',
'label': 'previous',
'color': [221, 178, 124],
'columns': {'lat': 'previous_lat',
'lng': 'previous_lng',
'altitude': None},
'isVisible': False,
'visConfig': {'radius': 10,
'fixedRadius': False,
'opacity': 0.8,
'outline': False,
'thickness': 2,
'strokeColor': None,
'colorRange': {'name': 'Global Warming',
'type': 'sequential',
'category': 'Uber',
'colors': ['#5A1846',
'#900C3F',
'#C70039',
'#E3611C',
'#F1920E',
'#FFC300']},
'strokeColorRange': {'name': 'Global Warming',
'type': 'sequential',
'category': 'Uber',
'colors': ['#5A1846',
'#900C3F',
'#C70039',
'#E3611C',
'#F1920E',
'#FFC300']},
'radiusRange': [0, 50],
'filled': True},
'textLabel': [{'field': None,
'color': [255, 255, 255],
'size': 18,
'offset': [0, 0],
'anchor': 'start',
'alignment': 'center'}]},
'visualChannels': {'colorField': None,
'colorScale': 'quantile',
'strokeColorField': None,
'strokeColorScale': 'quantile',
'sizeField': None,
'sizeScale': 'linear'}},
{'id': 'ilpixu9',
'type': 'arc',
'config': {'dataId': 'data',
'label': ' -> previous arc',
'color': [146, 38, 198],
'columns': {'lat0': 'lat',
'lng0': 'lng',
'lat1': 'previous_lat',
'lng1': 'previous_lng'},
'isVisible': True,
'visConfig': {'opacity': 0.8,
'thickness': 2,
'colorRange': {'name': 'Global Warming',
'type': 'sequential',
'category': 'Uber',
'colors': ['#5A1846',
'#900C3F',
'#C70039',
'#E3611C',
'#F1920E',
'#FFC300']},
'sizeRange': [0, 10],
'targetColor': None},
'textLabel': [{'field': None,
'color': [255, 255, 255],
'size': 18,
'offset': [0, 0],
'anchor': 'start',
'alignment': 'center'}]},
'visualChannels': {'colorField': None,
'colorScale': 'quantile',
'sizeField': None,
'sizeScale': 'linear'}},
{'id': 'inv52pp',
'type': 'line',
'config': {'dataId': 'data',
'label': ' -> previous line',
'color': [136, 87, 44],
'columns': {'lat0': 'lat',
'lng0': 'lng',
'lat1': 'previous_lat',
'lng1': 'previous_lng'},
'isVisible': False,
'visConfig': {'opacity': 0.8,
'thickness': 2,
'colorRange': {'name': 'Global Warming',
'type': 'sequential',
'category': 'Uber',
'colors': ['#5A1846',
'#900C3F',
'#C70039',
'#E3611C',
'#F1920E',
'#FFC300']},
'sizeRange': [0, 10],
'targetColor': None},
'textLabel': [{'field': None,
'color': [255, 255, 255],
'size': 18,
'offset': [0, 0],
'anchor': 'start',
'alignment': 'center'}]},
'visualChannels': {'colorField': None,
'colorScale': 'quantile',
'sizeField': None,
'sizeScale': 'linear'}}],
'interactionConfig': {'tooltip': {'fieldsToShow': {'data': ['time_ride_start',
'user_id',
'ride_id']},
'enabled': True},
'brush': {'size': 0.5, 'enabled': False}},
'layerBlending': 'normal',
'splitMaps': []},
'mapState': {'bearing': 0,
'dragRotate': False,
'latitude': 49.52565611453996,
'longitude': 6.2730441822977845,
'pitch': 0,
'zoom': 9.244725880765998,
'isSplit': False},
'mapStyle': {'styleType': 'dark',
'topLayerGroups': {},
'visibleLayerGroups': {'label': True,
'road': True,
'border': False,
'building': True,
'water': True,
'land': True,
'3d building': False},
'threeDBuildingColor': [9.665468314072013,
17.18305478057247,
31.1442867897876],
'mapStyles': {}}}}
Expected:
Fully configurated map as in Jupyter widget
Actuals
Colors and filters are not configured. Size and position of map is sent along, so if I store it looking at an empty area, when I open the html file it looks at the same field
In the Jupyter user guide for kepler.gl under the save section
# this will save current map
map_1.save_to_html(file_name='first_map.html')
# this will save map with provided data and config
map_1.save_to_html(data={'data_1': df}, config=config, file_name='first_map.html')
# this will save map with the interaction panel disabled
map_1.save_to_html(file_name='first_map.html', read_only=True)
So it looks like its a bug if the configuration parameter doesn't work or you are making the changes to the map configure after you set it equal to config. This would be fixed if you set
map_1.save_to_html(data={'data_1': df},
file_name='privateers.html',config=map_1.config)
I think it is a bug (or feature?) happens when you use the same cell to save the map configuration or still not print the map out yet. Generally, the config only exists after you really print the map out.
the problem, as far as I see it and how I solved at a similar problem is, that you 1) named your 'data' key in instancing the map different than you told it to save in the HTML 2).
map_1 = KeplerGl(height=500, data={'data': df},config=config)
map_1.save_to_html(data={'data_1': df}, file_name='privateers.html',config=config)
Name both keys the same and your HTML file will use the correct configuration.
Had this issue as well. Solved it by converting all pandas column dtypes to those that are json serializable: i.e. converting 'datetime' column from dtype <m8[ns] to object.

Pig XmlLoader code

Could someone please help with how to write a pig xmlloader for this kind of data.
<?xml version="1.0" encoding="utf-8"?>
<posts>
<row Id="1" PostTypeId="1" AcceptedAnswerId="9" CreationDate="2012-01-17T21:03:59.200" Score="30" ViewCount="698" Body="<p>From the front end, <code>\[InvisibleApplication]</code> can be entered as <kbd>Esc</kbd> <kbd>#</kbd> <kbd>Esc</kbd>, and is an invisible operator for <code>#</code>!. By an unfortunate combination of key-presses (there may have been a cat involved), this crept up in my code and I spent a great deal of time trying to figure out why in the world <code>f x</code> was being interpreted as <code>f[x]</code>. Example:</p>
<p><img src="http://i.stack.imgur.com/2Hxll.png" alt="enter image description here"></p>
<p>Now there is no way I could've spotted this visually. The <code>*Form</code>s weren't of much help either. If you're careful enough, you can see an invisible character between <code>f</code> and <code>x</code> if you move your cursor across the expression. Eventually, I found this out only by looking at the contents of the cell. </p>
<p>There's also <code>\[InvisibleSpace]</code>, <code>\[InvisibleComma]</code> and <code>\[ImplicitPlus]</code>, which are analogous to the above. There must be some use for these (perhaps internally), which is why it has been implemented in the first place. I can see the use for invisible space (lets you place superscripts/subscripts without needing anything visible to latch on to), and invisible comma (lets you use indexing like in math). It's the invisible apply that has me wondering...</p>
<p>The only advantage I can see is to sort of visually obfuscate the code. Where (or how) is this used (perhaps internally?), and can I disable it? If it's possible to disable, will there be any side effects?</p>
" OwnerUserId="5" LastEditorUserId="5" LastEditDate="2012-04-29T04:50:20.303" LastActivityDate="2013-10-22T10:48:32.560" Title="Usage of \[InvisibleApplication] and other related invisible characters" Tags="<front-end><syntax>" AnswerCount="4" CommentCount="1" FavoriteCount="4" />
<row Id="2" PostTypeId="1" AcceptedAnswerId="42" CreationDate="2012-01-17T21:10:34.680" Score="49" ViewCount="1347" Body="<p><code>Cases</code>, <code>Select</code>,<code>Pick</code> and <code>Position</code> each have different syntaxes and purposes, but there are times when you can express the same calculation equivalently using either of them. So with this input:</p>
<pre><code>test = RandomInteger[{-25, 25}, {20, 2}]
{{-15, 13}, {-8, 16}, {-8, -19}, {7, 6}, {-21, 9}, {-3, -25}, {21, -18}, {4, 4}, {2, -2}, {-24, 8}, {-17, -8}, {4, -18}, {22, -24}, {-4, -3}, {21, 0}, {19, 18}, {-23, -8}, {23, -25}, {14, -2}, {-1, -13}}
</code></pre>
<p>You can get the following equivalent results:</p>
<pre><code>Cases[test, {_, _?Positive}]
{{-15, 13}, {-8, 16}, {7, 6}, {-21, 9}, {4, 4}, {-24, 8}, {19, 18}}
Select[test, #[[2]] &gt; 0 &amp;]
{{-15, 13}, {-8, 16}, {7, 6}, {-21, 9}, {4, 4}, {-24, 8}, {19, 18}}
Pick[test, Sign[test[[All, 2]] ], 1]
{{-15, 13}, {-8, 16}, {7, 6}, {-21, 9}, {4, 4}, {-24, 8}, {19, 18}}
test[[Flatten#Position[test[[All, 2]], _?Positive] ]]
{{-15, 13}, {-8, 16}, {7, 6}, {-21, 9}, {4, 4}, {-24, 8}, {19, 18}}
</code></pre>
<p>Are there performance or other considerations that should guide which you should use? For example, is the pattern-matching used in <code>Cases</code> likely to be slower than the functional tests used in <code>Select</code>? Are there any generic rules of thumb, or is testing the particular case you are using the only solution?</p>
" OwnerUserId="8" LastEditorUserId="8" LastEditDate="2012-01-20T04:45:34.940" LastActivityDate="2012-01-20T04:45:34.940" Title="What best practices or performance considerations are there for choosing between Cases, Position, Pick and Select?" Tags="<performance-tuning><pattern-matching>" AnswerCount="4" CommentCount="0" FavoriteCount="28" />
</posts>
If you want load the xml data below is the following code
A = LOAD '$input' using
org.apache.pig.piggybank.storage.XMLLoader('row')
as (x:chararray);
B = FOREACH A GENERATE x;
dump B;