Giter VIP home page Giter VIP logo

ipams's People

Contributors

baoyadu avatar goodmaoxixi avatar guanglindu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

ipams's Issues

Unable to autoload constant PaginatedCollectionPolicy

When running the functional and integration tests against search_controller.rb with some actual searching strings , this error occurs: "LoadError: Unable to autoload constant PaginatedCollectionPolicy, expected .../ipams/app/policies/paginated_collection_policy.rb to define it". However, this policy file was already created long before. The buggy testing code was commented out for the time being and labelled with FIXME.

Shrink repo size both locally and remotely

  1. Repo size bloated After installing Sunspot to search, I found the latest committed folder .git size increased from around 18MB to 51MB because folder vendor was not ignored by default and a lot of cached gems were committed. After reading this, Should I commit the dependencies in my vendor directory?, I decided to ignore this folder completely. I also ignore folder log (unnecessary to commit logs) and folder solr completely, for we have to do tricks when deploying Sunspot in the production environment. See sunspot solr in rails4 production.
  2. Solution After searching, testing for a lot of times on how to shrink the repo size both locally and on the github server side, this did the trick Shrinking your Git repository. I deleted folder vendor from the history, reducing folder .git to 1.4MB. The whole committed repo size is around 3.2MB. Much smaller!
  3. Notices

    3.1 You'd better operate on the master branch, then rebase the other branches on the master, or delete and then recreate the other branches, e.g., branch develop. Have to ask your teammates to re-clone or rebase on your shrunk repo.

    3.2 Found out that when rebasing, there're too many conflicts. So the best way might be to re-clone.

    3.3 Anyway, back up your original data. Do remind your teammates of this, too.

Play tricks after Sunspot was introduced in the production environment

  1. Problem Description

    No problem to add Sunspot to the development environment with the its default configuration. After upgrading the code in the production environment, solr can be started, but the follwing problems bite:

    (1) Reindex cannot be executed;

    (2) Nothing was found when searching even after changing /solr/production to /solr/default to execute reindex successfully according to some Googled solutions.
  2. Solution

    sunspot solr in rails4 production

Uniqueness validation problem with Chinese chars

The model uniqueness validation fails with Chinese characters. But it succeeds using ASCII. Highly possible that this is caused by the char encoding. One case is the name attribute of model User.

The appropriate value of maxGramSize in prefix-matching search

Implemented the prefix-matching search according to . When maxGramSize was 10, nothing would be found to search for IP address 192.168.1.1 or the alike in the Addresses view:

<filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="10" side="front"/>

After setting it 15, the problem was solved.

Paginate search results with will_paginate

To enable pagination after search, I implement like this in action index (see Will_Paginate with Sunspot โ€“ Ruby on Rails):

def index
  keywords = params[:search]
  keywords = keywords.strip if keywords

  # No keywords, no search
  @posts = nil
  if keywords && keywords != "" 
    search = Post.search do
      fulltext keywords
      # See http://www.whatibroke.com/?p=235
      paginate :page => params[:page] || 1, :per_page => 30
    end 
    # Type Sunspot::Search::PaginatedCollection < Array
    @posts = search.results
  else
    # paginate returns object os type User::ActiveRecord_Relation
    @posts = Post.paginate(page: params[:page], per_page: 100)
  end
  authorize @posts
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.