Commit graph

87 commits

Author SHA1 Message Date
Matt Rogers
60ae4f6f5f
Convert before_filter to before_action
`before_filter` has been removed in future versions of rails.

Co-Authored-By: Dan Rice <dnrce@users.noreply.github.com>
2018-09-22 12:55:27 -05:00
Reinier Balt
0d224a5fe9 fasterer: hash#fetch with block is faster
hash#fetch with block is faster than hash#fetch with
second parameter
2015-08-19 14:49:52 +02:00
Matt Rogers
aa41e20e46 Remove trailing whitespace and tabs 2014-08-14 21:05:05 -05:00
Reinier Balt
2430fcb906 fix failing tests
not sure if the to_a fixes to get collections from activerecord is the right way
2014-05-16 14:33:18 +02:00
Don Cruse
8ed20b35f2 Fixing bug #1442
This bug was caused when the chart encountered data outside of its
visible range (i.e., the upper bound of the array size). A test was
added that inserts some data from 2 years and 16 months in the past.
The test failed on the old version, throwing exactly the error in bug
report #1442.

The fix is to check whether or not the value is within the array range
before sending the "+=" operator. With this change, the test passes.
2013-07-28 19:00:51 -05:00
Don Cruse
845ac14176 Moving label creation to helpers 2013-07-19 00:14:52 -05:00
Don Cruse
5b045d2c1a Moving time labels to separate methods 2013-07-18 23:56:57 -05:00
Don Cruse
25bf820edc Simplufying interpolation method 2013-07-18 23:48:33 -05:00
Don Cruse
3d2c048c44 Tweak to running averages 2013-07-18 23:43:44 -05:00
Don Cruse
ff54506e7f Removing a single-line method 2013-07-18 23:37:34 -05:00
Don Cruse
5e6b82c3e5 Combining the running average methods 2013-07-18 23:22:44 -05:00
Don Cruse
91e4717168 Removing some more intermediate values
Also removing the python-esque combination methods to set multiple
disparate variables from a single method by refactoring that to a
simpler method.

Reducing the complexity of computing running averages.

Note: It is not clear to me why the actions_done_lastyears_data
action is entirely unscoped on date. That seems to be the expected
behavior, so I left it alone.
2013-07-18 23:05:38 -05:00
Don Cruse
9073fa1237 Removing some intermediate values
This removes some intermediate steps that were ultimately not necessary
to the math.  It also consolidates some of the methods for counting events
so that fewer intermediate values are necessary.

To that end, a new scope is added to the ToDo model for events that are
*either* created_at or completed_at after a certain date. This scope
allows the StatsController to pull out the largest possible responsive
set of values, and then filter just the particular slices that it needs
for various steps in the calculation.
2013-07-18 22:32:44 -05:00
Don Cruse
70f633c150 Shifting more instance variables to the controller
Also removing some instance variables that were never invoked in the
views. This sets up a future refactoring of the method of comptuting
rolling averages, which differs between the two types of "last year"
views being refactored.
2013-07-18 21:01:39 -05:00
Don Cruse
1493304fc1 Refactor last year chart
Pulled some instance variable assignment into the controller.

Also extracted a method regarding interpolated values for the present
month.
2013-07-18 16:17:30 -05:00
Reinier Balt
a987ff3727 use size in stead of count to prevent unnecessary querying 2013-04-22 11:11:53 +02:00
Katrina Owen
a690e4a4cd Extract methods in pie chart data model 2013-03-18 19:57:42 -06:00
Katrina Owen
961227da0c Extract pie chart data logic into model layer
Move most of the tests for this logic into the unit test layer.
2013-03-18 19:49:54 -06:00
Katrina Owen
9f3470f9dc Shave off slight redundancy 2013-03-18 18:59:56 -06:00
Katrina Owen
f3a076c2af Turn unreferenced ivars into local variables 2013-03-18 18:58:36 -06:00
Katrina Owen
6e2f1a8e5f De-dupe pie chart view
Pull logic into the controller from the view. There were only a couple
of tiny differences between the running actions and the total actions
view, so I added a couple of instance variables and then called the same
template twice.
2013-03-18 18:56:41 -06:00
Katrina Owen
d6ed7d9722 Add heavy-handed tests against pie chart bug 2013-03-17 19:20:48 -06:00
Katrina Owen
119e536a97 Fix off-by-one error in pie chart data
A pie chart with exactly 10 contexts would show up with 9 contexts +
(other).
2013-03-17 16:20:12 -06:00
Katrina Owen
3479585991 Use a more appropriate name for stats domain object 2013-03-05 07:49:44 -07:00
Katrina Owen
d5a555fbac Encapsulate dependencies of stats index page
This may be a bit extreme.

It's modeled after the ideal "rails way".

In the controller, we now know the name of a single resource. It
doesn't happen to be backed by a database table, but it does know all
about the task of collecting stats, leaving the controller concerned
with just munging params and rendering stuff.

I called the resource `IndexPage`, to avoid the temptation of trying to
reuse it, which can get pretty messy.

Later, if a better abstraction appears, it should be fairly painless to
alter.
2013-03-02 17:35:19 -07:00
Katrina Owen
6df3534baf Inline last pieces into StatsController#index
We can now skip the before filter that sets instance variables.
2013-03-02 17:27:38 -07:00
Katrina Owen
ac4a483b18 Inline helper method 2013-03-02 17:24:05 -07:00
Katrina Owen
615a9e46c9 Encapsulate counts and totals into a class.
Move queries out of the view and into the model layer.
2013-03-02 17:22:15 -07:00
Katrina Owen
6ccb9a81fb Group context-related pieces in a class 2013-03-02 17:21:03 -07:00
Katrina Owen
8b1f0a34a0 Group project-related stats into a class.
Reduce number of instance variables available to the views.
Replace raw SQL with AR-type query.
2013-03-02 17:12:14 -07:00
Katrina Owen
0ebb98d49f Encapsulate action stats
This gets rid of a bunch of instance variables in the view/controller
layer.
2013-03-02 16:16:45 -05:00
Katrina Owen
1b7ed32024 Fold two more SQL queries into the query object 2013-03-02 07:54:13 -05:00
Matt Rogers
ae42f9c076 Merge pull request #163 from kytrinyx/stats-project-view
Simplify stats project view
2013-03-01 22:02:39 -08:00
Matt Rogers
3365b7e79f Merge pull request #162 from kytrinyx/projects-stats
Extract duplicate top projects query from stats controller
2013-03-01 21:58:34 -08:00
Katrina Owen
2686a0d3b5 Don't link to null projects
If you have fewer than 10 projects, then empty running projects were
linked to with the path `/projects/-1`.

Copy/pasted the list strategy from the other project sections in the
same partial so the duplication becomes explicit.
2013-03-02 00:19:47 -05:00
Katrina Owen
a23d2eb070 Extract duplicate context query from controller 2013-03-01 23:29:54 -05:00
Katrina Owen
6de4713d38 Extract top projects query object
This removed a bit of duplication from the stats controller.
2013-03-01 23:11:44 -05:00
Matt Rogers
f375c06964 Merge pull request #160 from kytrinyx/tag-counts
Extract duplicated query from stats controller
2013-03-01 18:52:52 -08:00
Katrina Owen
4dff7538ea Extract duplicated query
This includes a bit of a simplification which assumes that there aren't
any orphan taggings for a user.
2013-03-01 21:27:58 -05:00
Katrina Owen
0aa6ea183b Extract chart value object
This simplifies the views (slightly).
2013-03-01 20:38:24 -05:00
Matt Rogers
8b0f3e986a Merge branch 'tag-cloud' of https://github.com/kytrinyx/tracks 2013-03-01 16:49:53 -06:00
Katrina Owen
a13199cdda Add unit test for tag cloud 2013-03-01 16:03:35 -05:00
Katrina Owen
a81f5b76f3 Separate query from cloud
This will make testing easier
2013-03-01 13:14:27 -05:00
Reinier Balt
1e84adc91b get tests running and fix editing context state 2013-03-01 16:22:29 +01:00
Katrina Owen
0f5b402427 Use minimum of tag count for tag cloud
The tag cloud minimum used to start at 0, then repeatedly compared to
the lowest count and chose the smallest, which is bound to be zero in
every case.

Discussed
[here](8c26ea7cb5 (commitcomment-2719199)).
2013-03-01 00:13:41 -05:00
Katrina Owen
b5868d5c70 Use tag cloud objects in view
This allows us to not set the individual instance variables for the tag
cloud attributes.
2013-02-28 22:00:23 -05:00
Katrina Owen
61e04a8258 Extract methods in tag cloud
This gets rid of the compute method, and makes each value that got set
in it its own little method.
2013-02-28 21:53:19 -05:00
Katrina Owen
447178bd7d Collapse duplication in tag cloud model 2013-02-28 21:30:36 -05:00
Katrina Owen
edc793e703 Rename variables
The current user isn't necessarily current when it is in the model
layer.

The exposed attributes on the tag cloud no longer need to contain type
information.
2013-02-28 21:18:00 -05:00
Katrina Owen
8f6d57014a Extract tag cloud class from stats controller 2013-02-28 21:08:48 -05:00