i made several tests and this behaviour is strange :
events: [
{
title : 'event2',
start : '2018-02-05',
end : '2018-02-07 08:00:00'
}
]
and the event appears as a 2 days event ( 5 and 6 ) ( bad behaviour for my project )
events: [
{
title : 'event2',
start : '2018-02-05',
end : '2018-02-07 09:00:00'
}
]
and the event appears as a 3 days event ( 5,6 and 7 ) ( good behaviour for my project )
there's something around 9 o'clock i dont know what, how can i fix it ??
In the fullCalendar options it's possible to add
nextDayThreshold: "00:00:00"
and the behaviour around 9am disappears.
The default value for nextDayThreshold is 9am.
thx again for the indication about nextDayThreshold
nevertheless it seems there is a strange behaviour with 00:00:00 only this value, i mean :
events: [
{
title : 'event2',
start : '2018-02-05',
end : '2018-02-07 01:00:00'
}
],
nextDayThreshold: "01:00:00"
gives a 3-days large event on calendar ( normal ), but
events: [
{
title : 'event2',
start : '2018-02-05',
end : '2018-02-07 00:00:00'
}
],
nextDayThreshold: "00:00:00"
gives only a 2-days large event , alas...
Related
I'm using the daterangepicker from https://sensortower.github.io/daterangepicker/docs#configuration
$(".daterangepicker-field").daterangepicker({
startDate:moment(),
endDate:moment(),
timeZone:'Europe/Bucharest',
forceUpdate: true,
orientation:'left',
ranges:{},
periods: ['day','week','month','year'],
expanded:true,
firstDayOfWeek: 0,
minDate:'2019-01-01',
callback: function(startDate, endDate, period){
var title = startDate.format('MMM D, YYYY') + ' – ' + endDate.format('MMM D, YYYY');
$(this).val(title);
}
});
The problem is, if I set the firstDayOfWeek: 1 (Monday), the calendar will change the label from Sunday to Monday, but in fact the days in the calendar will remain the same - so the calendar is wrong.
Can you help me figure out what is causing this?
Thanks!
I finally solve it, in case someone else needs it. The issue was related to moment.js.
I used the documentation found here:
https://momentjs.com/docs/#/customization/dow-doy/
with the following code:
moment.updateLocale("en", { week: {
dow: 1, // First day of week is Monday
}});
According to this answer and its helpful Ellie I now have an idea of how we get the current time in Elm 0.18.
I want to get the current time and then post it in JSON to my server. I already have a POST working with a hardcoded timestamp, but I just don't see how to get the current time and then include it in the JSON I am POSTing.
My guess is that I need to chain a couple of commands (get current time, make a POST to server).
[I have also read another SO which shows how you can run a few commands in a row by directly calling the update function, which sounds like a nice idea but I am not sure if it is what I need for my situation.]
Experiment ([edit] perhaps more of a distraction than was intended)
In order to get my head around this I thought I would try to solve a similar problem that I can more easily set up in Ellie.
In the original Ellie the current time is gotten, updated into the model, and then the view function shows it.
In my version I wanted this to be a two-step process and therefore have grown the model to be a Maybe Float for the time and a String message. The view function shows the message string and a button -- the plan is that when the button is pressed it tells the runtime to 'go get the current time and then copy it across into the message slot'.
If I can solve this problem then I feel like I can solve my original problem.
My Ellie does not do this yet. When you press the button the time is gotten and is put into the time slot in the model, but I do not know how to tell the runtime to '...now copy that time across into the message slot'. The PutTimeInMessage message is in place, but I don't know how to get it to run after the GetCurrentTime message/command.
Any suggestions?
Here is my code so far (it compiles), which you can run here in Ellie:
module Main exposing (..)
import Html exposing (..)
import Html.Events exposing (..)
import Time exposing (Time)
import Date
import Task
type alias Model =
{ time : Maybe Float
, message : String
}
type Msg
= OnTime Time
| GetCurrentTime
| PutTimeInMessage
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
OnTime t ->
( { model | time = Just t }, Cmd.none )
GetCurrentTime ->
( model, getTime )
PutTimeInMessage ->
case model.time of
Nothing ->
( model, Cmd.none )
Just t ->
( { model | message = toString t }, Cmd.none )
view : Model -> Html Msg
view model =
div []
[ div []
[ button [ onClick GetCurrentTime ] [ Html.text "Get now time." ]
]
, model.message |> Html.text
]
getTime : Cmd Msg
getTime =
Time.now
|> Task.perform OnTime
main =
Html.program
{ init = ( Model Nothing "Empty message.", Cmd.none )
, update = update
, view = view
, subscriptions = always Sub.none
}
The way I see it, you can just update message field along with time field, when OnTime message is received. Thus, the whole update function is going to look like this:
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
OnTime t ->
( { model | time = Just t, message = toString t }, Cmd.none )
GetCurrentTime ->
( model, getTime )
The message is set in OnTime action, because in the GetCurrentTime time is unknown and is known only after getTime function is perform and OnTime message is received.
If you still want to use a separate action for putting the message, then the following code is the option:
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
OnTime t ->
update PutTimeInMessage { model | time = Just t }
GetCurrentTime ->
( model, getTime )
PutTimeInMessage ->
case model.time of
Nothing ->
( model, Cmd.none )
Just t ->
( { model | message = toString t }, Cmd.none )
But to be honest, the most preferable solution, would be just displaying the time in the view differently, so you don't need the message field (but probably I don't see the whole picture):
view : Model -> Html Msg
view model =
div []
[ div []
[ button [ onClick GetCurrentTime ] [ Html.text "Get now time." ]
]
, viewTime model.time
]
viewTime : Maybe Float -> Html Msg
viewTime time =
case time of
Nothing -> Html.text "Empty message."
Just t -> Html.text (toString t)
I came across an SO which explained how to do a sequence of Http requests with Task.andThen. Since I can see the type of Time.now is a Task I figured that I could adapt that example for my purposes if I use Http.toTask.
Below is the solution I came up with and here it is in Ellie:
module Main exposing (..)
import Html exposing (..)
import Html.Events exposing (..)
import Http
import Json.Decode as JD
import Json.Encode as JE
import Task
import Time
type alias Model =
{ url : String
}
type Msg
= PostTimeToServer
| PostDone (Result Http.Error String)
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
PostTimeToServer ->
( model, postTimeToServer model.url )
PostDone _ ->
( model, Cmd.none )
view : Model -> Html Msg
view model =
div []
[ div []
[ button [ onClick PostTimeToServer ] [ Html.text "POST the current time." ]
]
]
postTimeToServer : String -> Cmd Msg
postTimeToServer url =
let
getTime =
Time.now
postTime t =
JD.string
|> Http.post url (JE.float t |> Http.jsonBody)
|> Http.toTask
request =
getTime <<-- Here is
|> Task.andThen postTime <<-- the key bit.
in
Task.attempt PostDone request
main =
Html.program
{ init = ( Model "url_here", Cmd.none )
, update = update
, view = view
, subscriptions = always Sub.none
}
Background
I was doing some tests to see which would be the best for a primary key. I assumed that BSON would be better than a string. When I run some tests though, I'm getting about the same results. Am I doing something wrong here or can someone confirm that this is correct?
About my tests
I have created 200k records with 2 mongoid models. I ran everything in ruby benchmark. I did three main queries, a find(id) query, a where(id: id)query and a where(:id.in => array_of_ids). All of which gave me pretty similar response times.
Benchmark.bm(10) do |x|
x.report("String performance") { 100.times { ModelString.where(id: '58205ae41d41c81c5a0289e5').pluck(:id) } }
x.report("BSON performance") { 100.times { ModelBson.where(id: '581a1d271d41c82fc3030a34').pluck(:id) } }
end
Here are my models in Mongoid:
class ModelBson
include Mongoid::Document
end
class ModelString
include Mongoid::Document
field :_id, type: String, pre_processed: true, default: ->{ BSON::ObjectId.new.to_s }
end
Benchmark Results
ID miss "find" query
user system total real
String performance 0.140000 0.070000 0.210000 ( 2.187263)
BSON performance 0.280000 0.060000 0.340000 ( 2.308928)
ID hit "find" query
user system total real
String performance 0.280000 0.060000 0.340000 ( 2.392995)
BSON performance 0.190000 0.060000 0.250000 ( 2.245230)
100 IDs "in" query hit
String performance 0.850000 0.110000 0.960000 ( 9.221822)
BSON performance 0.770000 0.060000 0.830000 ( 8.055971)
db.collection.stats
{
"ns" : "model_bsons",
"count" : 199221,
"size" : 9562704,
"avgObjSize" : 48,
"numExtents" : 7,
"storageSize" : 22507520,
"lastExtentSize" : 11325440,
"paddingFactor" : 1,
"paddingFactorNote" : "paddingFactor is unused and unmaintained in 3.0. It remains hard coded to 1.0 for compatibility only.",
"userFlags" : 1,
"capped" : false,
"nindexes" : 1,
"indexDetails" : {
},
"totalIndexSize" : 6475392,
"indexSizes" : {
"_id_" : 6475392
},
"ok" : 1
}
{
"ns" : "model_strings",
"count" : 197680,
"size" : 9488736,
"avgObjSize" : 48,
"numExtents" : 7,
"storageSize" : 22507520,
"lastExtentSize" : 11325440,
"paddingFactor" : 1,
"paddingFactorNote" : "paddingFactor is unused and unmaintained in 3.0. It remains hard coded to 1.0 for compatibility only.",
"userFlags" : 1,
"capped" : false,
"nindexes" : 1,
"indexDetails" : {
},
"totalIndexSize" : 9304288,
"indexSizes" : {
"_id_" : 9304288
},
"ok" : 1
}
This is correct.
As you can see from collections stats, documents from both collections have the same size (avgObjSize field). So there is no difference between BSON ObjectID and string field size (both 12 bytes).
What really matters is the index size. Here you can notice that index size on
BSON collections is about 30% smaller than on String collection, because BSON objectID can take full advantage of index prefix compression. The index size difference is too small to see a real performance change with 200 000 documents, but I guess that increasing the number of documents could show different results
I have problem with count performance in MongoDB.
I'm using ZF2 and Doctrine ODM with SoftDelete filter. Now when query "first time" collection with db.getCollection('order').count({"deletedAt": null}), it takes about 30 seconds, sometimes even more. Second and more query takes about 150ms. After few minutes query takes again about 30 seconds. This is only on collections with size > 700MB.
Server is Amazon EC2 t2.medium instance, Mongo 3.0.1
Maybe it similar to MongoDB preload documents into RAM for better performance, but those answers do not solve my problem.
Any ideas what is going on?
/edit
explain
{
"executionSuccess" : true,
"nReturned" : 111449,
"executionTimeMillis" : 24966,
"totalKeysExamined" : 0,
"totalDocsExamined" : 111449,
"executionStages" : {
"stage" : "COLLSCAN",
"filter" : {
"$and" : []
},
"nReturned" : 111449,
"executionTimeMillisEstimate" : 281,
"works" : 145111,
"advanced" : 111449,
"needTime" : 1,
"needFetch" : 33660,
"saveState" : 33660,
"restoreState" : 33660,
"isEOF" : 1,
"invalidates" : 0,
"direction" : "forward",
"docsExamined" : 111449
},
"allPlansExecution" : []
}
The count will go through each document which is creating performance issues.
Care about the precise number if it's a small one. You're interested to know if there are 100 results or 500. But once it goes beyond, let's say, 10000, you can just say 'More than 10000 results' found to the user.
db.getCollection('order').find({"deletedAt": null}).limit(10000).count(true)
I have this hash
- "title" : "The Today Show",
- "category; "Show",
- "channel-name": "CNBC",
- "scheduling" =>
{ "start" : "7am", "stop" : "9am"},
{ "start" : "10am", "stop" : "11am"},
{ "start" : "11am", "stop": "12am"}
- "title" : "How I met your mother",
- "category; "Show",
- "channel-name": "CBS",
- "scheduling" =>
{ "start" : "7pm", "stop" : "9pm"},
{ "start" : "10pm", "stop" : "12pm"},
{ "start" : "11am", "stop": "12am"}
I need to "select" only programs which have at least one schedule beetween "7pm"-"9pm"
I tried this, but it isn't working
programs.select_by{|p|
p.scheduling.each{|ps|
ps.start <= "7pm" && ps.stop <= "9pm"
}
}
PS: I used a pseudo-code for the date-comparison just to make this code more readable :)
Try this
programs.select do |p|
p.scheduling.any? do |ps|
ps.start >= "7pm" && ps.stop <= "9pm"
end
end